diff options
Diffstat (limited to 'js/background.js')
-rw-r--r-- | js/background.js | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/js/background.js b/js/background.js index c86a4e2..4b2d1cf 100644 --- a/js/background.js +++ b/js/background.js @@ -3,9 +3,15 @@ //as well as monitoring changes in the redirects and the disabled status and reacting to them. //TODO: Better browser detection... -var isFirefox = !!navigator.userAgent.match(/Firefox\//); -var storage = chrome.storage.local; //TODO: Change to sync when Firefox supports it... - +var isFirefox = false; + +if (!this.chrome) { + isFirefox = true; + var firefoxShim = require('./firefox/background-shim'); + chrome = firefoxShim.chrome; + Redirect = firefoxShim.Redirect; + console.log(this.Redirect) +} //Hopefully Firefox will fix this at some point and we can just use onBeforeRequest everywhere... var redirectEvent = isFirefox ? chrome.webRequest.onBeforeSendHeaders : chrome.webRequest.onBeforeRequest; @@ -173,7 +179,7 @@ function setUpRedirectListener() { redirectEvent.removeListener(checkRedirects); //Unsubscribe first, in case there are changes... - storage.get({redirects:'firstrun'}, function(obj) { + chrome.storage.local.get({redirects:'firstrun'}, function(obj) { var redirects = obj.redirects; if (redirects === 'firstrun') { @@ -195,7 +201,7 @@ function setUpRedirectListener() { } function updateIcon() { - storage.get({disabled:false}, function(obj) { + chrome.storage.local.get({disabled:false}, function(obj) { if (obj.disabled) { setIcon("images/icon19disabled.png", "images/icon38disabled.png"); } else { @@ -206,7 +212,7 @@ function updateIcon() { //First time setup updateIcon(); -storage.get({disabled:false}, function(obj) { +chrome.storage.local.get({disabled:false}, function(obj) { if (!obj.disabled) { setUpRedirectListener(); } else { |