Avoid document rewriting for noscript meta refresh emulation in most cases.

This commit is contained in:
hackademix 2021-04-28 18:37:20 +02:00
parent 83b5d491af
commit 4e140b4b51
2 changed files with 12 additions and 14 deletions

View File

@ -2,12 +2,12 @@
"use strict";
function onScriptDisabled() {
onScriptDisabled = () => {};
let emulateNoscriptElement = () => {
onScriptDisabled = () => {}; // call me just once
debug("onScriptDisabled state", document.readyState);
if (ns.allows("noscript")) {
NoscriptElements.emulate(true);
} else {
let reportNoscriptElements = () => {
if (document.querySelector("noscript")) {
let request = {
id: "noscript-noscript",
@ -18,14 +18,12 @@ function onScriptDisabled() {
};
seen.record({policyType: "noscript", request, allowed: false});
}
}
};
debug("onScriptDisabled", document.readyState, new Error().stack); // DEV ONLY
if (document.readyState === "loading") {
window.addEventListener("DOMContentLoaded", emulateNoscriptElement, true);
return;
window.addEventListener("DOMContentLoaded", reportNoscriptElements, true);
} else {
emulateNoscriptElement();
reportNoscriptElements();
}
}
let eraser = {

@ -1 +1 @@
Subproject commit 1570208f7a04915063ce7776f61ad3bdca543c17
Subproject commit 4fb995d4d4683902906bafec460e505565e71c3b