UserIsCorrupt UserIsCorrupt - 9 months ago 62
Javascript Question

Context menus in Chrome extensions

I've searched and searched and searched for a solution to this but every source I come across seems to assume I already have profound knowledge of Chrome extensions, even Google's help pages

I know the very basics of Chrome extensions and I made one with some basic content scripts. However, now I'm looking to make one that involves context menus.

Let's say when you highlight words and right-click them, you see the option

Search '<highlighted words>' on Google
and when clicked, it opens<highlighted words>
in a new tab. I know this exists in Chrome and I'm sure there have been a billion extensions replicating it, but this is only an example for me to build off of.

How can I do this?


Script should look like this:

function getword(info,tab) {
  console.log("Word " + info.selectionText + " was clicked.");
    url: "" + info.selectionText,
  title: "Search: %s", 
  onclick: getword,

And manifest.json:

    "name": "App name",
    "version": "1.0",
    "manifest_version": 2,
    "description": "Your description",
    "permissions": [
    "background": { 
      "scripts": ["script.js"]

Here you have how to load extension: