queue/source/background-scripts/initialize.ts

29 lines
910 B
TypeScript
Raw Normal View History

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';
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
});
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 () => {
await initializeContextMenus();
await updateBadge(await Settings.fromSyncStorage());
2022-03-05 13:10:45 +00:00
});
if (import.meta.env.DEV) {
void browser.runtime.openOptionsPage();
}