Chrome-extension: Append functions to right click menu

I made simple extenstion using the contextMenu API – link
Hope this works well as an example.

manifest.json –

{
  "manifest_version": 2,
  ...
  ...
  "permissions": [
      "contextMenus", 
      "tabs"],
  ...
  ...
  "background": {
    "page": "background.html",
    "scripts": ["main.js"]
  }
}

main.js –

 searchUrbanDict = function(word){
    var query = word.selectionText;
    chrome.tabs.create({url: "http://www.urbandictionary.com/define.php?term=" + query});
 };

chrome.contextMenus.create({
 title: "Search in UrbanDictionary",
 contexts:["selection"],  // ContextType
 onclick: searchUrbanDict // A callback function
});

For more information on different context types – link

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)