Browser Extension, Google Chrome, Google-Translate-It, Javascript

Google-Translate-it A Google Chrome Extension in Five Elegant Lines Of Javascript


  "name": "Google-Translate-it",
  "description": "Adds context menu that, when text is selected, opens up a new tab with the google translation tool.",
  "version": "0.1",
  "permissions": ["contextMenus"],
  "background": {
    "scripts": ["app.js"]
  "manifest_version": 2


chrome.contextMenus.create({"title": "Google-Translate-it", "contexts":["selection"],"onclick": translateIt});
function translateIt(i, t){
	var createProperties = {url: "" + encodeURIComponent(i.selectionText)};

Yeah, I know, I could have used an anonymous function which would have made it four lines of javascript. The extra line is there for beauty.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s