Skip to content

Instantly share code, notes, and snippets.

@ishubham-k
Created April 21, 2019 05:25
Show Gist options
  • Save ishubham-k/4c47f8a194adfda8f636b96e4125477d to your computer and use it in GitHub Desktop.
Save ishubham-k/4c47f8a194adfda8f636b96e4125477d to your computer and use it in GitHub Desktop.
Youtube To Embed userscript. Use with plugins like tampermonkey to automatically redirect to youtube embed for distraction free view.
// ==UserScript==
// @name Youtube Redirect To Embed
// @namespace http://tampermonkey.net/
// @version 0.1
// @description youtube to embed
// @author Shubham Kamthania
// @match https://www.youtube.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var goTOEmbed= function(){
var parameters = new URLSearchParams(window.location.search);
var videoCode = parameters.get('v');
if(videoCode) {
location.replace ("https://www.youtube.com/embed/" + videoCode);
}
}
window.document.body.addEventListener("yt-navigate-finish", function(event) {
goTOEmbed();
});
goTOEmbed();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment