2

I'm trying to get a chrome extension to add text to an textbox, for example in the facebook chat, via right clicking and clicking in the context menu.

Currently the option in the context menu, yet nothing happens when i click it.

My manifest.json looks like this:

{
    "manifest_version": 2,
    "name": "Name here",
    "version" : "0.0.0.1",
    "permissions": ["contextMenus"],
    "browser_action":
        {
        "default_icon" : "icon.png",
        "default_title" : "Title here!"
        },
    "background": 
        {
        "scripts": ["background.js"]
        }    
}

And my background.js looks like this:

    function insert(text) {
document.getElementById('textbox').innerHTML = "textoutput";
}

chrome.contextMenus.create({
title: "inserttext", onclick: insert});

Where does everything go wrong?

MrBach
  • 21
  • 3
  • If you found any workaround please let us know by answering your own question with sample scripts :) – Jalal May 07 '15 at 07:40

1 Answers1

1

Your question is answered here

To summarize: as a background script, document refers to the background page.

Timores
  • 14,439
  • 3
  • 46
  • 46