I want to create a Chrome extension that adds an option to the right click menu when the user right clicks a certain HTML element (for example a DIV with a known ID).
I would use this to add an option when the user right clicks a tweet on Twitter.com and that option would call a REST service.
Is this posible with a regultar Chrome extension?
Right-click your Google Chrome shortcut and click Properties. Note: You have to put a space between chrome.exe before the code. It's two hyphens, and not a long em dash (–). Click OK, launch Chrome, and you'll see the right-click context menu is back to normal.
Another easy way to enable the right-click menu on any webpage is by using a simple code snippet. For that, navigate to the target webpage and copy + paste the following line of code in the address bar: javascript:void(document. oncontextmenu=null); and hit Enter.
Use the chrome. contextMenus API to add items to Google Chrome's context menu. You can choose what types of objects your context menu additions apply to, such as images, hyperlinks, and pages.
Yes, these are called Context Menus. You can find the docs for those here: https://developer.chrome.com/extensions/contextMenus
Use chrome.contextMenus to add the option to right click
chrome.contextMenus.create({
title: 'test',
onclick: function(e){
console.log(e)
}
}, function(){})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With