Fix old Chrome error: no 'browser_action' contextMenu type

This commit is contained in:
tophf 2015-04-22 20:13:21 +03:00
parent 05911f39ac
commit 30598dbbf0

View File

@ -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({ chrome.contextMenus.create({
id: "show-badge", title: chrome.i18n.getMessage("menuShowBadge"), id: "show-badge", title: chrome.i18n.getMessage("menuShowBadge"),
type: "checkbox", contexts: ["browser_action"], checked: prefs.getPref("show-badge") 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); prefs.setPref(info.menuItemId, info.checked);
} }
}); });
} catch(e) {console.error(e)}
function disableAllStylesToggle(newState) { function disableAllStylesToggle(newState) {
if (newState === undefined || newState === null) { if (newState === undefined || newState === null) {