Quantcast
Channel: JavaScript injection in chrome extension - Stack Overflow
Viewing all articles
Browse latest Browse all 3

JavaScript injection in chrome extension

$
0
0

I'm new with 'chrome extension development', and I wanted to make a extension.
That extension has to inject code in a web page when the user clicks a button on the popup-page. I saw different subjects about that, but it doesn't seem to be possible to inject code that 'interacts' with the existing code of the web page. For example: a variable called test is made when the user opens a web page, I want to get that variable and use it in my code (for example: alert(test);). I tried several ways to achieve this, but it won't work. How can I do this? I tried:

chrome.tabs.executeScript(null,{code:"alert('test')"}); console.log("alert('test');");

This worked, but only for the popup page and so the variable 'test' didn't exist.


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images