1
0
mirror of https://github.com/XFox111/PasswordGeneratorExtension.git synced 2026-04-22 08:08:01 +03:00
Files
PasswordGeneratorExtension/entrypoints/background.ts
T
Eugene Fox 3ecb6c4a31 Major 4.0 (#380)
- Migrated to WXT
- Migrated to NPM
- Added Insert & copy action
- Added ESLint
2024-09-25 16:19:12 +03:00

25 lines
653 B
TypeScript

export default defineBackground(() => main());
async function main(): Promise<void>
{
await browser.contextMenus.removeAll();
browser.contextMenus.onClicked.addListener(() => browser.action.openPopup());
const showMenu: boolean = (await storage.getItem<boolean>("sync:ContextMenu", { fallback: true }))!;
updateMenus(showMenu);
storage.watch<boolean>("sync:ContextMenu", e => updateMenus(e!));
}
async function updateMenus(showMenus: boolean): Promise<void>
{
await browser.contextMenus.removeAll();
if (showMenus)
browser.contextMenus.create({
id: "password-generator",
title: i18n.t("manifest.name"),
contexts: ["all"],
});
}