I want to get a reference for chrome.contextMenus.create title property in onClick function.
For example:
chrome.contextMenus.create({"title": "sometitle", "contexts":["selection"], "onclick": searchSelection});
function searchSelection(info, tab){
var query = "<i want title (sometitle) here>"+info.selectionText;
var url = "http://www.google.com/search?q="+query;
chrome.tabs.create({url: url});
}
I searched, but found no option doing this.
+1 Question: is there a way to inline edit contextMenu item? Or append an editable input field after CM element? I think no, but worth for a question 🙂
There’s no existing API method to retrieve information about a given menu item, since this information is rarely needed, and already available to the extension’s developer.
Here’s a general-purpose function to achieve the result:
And no, there is no way to add an inline-editable menu item (the only available options are mentioned in the documentation,
chrome.contextMenus.create).