chore: setTitle and setIcon browser actions separate by browser

This commit is contained in:
Sebastian Velez
2023-01-23 13:26:15 -05:00
parent a0c3d35a95
commit de4baec10e
2 changed files with 16 additions and 10 deletions

View File

@@ -7,22 +7,23 @@ type ColorIconTypes = 'gray' | 'red' | 'white' | '';
* It changes the extension icon color.
*/
export default async function changeExtensionIcon(color?: ColorIconTypes): Promise<void> {
let path;
if (color) {
const path = `./graphics/wakatime-logo-38-${color}.png`;
await browser.action.setIcon({
path: path,
});
path = `./graphics/wakatime-logo-38-${color}.png`;
} else {
const { theme } = await browser.storage.sync.get({
theme: config.theme,
});
const path =
path =
theme === config.theme
? './graphics/wakatime-logo-38.png'
: './graphics/wakatime-logo-38-white.png';
await browser.action.setIcon({
path: path,
});
}
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (browser.browserAction) {
await browser.browserAction.setIcon({ path: path }); // Support for FF with manifest V2
} else {
await browser.action.setIcon({ path: path }); // Support for Chrome with manifest V3
}
}

View File

@@ -12,5 +12,10 @@ export default async function changeExtensionTooltip(text: string): Promise<void
text = `${config.name} - ${text}`;
}
await browser.action.setTitle({ title: text });
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (browser.browserAction) {
await browser.browserAction.setTitle({ title: text }); // Support for FF with manifest V2
} else {
await browser.action.setTitle({ title: text }); // Support for Chrome with manifest V3
}
}