diff --git a/background.js b/background.js index ad5dc1c..04cbabf 100644 --- a/background.js +++ b/background.js @@ -7,4 +7,22 @@ chrome.runtime.onInstalled.addListener(() => { ], actions: [ new chrome.declarativeContent.ShowPageAction() ] }]); }); +}); + +chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { + let icons = request.killingStickies ? { + "16": "images/ASK_on_16.png", + "32": "images/ASK_on_32.png", + "48": "images/ASK_on_48.png", + "128": "images/ASK_on_128.png" + } : { + "16": "images/ASK_off_16.png", + "32": "images/ASK_off_32.png", + "48": "images/ASK_off_48.png", + "128": "images/ASK_off_128.png" + }; + chrome.pageAction.setIcon({ + path: icons, + tabId: sender.tab.id + }); }); \ No newline at end of file diff --git a/contentScript.js b/contentScript.js index e95a50c..759d12e 100644 --- a/contentScript.js +++ b/contentScript.js @@ -33,8 +33,8 @@ function checkForShouldKillSticky(result) { return shouldKillSticky; } -function updateIcon(result) { - // TODO: code! +function updateIcon(shouldKillSticky) { + chrome.runtime.sendMessage({ "killingStickies" : shouldKillSticky }); } /******************/ @@ -45,7 +45,7 @@ function initialize() { chrome.storage.sync.get([ "matchingPatterns", "exclusionPatterns", "mode" ], (result) => { let shouldKillSticky = checkForShouldKillSticky(result); - updateIcon(result); + updateIcon(shouldKillSticky); window.onload = () => { if (shouldKillSticky) killSticky(); }; diff --git a/images/ASK128.png b/images/ASK128.png deleted file mode 100644 index dbdc49b..0000000 Binary files a/images/ASK128.png and /dev/null differ diff --git a/images/ASK16.png b/images/ASK16.png deleted file mode 100644 index ec99e57..0000000 Binary files a/images/ASK16.png and /dev/null differ diff --git a/images/ASK32.png b/images/ASK32.png deleted file mode 100644 index e930cfc..0000000 Binary files a/images/ASK32.png and /dev/null differ diff --git a/images/ASK48.png b/images/ASK48.png deleted file mode 100644 index 5d060e9..0000000 Binary files a/images/ASK48.png and /dev/null differ diff --git a/images/ASK_off_128.png b/images/ASK_off_128.png new file mode 100644 index 0000000..4f5ba25 Binary files /dev/null and b/images/ASK_off_128.png differ diff --git a/images/ASK_off_16.png b/images/ASK_off_16.png new file mode 100644 index 0000000..50b2657 Binary files /dev/null and b/images/ASK_off_16.png differ diff --git a/images/ASK_off_32.png b/images/ASK_off_32.png new file mode 100644 index 0000000..ef2e6a4 Binary files /dev/null and b/images/ASK_off_32.png differ diff --git a/images/ASK_off_48.png b/images/ASK_off_48.png new file mode 100644 index 0000000..b7cc096 Binary files /dev/null and b/images/ASK_off_48.png differ diff --git a/images/ASK_on_128.png b/images/ASK_on_128.png new file mode 100644 index 0000000..a64f1dd Binary files /dev/null and b/images/ASK_on_128.png differ diff --git a/images/ASK_on_16.png b/images/ASK_on_16.png new file mode 100644 index 0000000..38eb6cc Binary files /dev/null and b/images/ASK_on_16.png differ diff --git a/images/ASK_on_32.png b/images/ASK_on_32.png new file mode 100644 index 0000000..125bfa2 Binary files /dev/null and b/images/ASK_on_32.png differ diff --git a/images/ASK_on_48.png b/images/ASK_on_48.png new file mode 100644 index 0000000..a0e7dfb Binary files /dev/null and b/images/ASK_on_48.png differ diff --git a/manifest.json b/manifest.json index eab386c..dd4121a 100644 --- a/manifest.json +++ b/manifest.json @@ -20,17 +20,17 @@ "default_popup": "popup.html", "default_title": "AlwaysKillSticky - Click the icon to control sticky-killing on this site!", "default_icon": { - "16": "images/ASK16.png", - "32": "images/ASK32.png", - "48": "images/ASK48.png", - "128": "images/ASK128.png" + "16": "images/ASK_on_16.png", + "32": "images/ASK_on_32.png", + "48": "images/ASK_on_48.png", + "128": "images/ASK_on_128.png" } }, "icons": { - "16": "images/ASK16.png", - "32": "images/ASK32.png", - "48": "images/ASK48.png", - "128": "images/ASK128.png" + "16": "images/ASK_on_16.png", + "32": "images/ASK_on_32.png", + "48": "images/ASK_on_48.png", + "128": "images/ASK_on_128.png" }, "options_page": "options.html" } \ No newline at end of file