From b2ba3216ea5dbe6a74fdfa75611fce95c1481316 Mon Sep 17 00:00:00 2001 From: Einar Egilsson Date: Fri, 18 Sep 2015 15:42:21 +0000 Subject: Halfway to making Firefox compatible --- js/background.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'js/background.js') 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 { -- cgit v1.2.3