Skip to content

Instantly share code, notes, and snippets.

@markbattistella
Created November 11, 2023 23:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markbattistella/c7da06c134bfb937574323c8066a33df to your computer and use it in GitHub Desktop.
Save markbattistella/c7da06c134bfb937574323c8066a33df to your computer and use it in GitHub Desktop.
Open Youtube in new window
javascript:(function(){
if(window.location.host === 'www.youtube.com' && window.location.pathname === '/watch'){
var videoId = window.location.search.split('v=')[1];
var ampersandPosition = videoId.indexOf('&');
if(ampersandPosition != -1) {
videoId = videoId.substring(0, ampersandPosition);
}
var embedUrl = 'https://www.youtube.com/embed/' + videoId;
window.open(embedUrl, 'youtube', 'width=1920,height=1080');
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment