Last active
September 5, 2020 00:12
-
-
Save afonsoalban/682d837b9ff8bc3df083ce6171736f8e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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