manifest.json
{
"name": "Look-it-up",
"description": "Adds context menu item that looks up selected text on dictionary.com",
"version": "0.1",
"permissions": ["contextMenus"],
"background": {
"scripts": ["app.js"]
},
"manifest_version": 2
}
app.js
chrome.contextMenus.create({"title": "Look-it-up", "contexts":["selection"],"onclick": lookItUp});
function lookItUp(i, t){
var createProperties = {url: "http://www.dictionary.com/cgi-bin/dict.pl?term=" + encodeURIComponent(i.selectionText)};
chrome.tabs.create(createProperties);
}
Simple Google Chrome Extension that looks up selected text on dictionary.com. Obviously you should only select one word as dictionary.com will not define more than one. Same as Google-Translate-it, demonstrates getting selected text and processing it in a GET request.
Leave a comment