diff --git a/src/content/syncFetchPolicy.js b/src/content/syncFetchPolicy.js index e98462d..c8d5435 100644 --- a/src/content/syncFetchPolicy.js +++ b/src/content/syncFetchPolicy.js @@ -19,6 +19,7 @@ // Mozilla has already parsed the element, we must take extra steps... let softReloading = true; + let suppressedScripts = 0; debug("Early parsing: preemptively suppressing events and script execution."); try { @@ -57,7 +58,7 @@ } let {readyState} = document; - debug("Readystate: %s, canScript: ", readyState, ns.canScript); + debug("Readystate: %s, %suppressedScripts %s, canScript = %s", readyState, suppressedScripts, ns.canScript); if (!ns.canScript) { for (let node of document.querySelectorAll("*")) { let evAttrs = [...node.attributes].filter(a => a.name.toLowerCase().startsWith("on")); @@ -71,6 +72,13 @@ return; } + if (suppressedScripts === 0 && readyState === "loading") { + // we don't care reloading, if no script has been suppressed + // and no readyState change has been fired yet + softReloading = false; + return; + } + let softReload = ev => { let html = document.documentElement.outerHTML; try { @@ -143,7 +151,8 @@ debug(e.type, e.target, softReloading); // DEV_ONLY if (softReloading) { e.preventDefault(); - debug("Blocked early script", e.target); + ++suppressedScripts; + debug(`Suppressed early script #${suppressedScripts}`, e.target); } else { removeEventListener(e.type, scriptSuppressor); }