Reputation: 414
I'm trying to create a Chrome extension that a user might want to frequently enable/disable. To facilitate this, I'd like to add a checkbox to the context menu that basically says "extension enabled". When a page loads, it would check to see if there was a check by the context menu item. I have created the menu item, and it stays persistent throughout page loads, but I don't know how to read its value. Can anyone help me out?
Here is the code that I'm using to add the checkbox to the context menu.
var checkbox1 = chrome.contextMenus.create({
"title": "Enable",
"type": "checkbox",
"onclick":enableAutofilter
});
Upvotes: 1
Views: 332
Reputation: 115950
From the Chrome docs, it appears that there is no way to read information about a context menu item. There are create
, update
, and remove
functions, but no read
function (so it has only three of the CRUD operators). This means that you'll have to maintain the on/off state elsewhere, e.g., on your background page and/or in localStorage, and toggle it when you fire enableAutoFilter
.
Upvotes: 2