summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhackademix2018-08-30 17:19:51 +0200
committerGitHub2018-08-30 17:19:51 +0200
commit379addaf3f3f20cfc9d3513c2ba4da099af1cade (patch)
tree05ffe323ec1ee3288b940a390633ac5f2ea78022
parentbe3ab16315b09ba008e7faa469ad295c409796a1 (diff)
parent6a0252c6de229076e2730a5f9c07d9776ddfeaba (diff)
downloadnoscript-379addaf3f3f20cfc9d3513c2ba4da099af1cade.tar.gz
noscript-379addaf3f3f20cfc9d3513c2ba4da099af1cade.tar.xz
noscript-379addaf3f3f20cfc9d3513c2ba4da099af1cade.zip
Merge pull request #17 from Lekensteyn/fix-serviceworker-check
Fix fallback scripts when ServiceWorkers are unavailable
-rw-r--r--src/content/content.js12
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();