Applied fixed to all code snippets in README.md so that they are syntactically valid.
This commit is contained in:
parent
0fd508671a
commit
a7cbdcc23e
12
README.md
12
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:
|
tabs, and notify the user that is has been done:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
browser.storage.get("urls").then(({urls}) => {
|
browser.storage.local.get("urls").then(({urls}) => {
|
||||||
return browser.tabs.query({url: urls});
|
return browser.tabs.query({url: urls});
|
||||||
}).then(tabs => {
|
}).then(tabs => {
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
Array.from(tabs, tab => browser.tabs.reload(tab.id)));
|
Array.from(tabs, tab => browser.tabs.reload(tab.id))
|
||||||
);
|
);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
return browser.notifications.create({
|
return browser.notifications.create({
|
||||||
|
@ -138,12 +138,12 @@ Or, using an async function:
|
||||||
```javascript
|
```javascript
|
||||||
async function reloadTabs() {
|
async function reloadTabs() {
|
||||||
try {
|
try {
|
||||||
let {urls} = await browser.storage.get("urls");
|
let {urls} = await browser.storage.local.get("urls");
|
||||||
|
|
||||||
let tabs = await browser.tabs.query({url: urls});
|
let tabs = await browser.tabs.query({url: urls});
|
||||||
|
|
||||||
await Promise.all(
|
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({
|
await browser.notifications.create({
|
||||||
|
@ -173,7 +173,7 @@ And like this from the content script:
|
||||||
```javascript
|
```javascript
|
||||||
browser.runtime.onMessage.addListener(msg => {
|
browser.runtime.onMessage.addListener(msg => {
|
||||||
if (msg == "get-ids") {
|
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),
|
return Array.from(document.querySelectorAll(idPattern),
|
||||||
elem => elem.textContent);
|
elem => elem.textContent);
|
||||||
});
|
});
|
||||||
|
@ -186,7 +186,7 @@ or:
|
||||||
```javascript
|
```javascript
|
||||||
browser.runtime.onMessage.addListener(async function(msg) {
|
browser.runtime.onMessage.addListener(async function(msg) {
|
||||||
if (msg == "get-ids") {
|
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),
|
return Array.from(document.querySelectorAll(idPattern),
|
||||||
elem => elem.textContent);
|
elem => elem.textContent);
|
||||||
|
|
Loading…
Reference in New Issue