I am making a test extension but the item is not appearing in context menu. What is wrong here?
My manifest file
{
"name": "Colour",
"version": "1.0.1",
"description": "Colour the background on right clicking image.",
"offline_enabled": true,
"permissions" : [
"contextMenus",
"tabs",
"http://*/*",
"https://*/*"
],
"background_page":"background.html"
}
My background.html contains this script
function getColour(info, tab){
document.body.style.background="#456";
}
chrome.contextMenus.create({
"type":"normal",
"title":"Colour page",
"contexts":["image"],
"onclick":getColour()
});
A reference to the
getColourfunction has to be passed. It should not be invoked:Previously, your code would work in this way:
getColour()– CallsgetColour.returnstatement in the function, so it returnsundefined.chrome.contextMenu.create({ ... "onclick": undefined });– No event handler!