From 817c1a7fb181a1bc0c5c975f0e685ff31dc78ebb Mon Sep 17 00:00:00 2001 From: Ray Lothian Date: Sun, 4 Nov 2018 10:56:34 +0100 Subject: [PATCH] change mode from right-click context menu; fixes #23 --- common.js | 26 ++++++++++++++++++++++++++ manifest.json | 3 ++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/common.js b/common.js index bbee2e4..05cf529 100644 --- a/common.js +++ b/common.js @@ -28,6 +28,28 @@ chrome.storage.local.get(prefs, ps => { color: prefs.color }); } + // context menu + chrome.contextMenus.create({ + id: 'blacklist', + title: 'Switch to "black-list" mode', + contexts: ['browser_action'], + type: 'radio', + checked: prefs.mode === 'blacklist' + }); + chrome.contextMenus.create({ + id: 'whitelist', + title: 'Switch to "white-list" mode', + contexts: ['browser_action'], + type: 'radio', + checked: prefs.mode === 'whitelist' + }); + chrome.contextMenus.create({ + id: 'custom', + title: 'Switch to "custom" mode', + contexts: ['browser_action'], + type: 'radio', + checked: prefs.mode === 'custom' + }); }); chrome.storage.onChanged.addListener(ps => { Object.keys(ps).forEach(key => prefs[key] = ps[key].newValue); @@ -256,6 +278,10 @@ var onCommitted = ({frameId, url, tabId}) => { ua.toolbar({tabId}); } }; +// context menu +chrome.contextMenus.onClicked.addListener(info => chrome.storage.local.set({ + mode: info.menuItemId +})); // FAQs & Feedback chrome.storage.local.get({ diff --git a/manifest.json b/manifest.json index 1510e0d..7f8cca9 100755 --- a/manifest.json +++ b/manifest.json @@ -12,7 +12,8 @@ "", "webNavigation", "webRequest", - "webRequestBlocking" + "webRequestBlocking", + "contextMenus" ], "icons": {