-
-
Save xtagon/3fc1abc1713128245896 to your computer and use it in GitHub Desktop.
"YouTube Kid Mode" for Tampermonkey
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 Kid Mode | |
// @description Don't show recommendations at the end of YouTube videos | |
// @version 0.1 | |
// @namespace http://www.xtagon.com/ | |
// @copyright 2012 Justin Workman | |
// @match http://www.youtube.com/watch* | |
// @match http://www.youtu.be/* | |
// @match http://youtu.be/* | |
// ==/UserScript== | |
// See http://www.reddit.com/r/SomebodyMakeThis/comments/16gtte/ | |
function replace_video() | |
{ | |
var video_id_regex = /(?:http:\/\/)?(?:www\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?v=)?(.+)/g; | |
var embed_code_pattern = '<iframe width="640" height="390" src="http://www.youtube.com/embed/$1?rel=0" frameborder="0" allowfullscreen></iframe>'; | |
var embed_code = window.location.href.replace(video_id_regex, embed_code_pattern); | |
var player_root_element = document.getElementsByClassName("player-root")[0]; | |
player_root_element.innerHTML = embed_code; | |
} | |
// Set a short delay before replacing YouTube's player embed code | |
// It doesn't work without the delay, but it can probably be tweaked | |
setTimeout(replace_video, 500); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment