您如何获取 youtube.com 上的 YouTube 视频的状态?

How do you get the state of a youtube video on youtube.com?

我正在尝试制作一个需要 YouTube 视频播放器状态的 chrome 扩展,并且 I'm aware of the existence of the API 但我尝试实际使用它的尝试没有结果。有人能指出我正确的方向吗?

您需要按照此处所述订阅 onStateChange 事件:https://developers.google.com/youtube/js_api_reference?csw=1#SubscribingEvents

同一页面上的 onStateChange 事件文档中描述了播放器的状态。

我一直在寻找的是您必须在此 div 上调用 API 方法,而文档中并未明确说明。

document.getElementById('movie_player');

此外,如果有人在这里结束,请继续阅读:

Insert code into the page context using a content script