Created
July 25, 2023 20:10
-
-
Save jonschr/9120118eb3097b3d413f9019d04b7ae6 to your computer and use it in GitHub Desktop.
Force oembed to not show related videos
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
// Get all the iframes present on the page | |
const iframes = document.querySelectorAll('iframe'); | |
// Loop through each iframe to check if it contains "youtube.com" in its src | |
for (const iframe of iframes) { | |
const src = iframe.getAttribute('src'); | |
if (src.includes('youtube.com')) { | |
// Append ?rel=0 to the existing src | |
const modifiedSrc = src + '?rel=0'; | |
iframe.setAttribute('src', modifiedSrc); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment