This commit is contained in:
GrzegorzZajac000 2024-10-03 13:09:40 +02:00
parent b46588b853
commit 2ae6707982
3 changed files with 14 additions and 6 deletions

View File

@ -18,7 +18,7 @@
//
const browser = require('webextension-polyfill');
const { onConnect, onCommand, onContextMenuClick, onInstalled, getBrowserInfo, onMessage, onStartup, browserAction, createContextMenus, dummyGetLocalStorage } = require('./functions');
const { onConnect, onCommand, onContextMenuClick, onInstalled, getBrowserInfo, onMessage, onStartup, browserAction, createContextMenus, dummyGetLocalStorage, setIcon } = require('./functions');
const { onTabRemoved, onTabUpdated, onTabActivated } = require('./tabs');
const browserInfo = getBrowserInfo();
@ -47,3 +47,5 @@ browser.tabs.onActivated.addListener(onTabActivated);
setInterval(() => {
return dummyGetLocalStorage();
}, 25 * 1000);
setIcon(null, false, false);

View File

@ -49,16 +49,21 @@ const getIconObj = async (tabID, isActive) => {
iconFileName = isActive ? typeFilename : `${typeFilename}gray`;
}
return {
const iconObj = {
path: {
16: browser.runtime.getURL(`images/icons/icon16${iconFileName}.png`),
32: browser.runtime.getURL(`images/icons/icon32${iconFileName}.png`),
48: browser.runtime.getURL(`images/icons/icon48${iconFileName}.png`),
96: browser.runtime.getURL(`images/icons/icon96${iconFileName}.png`),
128: browser.runtime.getURL(`images/icons/icon128${iconFileName}.png`)
},
tabId: tabID
}
};
if (tabID) {
iconObj.tabId = tabID;
}
return iconObj;
};
const setIcon = async (tabID, isActive = true, changeTitle = false) => {

View File

@ -20,7 +20,7 @@
const SlimSelect = require('slim-select');
const browser = require('webextension-polyfill');
const { loadFromLocalStorage, saveToLocalStorage } = require('../../localStorage');
const checkTabCS = require('../../background/functions/checkTabCS');
const setIcon = require('../../background/functions/setIcon');
const setIconSelect = async () => {
const { extIcon } = await loadFromLocalStorage(['extIcon']);
@ -57,7 +57,8 @@ const setIconSelect = async () => {
const tabID = await browser.tabs.query({ active: true, currentWindow: true }).then(tabs => tabs[0].id);
await saveToLocalStorage({ extIcon: parseInt(item[0].value, 10) });
await checkTabCS(tabID);
await setIcon(null, false, false);
await setIcon(tabID, false, false);
}
}
});