2022-03-05 13:10:45 +00:00
|
|
|
import browser from 'webextension-polyfill';
|
|
|
|
|
|
|
|
import {Settings} from '../settings/settings.js';
|
|
|
|
|
|
|
|
export async function updateBadge(settings: Settings): Promise<void> {
|
2022-03-20 18:23:59 +00:00
|
|
|
let action: browser.Action.Static = browser.browserAction;
|
|
|
|
if (import.meta.env.VITE_BROWSER === 'chromium') {
|
|
|
|
action = browser.action;
|
|
|
|
}
|
|
|
|
|
2022-03-05 13:10:45 +00:00
|
|
|
const queueLength = settings.queue.length.toString();
|
2022-03-20 18:23:59 +00:00
|
|
|
await action.setBadgeText({
|
|
|
|
text: queueLength === '0' ? '' : queueLength,
|
|
|
|
});
|
|
|
|
|
|
|
|
await action.setBadgeBackgroundColor({
|
|
|
|
color: '#2a2041',
|
2022-03-05 13:10:45 +00:00
|
|
|
});
|
|
|
|
|
2022-03-20 18:23:59 +00:00
|
|
|
if (import.meta.env.VITE_BROWSER === 'firefox') {
|
|
|
|
action.setBadgeTextColor({color: '#f2efff'});
|
|
|
|
}
|
2022-03-05 13:10:45 +00:00
|
|
|
}
|