diff options
author | hackademix | 2018-07-22 16:50:24 +0200 |
---|---|---|
committer | hackademix | 2018-07-22 17:10:05 +0200 |
commit | 81b38512568982267b48f6df4ae15fb35ef1cc15 (patch) | |
tree | 22b0790750e2237a84c903a91d019f4d7b498771 /src/content/content.js | |
parent | e7fcd7670543a55e1eba5712c709231dd9f6a7fe (diff) | |
download | noscript-81b38512568982267b48f6df4ae15fb35ef1cc15.tar.gz noscript-81b38512568982267b48f6df4ae15fb35ef1cc15.tar.xz noscript-81b38512568982267b48f6df4ae15fb35ef1cc15.zip |
Fixed dynamic script injection failing sometimes with "No matching message handler" error.
Diffstat (limited to 'src/content/content.js')
-rw-r--r-- | src/content/content.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/content/content.js b/src/content/content.js index fa87ba8..daca1c3 100644 --- a/src/content/content.js +++ b/src/content/content.js @@ -85,8 +85,13 @@ async function init() { debug("canScript:", canScript); } catch (e) { debug("Error querying canScript", e); - // background script not initialized yet? - setTimeout(() => init(), 100); + if (document.readyState !== "complete" && + document.URL !== "about:blank" && + /Receiving end does not exist/.test(e.message)) { + window.location.reload(false); + } else { + setTimeout(() => init(), 100); + } return; } finally { queryingCanScript = false; |