From 1def387cbc942eedd39d6b83b7f22a362b128396 Mon Sep 17 00:00:00 2001 From: Isaac Corbrey Date: Wed, 21 Jan 2026 09:47:14 -0500 Subject: [PATCH] firefox: Ensure context menus register on startup Fixes context menus not showing when the temp extension is reloaded in Firefox. --- extension/background/service-worker.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/extension/background/service-worker.js b/extension/background/service-worker.js index 708c7db..09e0ef4 100644 --- a/extension/background/service-worker.js +++ b/extension/background/service-worker.js @@ -75,6 +75,22 @@ chrome.runtime.onInstalled.addListener(async () => { updateBaseUrls("https://margin.at"); } + await ensureContextMenus(); + + if (hasSidebarAction) { + try { + await browser.sidebarAction.close(); + } catch { + /* ignore */ + } + } +}); + +chrome.runtime.onStartup.addListener(async () => { + await ensureContextMenus(); +}); + +async function ensureContextMenus() { await chrome.contextMenus.removeAll(); chrome.contextMenus.create({ @@ -100,15 +116,7 @@ chrome.runtime.onInstalled.addListener(async () => { title: "Open Margin Sidebar", contexts: ["page", "selection", "link"], }); - - if (hasSidebarAction) { - try { - await browser.sidebarAction.close(); - } catch { - /* ignore */ - } - } -}); +} chrome.action.onClicked.addListener(async () => { const stored = await chrome.storage.local.get(["apiUrl"]); -- 2.51.2