fix: Use browser.storage.local in README (#87) (#90)

Applied fixed to all code snippets in README.md so that they are syntactically valid.
This commit is contained in:
Rob Wu 2018-03-19 15:42:40 +01:00 committed by Luca Greco
parent 0fd508671a
commit a7cbdcc23e
1 changed files with 6 additions and 6 deletions

View File

@ -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);