diff options
author | Peter Wu | 2018-08-30 16:36:29 +0200 |
---|---|---|
committer | Peter Wu | 2018-08-30 16:36:29 +0200 |
commit | 6a0252c6de229076e2730a5f9c07d9776ddfeaba (patch) | |
tree | 05ffe323ec1ee3288b940a390633ac5f2ea78022 /src | |
parent | be3ab16315b09ba008e7faa469ad295c409796a1 (diff) | |
download | noscript-6a0252c6de229076e2730a5f9c07d9776ddfeaba.tar.gz noscript-6a0252c6de229076e2730a5f9c07d9776ddfeaba.tar.xz noscript-6a0252c6de229076e2730a5f9c07d9776ddfeaba.zip |
Fix fallback scripts when ServiceWorkers are unavailable
ServiceWorkers are not available in private browsing mode (and can be
disabled otherwise via about:config), be sure to check its availability.
Otherwise fallback scripts are not invoked which prevents redirections
in <noscript> tags from being executed (as observed with t.co).
Diffstat (limited to 'src')
-rw-r--r-- | src/content/content.js | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/content/content.js b/src/content/content.js index eb4fcdd..e73feb6 100644 --- a/src/content/content.js +++ b/src/content/content.js @@ -85,13 +85,13 @@ ns.on("capabilities", () => { if (!ns.canScript) { - if (!!navigator.serviceWorker.controller) { + if ("serviceWorker" in navigator && navigator.serviceWorker.controller) { addEventListener("beforescriptexecute", e => e.preventDefault()); - (async () => { - for (let r of await navigator.serviceWorker.getRegistrations()) { - await r.unregister(); - } - })(); + (async () => { + for (let r of await navigator.serviceWorker.getRegistrations()) { + await r.unregister(); + } + })(); } if (document.readyState !== "loading") onScriptDisabled(); |