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 { contextClicked, getContextMenus, 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(); } browser.contextMenus.onClicked.addListener(async (info, tab) => { const contextMenus = getContextMenus(); const contextMenuIds = new Set( contextMenus.map(({id}) => id ?? 'queue-unknown'), ); await contextClicked(contextMenuIds, info, tab); });