Skip to content

Instantly share code, notes, and snippets.

@ishubham-k
Created April 21, 2019 05:25
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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