aboutsummaryrefslogtreecommitdiff
path: root/js/background.js
diff options
context:
space:
mode:
authorEinar Egilsson <einar@einaregilsson.com>2015-09-11 12:08:45 +0000
committerEinar Egilsson <einar@einaregilsson.com>2015-09-11 12:08:45 +0000
commit462ca78e5c63682c06f96dade70d193b9e1b68c1 (patch)
treeb28a1b279ea523efc021856cd878f41972a0125a /js/background.js
parent4c7ba5856ce3bf2976094e2c19d1f99054929360 (diff)
Popup ready
Diffstat (limited to 'js/background.js')
-rw-r--r--js/background.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/js/background.js b/js/background.js
index b6260d7..35b1243 100644
--- a/js/background.js
+++ b/js/background.js
@@ -23,3 +23,28 @@ var isFirefox = !!navigator.userAgent.match(/Firefox\//);
var ev = isFirefox ? chrome.webRequest.onBeforeSendHeaders : chrome.webRequest.onBeforeRequest;
ev.addListener(checkForRedirect, filter, ["blocking"]);
+
+var storage = chrome.storage.local; //TODO: Change to sync when Firefox supports it...
+
+
+//Icon updating code below
+
+function updateIcon() {
+ storage.get({disabled:false}, function(obj) {
+ chrome.browserAction.setIcon({
+ path: {
+ 19: obj.disabled ? "images/icon19disabled.png" : "images/icon19active.png",
+ 38: obj.disabled ? "images/icon38disabled.png" : "images/icon38active.png"
+ }
+ });
+ });
+}
+
+updateIcon();
+
+chrome.storage.onChanged.addListener(function(changes, namespace) {
+ if (changes.disabled) {
+ updateIcon();
+ }
+});
+ \ No newline at end of file