diff options
author | hackademix | 2019-10-01 22:46:43 +0200 |
---|---|---|
committer | hackademix | 2019-10-01 22:47:19 +0200 |
commit | 958bfba66c339d388487e7131402959c89db7553 (patch) | |
tree | dee00084cf2a97be0b8a039843482a376eeb9d43 | |
parent | 0940fc84b3c9387b9eb371592625ab2d7ab259e2 (diff) | |
download | noscript-958bfba66c339d388487e7131402959c89db7553.tar.gz noscript-958bfba66c339d388487e7131402959c89db7553.tar.xz noscript-958bfba66c339d388487e7131402959c89db7553.zip |
SyncMessage support for asynchronous listeners.
-rw-r--r-- | src/lib/SyncMessage.js | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/lib/SyncMessage.js b/src/lib/SyncMessage.js index b9e5006..2f06d3e 100644 --- a/src/lib/SyncMessage.js +++ b/src/lib/SyncMessage.js @@ -82,10 +82,9 @@ console.error(e, "Processing message %o from %o", msg, sender); } } - return { - redirectUrl: `data:application/json,${JSON.stringify(result)}` - }; + return result instanceof Promise ? (async () => ret(await result)) : ret(result); }; + let ret = r => ({redirectUrl: `data:application/json,${JSON.stringify(r)}`}) let listeners = new Set(); browser.runtime.onSyncMessage = { |