aboutsummaryrefslogtreecommitdiff
path: root/js/background.js
diff options
context:
space:
mode:
authorEinar Egilsson <einar@einaregilsson.com>2015-09-18 15:42:21 +0000
committerEinar Egilsson <einar@einaregilsson.com>2015-09-18 15:42:21 +0000
commitb2ba3216ea5dbe6a74fdfa75611fce95c1481316 (patch)
tree0ed80d05edc5497d64455197a04fabec7aa8d69d /js/background.js
parent862d738c79dc6f8188d3f9fefd46c01179041710 (diff)
Halfway to making Firefox compatible
Diffstat (limited to 'js/background.js')
-rw-r--r--js/background.js18
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 {