diff options
author | Einar Egilsson <einar@einaregilsson.com> | 2015-09-23 12:07:12 +0000 |
---|---|---|
committer | Einar Egilsson <einar@einaregilsson.com> | 2015-09-23 12:07:12 +0000 |
commit | d8cf1e9fb53dc262f6deb8633c5ecc43240c82ef (patch) | |
tree | 30aaea34c82072828992da483e142a7217b2f6d8 /js/background.js | |
parent | 354b7325e453c3fa259ecd9a07b4634d09cf5afe (diff) |
Mostly working, dead object problems
Diffstat (limited to 'js/background.js')
-rw-r--r-- | js/background.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/js/background.js b/js/background.js index 81bf405..16c052f 100644 --- a/js/background.js +++ b/js/background.js @@ -18,6 +18,10 @@ if (typeof chrome == 'undefined') { firefoxShim.setLogger(log); chrome = firefoxShim.chrome; Redirect = firefoxShim.Redirect; + exports.onUnload = function (reason) { + redirectEvent.removeListener(checkRedirects); + chrome.storage.onChanged.removeListener(monitorChanges); + }; } //Hopefully Firefox will fix this at some point and we can just use onBeforeRequest everywhere... var redirectEvent = isFirefox ? chrome.webRequest.onBeforeSendHeaders : chrome.webRequest.onBeforeRequest; @@ -100,7 +104,7 @@ function checkRedirects(details) { //Monitor changes in data, and setup everything again. //This could probably be optimized to not do everything on every change //but why bother? -chrome.storage.onChanged.addListener(function(changes, namespace) { +function monitorChanges(changes, namespace) { if (changes.disabled) { updateIcon(); @@ -117,7 +121,8 @@ chrome.storage.onChanged.addListener(function(changes, namespace) { log('Redirects have changed, setting up listener again'); setUpRedirectListener(); } -}); +} +chrome.storage.onChanged.addListener(monitorChanges); //Creates a filter to pass to the listener so we don't have to run through //all the redirects for all the request types we don't have any redirects for anyway. |