Skip to content
Permalink
Browse files

Fixed meta refresh inside <NOSCRIPT> emulation breaking Firefox's bui…

…lt-in refresh blocking.
  • Loading branch information...
hackademix committed Nov 17, 2018
1 parent 24f7383 commit 1dcbc7ebfcd82667240bfad44d5be158757350e0
Showing with 13 additions and 18 deletions.
  1. +13 −18 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,

0 comments on commit 1dcbc7e

Please sign in to comment.
You can’t perform that action at this time.