mxch
mxch

Reputation: 865

Chrome extension: add option to right click menu when clicking certain HTML element

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?

Upvotes: 24

Views: 37526

Answers (2)

SWAPNIL KUWAR
SWAPNIL KUWAR

Reputation: 422

Use chrome.contextMenus to add the option to right click

chrome.contextMenus.create({
    title: 'test',
    onclick: function(e){
        console.log(e)
    }

}, function(){})

Upvotes: 5

tomdemuyt
tomdemuyt

Reputation: 4592

Yes, these are called Context Menus. You can find the docs for those here: https://developer.chrome.com/extensions/contextMenus

Upvotes: 21

Related Questions