From 820208371032c7e410c0f2487ad608fca74ac9aa Mon Sep 17 00:00:00 2001 From: Thomas Rupprecht Date: Fri, 6 Jan 2023 02:19:12 +0100 Subject: [PATCH] use globalThis instead of window to also work in service worker --- src/background.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/background.js b/src/background.js index f7868a9..f2a89d6 100644 --- a/src/background.js +++ b/src/background.js @@ -94,13 +94,13 @@ function startFetching() { }); } -window.addEventListener('offline', async () => { +globalThis.addEventListener('offline', async () => { browser.alarms.onAlarm.removeListener(handleAlarm); await browser.alarms.clear('fetchData'); }); -window.addEventListener('online', () => { +globalThis.addEventListener('online', () => { startFetching(); }); -if (window.navigator.onLine) { +if (globalThis.navigator.onLine) { startFetching(); }