Making icon grayscale when extension is off

pull/18/head v1.0.2
Kevin Payravi 2023-02-06 05:00:44 -06:00
parent f51ff8836c
commit 0c4ae5afb8
5 changed files with 29 additions and 4 deletions

View File

@ -5,6 +5,26 @@ chrome.webNavigation.onBeforeNavigate.addListener(event => main(event, 'onBefore
chrome.webNavigation.onCreatedNavigationTarget.addListener(event => main(event, 'onCreatedNavigationTarget')); chrome.webNavigation.onCreatedNavigationTarget.addListener(event => main(event, 'onCreatedNavigationTarget'));
chrome.webNavigation.onCommitted.addListener(event => main(event, 'onCommitted')); chrome.webNavigation.onCommitted.addListener(event => main(event, 'onCommitted'));
// Listen for user turning extension on or off, to update icon
chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
if (msg.action === "updateIcon") {
const manifestVersion = chrome.runtime.getManifest().manifest_version;
if (msg.value === 'on') {
if (manifestVersion === 2) {
chrome.browserAction.setIcon({ path: "/images/logo-128.png" });
} else {
chrome.action.setIcon({ path: "/images/logo-128.png" });
}
} else {
if (manifestVersion === 2) {
chrome.browserAction.setIcon({ path: "/images/logo-off.png" });
} else {
chrome.action.setIcon({ path: "/images/logo-off.png" });
}
}
}
});
function redirectToBreezeWiki(storage, eventInfo, url) { function redirectToBreezeWiki(storage, eventInfo, url) {
function processRedirect(host) { function processRedirect(host) {
const subdomain = url.hostname.split(".")[0]; const subdomain = url.hostname.split(".")[0];

BIN
images/logo-off.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@ -1,6 +1,6 @@
{ {
"name": "Indie Wiki Buddy", "name": "Indie Wiki Buddy",
"version": "1.0.1", "version": "1.0.2",
"description": "Helping you discover quality independent wikis through alerts, redirects, and search filtering", "description": "Helping you discover quality independent wikis through alerts, redirects, and search filtering",
"permissions": [ "permissions": [
"storage", "storage",

View File

@ -1,6 +1,6 @@
{ {
"name": "Indie Wiki Buddy", "name": "Indie Wiki Buddy",
"version": "1.0.1", "version": "1.0.2",
"description": "Helping you discover quality independent wikis through alerts, redirects, and search filtering", "description": "Helping you discover quality independent wikis through alerts, redirects, and search filtering",
"permissions": [ "permissions": [
"storage", "storage",

View File

@ -305,6 +305,11 @@ function setPower(setting) {
powerImage.src = 'images/power-' + setting + '.png'; powerImage.src = 'images/power-' + setting + '.png';
var powerText = document.getElementById('powerText'); var powerText = document.getElementById('powerText');
powerText.textContent = 'Extension is ' + setting; powerText.textContent = 'Extension is ' + setting;
chrome.runtime.sendMessage({
action: 'updateIcon',
value: setting
});
} }
// Set notifications setting // Set notifications setting