diff options
author | hackademix | 2019-11-01 00:19:02 +0100 |
---|---|---|
committer | hackademix | 2019-11-01 00:19:56 +0100 |
commit | 491bf8eb33524065315a9c5b63b746c34891d070 (patch) | |
tree | cb306f0c4e68eac40fb7c8332946a8f8ac92ee42 /src/content | |
parent | 7c33fddd2c83619a4410fa2b8c944da16eb8f7df (diff) | |
download | noscript-491bf8eb33524065315a9c5b63b746c34891d070.tar.gz noscript-491bf8eb33524065315a9c5b63b746c34891d070.tar.xz noscript-491bf8eb33524065315a9c5b63b746c34891d070.zip |
Script blocking before policy is fetched only for synchronous loads.
Diffstat (limited to 'src/content')
-rw-r--r-- | src/content/staticNS.js | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/content/staticNS.js b/src/content/staticNS.js index 1d00ecf..ca9de41 100644 --- a/src/content/staticNS.js +++ b/src/content/staticNS.js @@ -59,15 +59,17 @@ let originalState = document.readyState; let blockedScripts = []; - addEventListener("beforescriptexecute", e => { - // safety net for syncrhonous load on Firefox - if (!this.canScript) { - e.preventDefault(); - let script = e.target; - blockedScripts.push(script) - log("Some script managed to be inserted in the DOM while fetching policy, blocking it.\n", script); - } - }, true); + if (/^(?:ftp|file):/.test(url)) { + addEventListener("beforescriptexecute", e => { + // safety net for synchronous loads on Firefox + if (!this.canScript) { + e.preventDefault(); + let script = e.target; + blockedScripts.push(script) + log("Some script managed to be inserted in the DOM while fetching policy, blocking it.\n", script); + } + }, true); + } let policy = null; @@ -79,7 +81,7 @@ // something went wrong, e.g. with session restore. for (let s of blockedScripts) { // reinsert the script - s.replace(s.cloneNode(true)); + s.replaceWith(s.cloneNode(true)); } } } |