summaryrefslogtreecommitdiff
path: root/src/content
diff options
context:
space:
mode:
authorhackademix2018-07-20 23:30:14 +0200
committerhackademix2018-07-20 23:30:14 +0200
commit570cf0456ce912aa4e331b103c5b1b4a3b5e7dc2 (patch)
tree9ccb07e3343a88a4623fbeba4b0afb4958cc9a1d /src/content
parent9382bbd9112b48676e3c308921e0285f632f9126 (diff)
downloadnoscript-570cf0456ce912aa4e331b103c5b1b4a3b5e7dc2.tar.gz
noscript-570cf0456ce912aa4e331b103c5b1b4a3b5e7dc2.tar.xz
noscript-570cf0456ce912aa4e331b103c5b1b4a3b5e7dc2.zip
Prevent multiple canScript content messages during the same page load.
Diffstat (limited to 'src/content')
-rw-r--r--src/content/content.js10
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();