change mode from right-click context menu; fixes #23

This commit is contained in:
Ray Lothian 2018-11-04 10:56:34 +01:00
parent 62d3eefd67
commit 817c1a7fb1
2 changed files with 28 additions and 1 deletions

View file

@ -28,6 +28,28 @@ chrome.storage.local.get(prefs, ps => {
color: prefs.color 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 => { chrome.storage.onChanged.addListener(ps => {
Object.keys(ps).forEach(key => prefs[key] = ps[key].newValue); Object.keys(ps).forEach(key => prefs[key] = ps[key].newValue);
@ -256,6 +278,10 @@ var onCommitted = ({frameId, url, tabId}) => {
ua.toolbar({tabId}); ua.toolbar({tabId});
} }
}; };
// context menu
chrome.contextMenus.onClicked.addListener(info => chrome.storage.local.set({
mode: info.menuItemId
}));
// FAQs & Feedback // FAQs & Feedback
chrome.storage.local.get({ chrome.storage.local.get({

View file

@ -12,7 +12,8 @@
"<all_urls>", "<all_urls>",
"webNavigation", "webNavigation",
"webRequest", "webRequest",
"webRequestBlocking" "webRequestBlocking",
"contextMenus"
], ],
"icons": { "icons": {