32 lines
909 B
TypeScript
32 lines
909 B
TypeScript
|
import browser from 'webextension-polyfill';
|
||
|
|
||
|
import {Settings} from '../settings/settings.js';
|
||
|
import {updateBadge} from '../utilities/badge.js';
|
||
|
import {History} from '../utilities/history.js';
|
||
|
import {browserActionClicked} from './browser-action.js';
|
||
|
import {initializeContextMenus} from './context-menus.js';
|
||
|
|
||
|
browser.runtime.onStartup.addListener(async () => {
|
||
|
console.debug('Clearing history.');
|
||
|
await History.clear();
|
||
|
});
|
||
|
|
||
|
browser.browserAction.onClicked.addListener(browserActionClicked);
|
||
|
|
||
|
browser.runtime.onInstalled.addListener(async () => {
|
||
|
if (import.meta.env.DEV) {
|
||
|
await browser.runtime.openOptionsPage();
|
||
|
}
|
||
|
});
|
||
|
|
||
|
browser.runtime.onMessage.addListener(
|
||
|
async (request: Queue.Message<unknown>) => {
|
||
|
if (request.action === 'queue update badge') {
|
||
|
const settings = await Settings.fromSyncStorage();
|
||
|
await updateBadge(settings);
|
||
|
}
|
||
|
},
|
||
|
);
|
||
|
|
||
|
initializeContextMenus();
|