| @@ -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 | |||
| }); | |||
| }); | |||
| @@ -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(); | |||
| }; | |||
| @@ -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" | |||
| } | |||