new context menu item to open styles manager from right click context menu over the toolbar button

This commit is contained in:
Jeremy Schomery 2017-02-20 17:25:56 +03:30
parent 7e3d745fc0
commit 65a3cc195b
2 changed files with 12 additions and 1 deletions

View File

@ -132,6 +132,10 @@
"message": "Restyle the web with Stylus, a user styles manager. Stylus lets you easily install themes and skins for many popular sites.",
"description": "Extension description"
},
"openStylesManager": {
"message": "Open styles manager",
"description": "Label for the style maanger opener in the browser action context menu."
},
"disableAllStyles": {
"message": "Turn all styles off",
"description": "Label for the checkbox that turns all enabled styles off."

View File

@ -115,15 +115,22 @@ runTryCatch(function() {
id: "disableAll", title: chrome.i18n.getMessage("disableAllStyles"),
type: "checkbox", contexts: ["browser_action"], checked: prefs.get("disableAll")
}, function() { var clearError = chrome.runtime.lastError });
chrome.contextMenus.create({
id: "open-manager", title: chrome.i18n.getMessage("openStylesManager"),
type: "normal", contexts: ["browser_action"]
}, function() {var clearError = chrome.runtime.lastError});
});
chrome.contextMenus.onClicked.addListener(function(info, tab) {
if (info.menuItemId == "disableAll") {
disableAllStylesToggle(info.checked);
}
else {
else if (info.menuItemId === 'show-badge') {
prefs.set(info.menuItemId, info.checked);
}
else if (info.menuItemId === 'open-manager') {
openURL({url: chrome.extension.getURL("manage.html")});
}
});
function disableAllStylesToggle(newState) {