Chrome extension - change the right-click browser action menu

I am wondering if I can change the right menu of the browser menu? I want to add the "Exit" option.

+6
source share
3 answers

No, you cannot do this, you will need to insert it into the browser popup.

+1
source

In the context of Chrome, it says:

The value must be one of: [all, page, frame, selection, link, editable, image, video, audio, launcher, browser_action, page_action]

Therefore use

 chrome.contextMenus.create({ "title": "Logout", "contexts": ["browser_action"], "onclick": logout }); 

Where logout() is a function that will be called when clicking on it. (And allow permission to "contextMenus" in the manifest.)

Edit: A little warning, if you have an Event Page , using the onclick attribute is not and you should add a chrome.contextMenus.onClicked handler.

+13
source

hum, if I understand ... you want to add an item to the menu after a right click?

You can do it:

 chrome.contextMenus.create({ "title" : "You menu Name", "type" : "normal", "contexts" : ["link","video","audio"], //the context which item appear "onclick" : shorten() // The function call on click }); 

And your manifest:

Add "contextMenus" to the "permissions" array.

Additional information: here

-3
source

Source: https://habr.com/ru/post/911617/


All Articles