From 462ca78e5c63682c06f96dade70d193b9e1b68c1 Mon Sep 17 00:00:00 2001 From: Einar Egilsson Date: Fri, 11 Sep 2015 12:08:45 +0000 Subject: Popup ready --- js/background.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'js/background.js') 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 -- cgit v1.2.3