29 lines
910 B
TypeScript
29 lines
910 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 {actionClicked, browserActionClicked} from './browser-action.js';
|
|
import {initializeContextMenus} from './context-menus.js';
|
|
|
|
browser.runtime.onStartup.addListener(async () => {
|
|
console.debug('Clearing history.');
|
|
await History.clear();
|
|
await updateBadge(await Settings.fromSyncStorage());
|
|
});
|
|
|
|
if (import.meta.env.VITE_BROWSER === 'chromium') {
|
|
browser.action.onClicked.addListener(actionClicked);
|
|
} else {
|
|
browser.browserAction.onClicked.addListener(browserActionClicked);
|
|
}
|
|
|
|
browser.runtime.onInstalled.addListener(async () => {
|
|
await initializeContextMenus();
|
|
await updateBadge(await Settings.fromSyncStorage());
|
|
});
|
|
|
|
if (import.meta.env.DEV) {
|
|
void browser.runtime.openOptionsPage();
|
|
}
|