Merge pull request #104 from tophf/bugfix2

Fix old Chrome error: no 'browser_action' contextMenu type
This commit is contained in:
Jason Barnabe 2015-04-22 14:01:09 -05:00
commit cb9f8ffc27

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) {