diff options
Diffstat (limited to 'source/background.ts')
-rw-r--r-- | source/background.ts | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/source/background.ts b/source/background.ts index e189e0ae..1e182660 100644 --- a/source/background.ts +++ b/source/background.ts @@ -45,6 +45,8 @@ addDomainPermissionToggle(); // `background` fetch required to avoid avoid CORB introduced in Chrome 73 https://chromestatus.com/feature/5629709824032768 // Don’t turn this into an `async` function https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onMessage#addListener_syntax -browser.runtime.onMessage.addListener(({request}): Promise<Response> | void => { - return fetch(request).then(async response => response.json()); +browser.runtime.onMessage.addListener((message): Promise<string> | void => { + if (message?.request) { + return fetch(message.request).then(async response => response.text()); + } }); |