From 30598dbbf059ea22ecb9c0b3a1e755927ec4a148 Mon Sep 17 00:00:00 2001 From: tophf Date: Wed, 22 Apr 2015 20:13:21 +0300 Subject: [PATCH] Fix old Chrome error: no 'browser_action' contextMenu type --- background.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/background.js b/background.js index 351948e4..fe199f13 100644 --- a/background.js +++ b/background.js @@ -60,6 +60,9 @@ chrome.commands.onCommand.addListener(function(command) { } }); +// contextMenus API is present in ancient Chrome but it throws an exception +// upon encountering the unsupported parameter value "browser_action", so we have to catch it. +try { chrome.contextMenus.create({ id: "show-badge", title: chrome.i18n.getMessage("menuShowBadge"), type: "checkbox", contexts: ["browser_action"], checked: prefs.getPref("show-badge") @@ -75,6 +78,7 @@ chrome.contextMenus.onClicked.addListener(function(info, tab) { prefs.setPref(info.menuItemId, info.checked); } }); +} catch(e) {console.error(e)} function disableAllStylesToggle(newState) { if (newState === undefined || newState === null) {