From 11b42fb9dcb9497d77d6c7a1f3c0207fd3d44ae7 Mon Sep 17 00:00:00 2001 From: Hygna Date: Thu, 13 Oct 2022 22:09:24 +0100 Subject: [PATCH] Fixed bug on chromium browsers where creating toggle redirects context menu would fail --- src/pages/background/background.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/pages/background/background.js b/src/pages/background/background.js index 5416c12..35deb8f 100644 --- a/src/pages/background/background.js +++ b/src/pages/background/background.js @@ -164,11 +164,19 @@ browser.contextMenus.create({ contexts: ["browser_action"], }) -browser.contextMenus.create({ - id: "toggleTab", - title: browser.i18n.getMessage("toggleTab"), - contexts: ["page", "tab"], -}) +try { + browser.contextMenus.create({ + id: "toggleTab", + title: browser.i18n.getMessage("toggleTab"), + contexts: ["page", "tab"], + }) +} catch { + browser.contextMenus.create({ + id: "toggleTab", + title: browser.i18n.getMessage("toggleTab"), + contexts: ["page"], + }) +} browser.contextMenus.create({ id: "redirectLink",