chore: setTitle and setIcon browser actions separate by browser
This commit is contained in:
@@ -7,22 +7,23 @@ type ColorIconTypes = 'gray' | 'red' | 'white' | '';
|
|||||||
* It changes the extension icon color.
|
* It changes the extension icon color.
|
||||||
*/
|
*/
|
||||||
export default async function changeExtensionIcon(color?: ColorIconTypes): Promise<void> {
|
export default async function changeExtensionIcon(color?: ColorIconTypes): Promise<void> {
|
||||||
|
let path;
|
||||||
if (color) {
|
if (color) {
|
||||||
const path = `./graphics/wakatime-logo-38-${color}.png`;
|
path = `./graphics/wakatime-logo-38-${color}.png`;
|
||||||
|
|
||||||
await browser.action.setIcon({
|
|
||||||
path: path,
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
const { theme } = await browser.storage.sync.get({
|
const { theme } = await browser.storage.sync.get({
|
||||||
theme: config.theme,
|
theme: config.theme,
|
||||||
});
|
});
|
||||||
const path =
|
path =
|
||||||
theme === config.theme
|
theme === config.theme
|
||||||
? './graphics/wakatime-logo-38.png'
|
? './graphics/wakatime-logo-38.png'
|
||||||
: './graphics/wakatime-logo-38-white.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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,5 +12,10 @@ export default async function changeExtensionTooltip(text: string): Promise<void
|
|||||||
text = `${config.name} - ${text}`;
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user