Code works in Scratchpad but not in content script?

(Diracsbracket) #1

I am completely new to add-ons and scripting, so please forgive me this basic question.

I am trying to achieve the following: When I open my particular web page containing a radio stream (using jwplayer), I simply want to start the player automatically, which it does not do by default.

So, I thought about using a content script that runs after the load event of the page, and then issue the play command, like so:


The above command works when executed in the Scratchpad, but not when I test it in my very basic content script (I added a delay, but that does not help, no matter what the delay
value is):

console.log("TEST MY CONTENT SCRIPT");

window.addEventListener ("load", myMain, false);

function myTest() {

function myMain (evt) {
console.debug("TEST ON LOAD EVENT **************");
setTimeout(myTest, 6000); 

I can see the debug statements fine in the debugger console, but I can’t seem to access the jwplayer object the way it works in the Scratchpad.

What am I missing here?

Thanks for any help!

(Martin Giger) #2


(Diracsbracket) #3

Thanks a lot!

As per the info in the link, I instead used: