From 65a3cc195b6e4345d5060e05ce76bb455a8f03d2 Mon Sep 17 00:00:00 2001 From: Jeremy Schomery Date: Mon, 20 Feb 2017 17:25:56 +0330 Subject: [PATCH] new context menu item to open styles manager from right click context menu over the toolbar button --- _locales/en/messages.json | 4 ++++ background.js | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 84f41001..fb8242d0 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -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." diff --git a/background.js b/background.js index a0b720f0..18865544 100644 --- a/background.js +++ b/background.js @@ -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) {