Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3638

Use a content script to access the page context variables and functions

$
0
0

I'm learning how to create Chrome extensions. I just started developing one to catch YouTube events. I want to use it with YouTube flash player (later I will try to make it compatible with HTML5).

manifest.json:

{"name": "MyExtension","version": "1.0","description": "Gotta catch Youtube events!","permissions": ["tabs", "http://*/*"],"content_scripts" : [{"matches" : [ "www.youtube.com/*"],"js" : ["myScript.js"]    }]}

myScript.js:

function state() { console.log("State Changed!"); }var player = document.getElementById("movie_player");player.addEventListener("onStateChange", "state");console.log("Started!");

The problem is that the console gives me the "Started!", but there is no "State Changed!" when I play/pause YouTube videos.

When this code is put in the console, it worked. What am I doing wrong?


Viewing all articles
Browse latest Browse all 3638

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>