Skip to content

Commit 1b20328

Browse files
committed
Fix context menu disappearing after updating the browser
Initialize the context menu using the `runtime.onInstalled` event as recommended by MDN. This will trigger the creation of the menu option when the extension is first installed, when it is updated to a new version, and when the browser is updated to a new version.
1 parent 9a4b8b7 commit 1b20328

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/background.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import {
66

77
import { fetchImage, fetchQuery } from "./fetch";
88

9-
browser.contextMenus.create({
10-
id: "dokodemo-search",
11-
title: "Search Dokodemo Anilist",
12-
});
9+
browser.runtime.onInstalled.addListener(() =>
10+
browser.contextMenus.create({
11+
id: "dokodemo-search",
12+
title: "Search Dokodemo Anilist",
13+
}),
14+
);
1315

1416
browser.contextMenus.onClicked.addListener(async (info, tab) => {
1517
browser.permissions.request({ origins: ["https://*.anilist.co/*"] });

0 commit comments

Comments
 (0)