From c71789753259958ec77e28639ef86033b1418ef4 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sun, 8 Oct 2017 23:28:00 -0700 Subject: [PATCH] Workaround for Firefox re-injecting content scripts when reloaded. --- src/main/Main.coffee | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/Main.coffee b/src/main/Main.coffee index 6841ead9a..f387df351 100644 --- a/src/main/Main.coffee +++ b/src/main/Main.coffee @@ -4,8 +4,12 @@ Main = return if d.body and not $ 'title', d.head # XXX dwb userscripts extension reloads scripts run at document-start when replaceState/pushState is called. - return if window['<%= meta.name %> antidup'] - window['<%= meta.name %> antidup'] = true + # XXX Firefox reinjects WebExtension content scripts when extension is updated / reloaded. + try + w = window + w = (w.wrappedJSObject or w) if $.platform is 'crx' + return if '<%= meta.name %> antidup' of w + w['<%= meta.name %> antidup'] = true if location.hostname is 'www.google.com' if location.pathname is '/recaptcha/api/noscript'