diff options
author | hackademix | 2018-07-20 23:30:14 +0200 |
---|---|---|
committer | hackademix | 2018-07-20 23:30:14 +0200 |
commit | 570cf0456ce912aa4e331b103c5b1b4a3b5e7dc2 (patch) | |
tree | 9ccb07e3343a88a4623fbeba4b0afb4958cc9a1d /src | |
parent | 9382bbd9112b48676e3c308921e0285f632f9126 (diff) | |
download | noscript-570cf0456ce912aa4e331b103c5b1b4a3b5e7dc2.tar.gz noscript-570cf0456ce912aa4e331b103c5b1b4a3b5e7dc2.tar.xz noscript-570cf0456ce912aa4e331b103c5b1b4a3b5e7dc2.zip |
Prevent multiple canScript content messages during the same page load.
Diffstat (limited to 'src')
-rw-r--r-- | src/content/content.js | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/content/content.js b/src/content/content.js index a74aa0c..fa87ba8 100644 --- a/src/content/content.js +++ b/src/content/content.js @@ -72,16 +72,24 @@ let notifyPage = () => { return false; } - +var queryingCanScript = false; async function init() { + if (queryingCanScript) return; + queryingCanScript = true; + debug(`NoScript init() called in document %s, scripting=%s, content type %s readyState %s`, + document.URL, canScript, document.contentType, document.readyState); + try { canScript = await browser.runtime.sendMessage({type: "canScript"}); init = () => {}; debug("canScript:", canScript); } catch (e) { + debug("Error querying canScript", e); // background script not initialized yet? setTimeout(() => init(), 100); return; + } finally { + queryingCanScript = false; } if (!canScript) onScriptDisabled(); |