2022-03-05 13:10:45 +00:00
|
|
|
import browser from 'webextension-polyfill';
|
|
|
|
|
2022-03-16 10:20:29 +00:00
|
|
|
import {Settings} from '../settings/settings.js';
|
|
|
|
import {updateBadge} from '../utilities/badge.js';
|
2022-03-05 13:10:45 +00:00
|
|
|
import {History} from '../utilities/history.js';
|
2022-03-20 18:39:46 +00:00
|
|
|
import {actionClicked, browserActionClicked} from './browser-action.js';
|
2022-03-05 13:10:45 +00:00
|
|
|
import {initializeContextMenus} from './context-menus.js';
|
|
|
|
|
|
|
|
browser.runtime.onStartup.addListener(async () => {
|
|
|
|
console.debug('Clearing history.');
|
|
|
|
await History.clear();
|
2022-03-16 10:20:29 +00:00
|
|
|
await updateBadge(await Settings.fromSyncStorage());
|
2022-03-05 13:10:45 +00:00
|
|
|
});
|
|
|
|
|
2022-03-20 18:39:46 +00:00
|
|
|
if (import.meta.env.VITE_BROWSER === 'chromium') {
|
|
|
|
browser.action.onClicked.addListener(actionClicked);
|
|
|
|
} else {
|
|
|
|
browser.browserAction.onClicked.addListener(browserActionClicked);
|
|
|
|
}
|
2022-03-05 13:10:45 +00:00
|
|
|
|
|
|
|
browser.runtime.onInstalled.addListener(async () => {
|
2022-03-20 18:39:46 +00:00
|
|
|
await initializeContextMenus();
|
|
|
|
await updateBadge(await Settings.fromSyncStorage());
|
2022-03-05 13:10:45 +00:00
|
|
|
});
|
|
|
|
|
2022-03-20 18:39:46 +00:00
|
|
|
if (import.meta.env.DEV) {
|
|
|
|
void browser.runtime.openOptionsPage();
|
|
|
|
}
|