

Including YouTube's iframe_api script effectively loads 2 scripts instead of one. There could be a reason for this on some untested edge cases or mobile platforms, but none have been found yet. Testing seems to indicate that this message is needed only once, so this custom script only sends it once. YouTube's API repeatedly postMessage's a listening event to the iframe every 250ms. With more events available for use, a poll loop is no longer required for state update. YouTube's API provides a limited amount of events for checking state updates.Īs such, things like load progress or current time would require a poll loop. This makes it very difficult (or impossible) to use their API inside of a userscript, because the event (and subsequently the YT object) will exist on the main window object and not inside the userscript. YouTube's API requires a function called onYouTubeIframeAPIReady to exist somewhere in a tag on the page.
#YOUTUBE IFRAME PLUS#
This custom API contains all of these events plus several extra state changing events for things such as volume, load progress, and playlist entry changing.Īdditionally, these events expose the previous value before the change.


It can also be used to learn how the basic postMessage system communicates between the main window and the embedded iframe. It can be directly integrated into an existing script or loaded as a stand-alone script. It contains a few extra features and has readable and modifiable source code. This library is a reworking of YouTube's default embedding iframe API.
