Created
April 21, 2019 05:25
-
-
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.
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
// ==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