From 491bf8eb33524065315a9c5b63b746c34891d070 Mon Sep 17 00:00:00 2001 From: hackademix Date: Fri, 1 Nov 2019 00:19:02 +0100 Subject: Script blocking before policy is fetched only for synchronous loads. --- src/content/staticNS.js | 22 ++++++++++++---------- 1 file 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)); } } } -- cgit v1.2.3