1
Fork 0
webextension-template/source/background-scripts/initialize.ts

20 lines
525 B
TypeScript

import browser from 'webextension-polyfill';
async function browserActionClicked() {
await browser.runtime.openOptionsPage();
}
if (import.meta.env.VITE_BROWSER === 'chromium') {
browser.action.onClicked.addListener(browserActionClicked);
} else {
browser.browserAction.onClicked.addListener(browserActionClicked);
}
browser.runtime.onInstalled.addListener(async () => {
console.debug('WebExtension Template has been installed!');
if (import.meta.env.DEV) {
await browser.runtime.openOptionsPage();
}
});