From a7cbdcc23e069979b81cab87fbfa89c5e7442d30 Mon Sep 17 00:00:00 2001 From: Rob Wu Date: Mon, 19 Mar 2018 15:42:40 +0100 Subject: [PATCH] fix: Use browser.storage.local in README (#87) (#90) Applied fixed to all code snippets in README.md so that they are syntactically valid. --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 8d953ed..48e6ba5 100644 --- a/README.md +++ b/README.md @@ -115,11 +115,11 @@ API, retrieve a list of tabs which match any of them, reload each of those tabs, and notify the user that is has been done: ```javascript -browser.storage.get("urls").then(({urls}) => { +browser.storage.local.get("urls").then(({urls}) => { return browser.tabs.query({url: urls}); }).then(tabs => { return Promise.all( - Array.from(tabs, tab => browser.tabs.reload(tab.id))); + Array.from(tabs, tab => browser.tabs.reload(tab.id)) ); }).then(() => { return browser.notifications.create({ @@ -138,12 +138,12 @@ Or, using an async function: ```javascript async function reloadTabs() { try { - let {urls} = await browser.storage.get("urls"); + let {urls} = await browser.storage.local.get("urls"); let tabs = await browser.tabs.query({url: urls}); await Promise.all( - Array.from(tabs, tab => browser.tabs.reload(tab.id))); + Array.from(tabs, tab => browser.tabs.reload(tab.id)) ); await browser.notifications.create({ @@ -173,7 +173,7 @@ And like this from the content script: ```javascript browser.runtime.onMessage.addListener(msg => { if (msg == "get-ids") { - return browser.storage.get("idPattern").then(({idPattern}) => { + return browser.storage.local.get("idPattern").then(({idPattern}) => { return Array.from(document.querySelectorAll(idPattern), elem => elem.textContent); }); @@ -186,7 +186,7 @@ or: ```javascript browser.runtime.onMessage.addListener(async function(msg) { if (msg == "get-ids") { - let {idPattern} = await browser.storage.get("idPattern"); + let {idPattern} = await browser.storage.local.get("idPattern"); return Array.from(document.querySelectorAll(idPattern), elem => elem.textContent);