secret
Last active

"YouTube Kid Mode" for Tampermonkey

  • Download Gist
youtube_kid_mode.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
// ==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);

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.