diff options
author | hackademix | 2018-11-17 22:56:30 +0100 |
---|---|---|
committer | hackademix | 2018-11-17 22:56:30 +0100 |
commit | 1dcbc7ebfcd82667240bfad44d5be158757350e0 (patch) | |
tree | af2d740d20fc99befb3ba20ff1ba50b1de22f29d /src/content | |
parent | 24f738337be6f6328ffb9464dcd07fcbeab5e9ab (diff) | |
download | noscript-1dcbc7ebfcd82667240bfad44d5be158757350e0.tar.gz noscript-1dcbc7ebfcd82667240bfad44d5be158757350e0.tar.xz noscript-1dcbc7ebfcd82667240bfad44d5be158757350e0.zip |
Fixed meta refresh inside <NOSCRIPT> emulation breaking Firefox's built-in refresh blocking.
Diffstat (limited to 'src/content')
-rw-r--r-- | src/content/onScriptDisabled.js | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/src/content/onScriptDisabled.js b/src/content/onScriptDisabled.js index 3606ede..c0d5899 100644 --- a/src/content/onScriptDisabled.js +++ b/src/content/onScriptDisabled.js @@ -1,31 +1,26 @@ function onScriptDisabled() { + let refresh = false; for (let noscript of document.querySelectorAll("noscript")) { // force show NOSCRIPT elements content let replacement = createHTMLElement("span"); replacement.innerHTML = noscript.innerHTML; noscript.parentNode.replaceChild(replacement, noscript); // emulate meta-refresh - let meta = replacement.querySelector('meta[http-equiv="refresh"]'); + let meta = replacement.querySelector('meta[http-equiv="refresh"]'); if (meta) { - let content = meta.getAttribute("content"); - if (content) { - let [secs, url] = content.split(/\s*;\s*url\s*=\s*/i); - let urlObj; - if (url) { - try { - urlObj = new URL(url.replace(/^(['"]?)(.+?)\1$/, '$2'), document.URL); - if (!/^https?:/.test(urlObj.protocol)) { - continue; - } - } catch (e) { - continue; - } - window.setTimeout(() => location.href = urlObj, (parseInt(secs) || 0) * 1000); - } - } + refresh = true; + document.head.appendChild(meta); } } - + if (refresh) { + let html = document.documentElement.outerHTML; + window.addEventListener("load", e => { + let document = window.wrappedJSObject.document; + document.open(); + document.write(html); + document.close(); + }); + } { let eraser = { tapped: null, |