Add async function version of message listener example.
This commit is contained in:
parent
0007c27bb9
commit
2dd404db0f
13
README.md
13
README.md
|
@ -158,4 +158,17 @@ browser.runtime.onMessage.addListener(msg => {
|
|||
});
|
||||
```
|
||||
|
||||
or:
|
||||
|
||||
```javascript
|
||||
browser.runtime.onMessage.addListener(async function(msg) {
|
||||
if (msg == "get-ids") {
|
||||
let {idPattern} = await browser.storage.get("idPattern");
|
||||
|
||||
return Array.from(document.querySelectorAll(idPattern),
|
||||
elem => elem.textContent);
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Or vice versa.
|
||||
|
|
Loading…
Reference in New Issue