Create a gist now

Instantly share code, notes, and snippets.

@xtagon /youtube_kid_mode.js Secret
Last active Dec 11, 2015

What would you like to do?
"YouTube Kid Mode" for Tampermonkey
// ==UserScript==
// @name YouTube Kid Mode
// @description Don't show recommendations at the end of YouTube videos
// @version 0.1
// @namespace
// @copyright 2012 Justin Workman
// @match*
// @match*
// @match*
// ==/UserScript==
// See
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="$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