summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhackademix2019-11-03 13:32:07 +0100
committerhackademix2019-11-03 13:32:07 +0100
commitb6ddc2d502882da49800f55743c842242a62b6e2 (patch)
tree7c27ad722f6980a6f4192cd79e6137616646c9e0 /src
parent4f08302084476cee636b869e94c12d57db41d963 (diff)
downloadnoscript-b6ddc2d502882da49800f55743c842242a62b6e2.tar.gz
noscript-b6ddc2d502882da49800f55743c842242a62b6e2.tar.xz
noscript-b6ddc2d502882da49800f55743c842242a62b6e2.zip
Use fragments to reinsert and run previously blocked scripts.
Diffstat (limited to 'src')
-rw-r--r--src/content/staticNS.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/content/staticNS.js b/src/content/staticNS.js
index 82ef302..236abb4 100644
--- a/src/content/staticNS.js
+++ b/src/content/staticNS.js
@@ -86,11 +86,17 @@
debug("Fetched %o, readyState %s", policy, document.readyState); // DEV_ONLY
this.setup(policy);
if (this.canScript && blockedScripts.length && originalState === "loading") {
- log("Blocked some scripts on %s even though they are actually permitted by policy.", url)
+ log("Running suspended scripts which are permitted by %s policy.", url)
// something went wrong, e.g. with session restore.
for (let s of blockedScripts) {
- // reinsert the script
- s.replaceWith(s.cloneNode(true));
+ // reinsert the script:
+ // just s.cloneNode(true) doesn't work, the script wouldn't run,
+ // let's clone it the hard way...
+ try {
+ s.replaceWith(document.createRange().createContextualFragment(s.outerHTML));
+ } catch (e) {
+ error(e);
+ }
}
}
}