Options page: edit the context items.
onclick event programming (background page)
- Use async runScript(function,...args) to evaluate a function/string
on the current page's content script.
- Use setEnabled and setVisible (boolean) to set the enabled/visible status.
content script
- The content script has a global variable called lastMenu
that is set to the last contextmenu mouse event.
- - lastMenu.target === element right clicked on.
Use info (context info) and tab (current tab) as menu item click arguments [1].
[1] info and tab
How to use contextMenus api (usable in background page): https://developer.chrome.com/extensions/contextMenus