How to add a custom item into the chrome context menu?
Is there any API to be used to add a custom item into the chrome context menu?
For example:
Now, I wanna add a "send to ..." item to context menu(right click), wh开发者_如何转开发en it is clicked the contents selected in the webpage will be sent to someone.
I searched the chrome APIS and found that chrome.experimental.contextMenu is competent for my requirement, however it is experimental API so something like "path_to_chrome.exe --enable-experimental-extension-apis" will be added.
Any other solutions?
Now (for long time) you have an option.
Add this permission to your manifest.json file
"permissions": ["contextMenus"]
Then, something like that will do the trick:
chrome.contextMenus.create({ 'title' : 'Open this select text %s', 'contexts' : ['selection'], 'onclick' : function(info, tab) { console.log('Selected link: ' + info.selectionText); } });
Good luck.
Using contextMenu
is the one and only way (outside of hacking on the Chromium source), but the API should be graduating from experimental
when Google Chrome 6 gets released to the stable channel.
精彩评论