Skip to content

Instantly share code, notes, and snippets.

@afonsoalban
Last active September 5, 2020 00:12
Show Gist options
  • Save afonsoalban/682d837b9ff8bc3df083ce6171736f8e to your computer and use it in GitHub Desktop.
Save afonsoalban/682d837b9ff8bc3df083ce6171736f8e to your computer and use it in GitHub Desktop.
const stopAllYouTubeVideos = () => {
const iframes = document.querySelectorAll("iframe")
Array.prototype.forEach.call(iframes, iframe => {
iframe.contentWindow.postMessage(
JSON.stringify({
event: "command",
func: "stopVideo",
}),
"*"
)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment