There are 18 previous versions of this script.
// ==UserScript==
// @name YouTube Customization
// @namespace http://userscripts.org/users/23652
// @description Customize YouTube's Player Page
// @include http://*.youtube.com/watch?v=*
// @include http://youtube.com/watch?v=*
// @copyright JoeSimmons
// @version 1.0.6
// @license Creative Commons Attribution-Noncommercial 3.0 United States License
// @require http://userscripts.org/scripts/source/49700.user.js
// ==/UserScript==
// Create by avg, modified by JoeSimmons
function create(a,b) {
var ret=document.createElement(a);
if(b) for(var prop in b) {
if(prop.indexOf('on')==0) ret.addEventListener(prop.substring(2),b[prop],false);
else if(prop=="kids" && (prop=b[prop])) {
for(var i=0;i<prop.length;i++) ret.appendChild(prop[i]);
}
else if('style,accesskey,id,name,src,href'.indexOf(prop)!=-1) ret.setAttribute(prop, b[prop]);
else ret[prop]=b[prop];
} return ret;
}
// $g by JoeSimmons. Supports ID, Class, and XPath (full with types) in one query
// Supports multiple id/class grabs in one query (split by spaces), and the ability to remove all nodes regardless of type
// See script page for syntax examples: http://userscripts.org/scripts/show/51532
function $g(que, obj) {
if(!que || !(que=que.replace(/^\s+/,''))) return;
var obj=obj||({del:false,type:6,node:document}), r,
idclass_re=/^[#\.][^\/]/, xp_re=/^\.?(\/\/|count|id)/;
if(typeof que!='string' || que=='') return false;
else if(idclass_re.test(que)) {
var s=que.split(' '), r=new Array(), c;
for(var n=0; n<s.length; n++) {
switch(s[n].substring(0,1)) {
case '#': r.push(document.getElementById(s[n].substring(1))); break;
case '.': c=document.getElementsByClassName(s[n].substring(1));
if(c.length>0) for(var i=0; i<c.length; i++) r.push(c[i]); break;
}
}
if(r.length==1) r=r[0];
} else if(xp_re.test(que)) {
r = document.evaluate(que,(obj['node']||document),null,(obj['type']||6),null);
switch((obj['type']||6)){
case 1: r=r.numberValue; break;
case 2: r=r.stringValue; break;
case 3: r=r.booleanValue; break;
case 8: case 9: r=r.singleNodeValue; break;
}
}
if(r && obj['del']===true) {
if(r.nodeType==1) r.parentNode.removeChild(r);
else if(r.snapshotItem) for(var i=r.snapshotLength-1; (item=r.snapshotItem(i)); i--) item.parentNode.removeChild(item);
else if(!r.snapshotItem) for(var i=r.length-1; i>=0; i--) if(r[i]) r[i].parentNode.removeChild(r[i]);
} return r;
}
function uncheckAll() {
var ops = $g(".//input[@type='checkbox']", {node:$g("#yt_c_options")});
if(ops) for(var i=0; i<ops.snapshotLength; i++) ops.snapshotItem(i).checked = false;
}
function checkAll() {
var ops = $g(".//input[@type='checkbox']", {node:$g("#yt_c_options")});
if(ops) for(var i=0; i<ops.snapshotLength; i++) ops.snapshotItem(i).checked = true;
}
// Toggle visibility of id/node by JoeSimmons
// Syntax: toggle('gbar');
function toggle(e) {
var node=(typeof e=='string')?$g('#'+e):((typeof e=='object')?e:false);
if(node) node.style.display=(node.style.display!='none')?'none':'';
}
function check(c) {
var e = (typeof c=='string') ? $g('#'+c) : c;
if(e) e.checked = true;
}
function uncheck(c) {
var e = (typeof c=='string') ? $g('#'+c) : c;
if(e) e.checked = false;
}
function checked(c) {
var e = (typeof c=='string') ? $g('#'+c) : c;
if(!e) alert(c);
return e.checked;
}
function hide(hide_id, parent) {
var e = (typeof hide_id=='string') ? $g('#'+hide_id) : hide_id;
if(e && parent) {
if(parent==1) e.parentNode.style.display = "none";
if(parent==2) e.parentNode.parentNode.style.display = "none";
if(parent==3) e.parentNode.parentNode.parentNode.style.display = "none";
} else if(e) e.style.display = "none";
}
function show(show_id, parent) {
var e = (typeof show_id=='string') ? $g('#'+show_id) : show_id;
if(e && parent) {
if(parent==1) e.parentNode.style.display = "";
if(parent==2) e.parentNode.parentNode.style.display = "";
if(parent==3) e.parentNode.parentNode.parentNode.style.display = "";
} else if(e) e.style.display = "";
}
function customize() {
var options = {
hide_ads : GM_getValue("ads", false),
hide_embed_form : GM_getValue("embed_form", false),
hide_url_form : GM_getValue("url_form", false),
hide_more_from : GM_getValue("more_from", false),
hide_related_videos : GM_getValue("related_videos", false),
hide_promoted_videos : GM_getValue("promoted_videos", false),
hide_comments : GM_getValue("comments", false),
hide_tags : GM_getValue("tags", false),
hide_video_details : GM_getValue("video_details", false),
hide_ratings_and_views : GM_getValue("ratings_and_views", false),
hide_search_box : GM_getValue("search_box", false),
hide_also_watching : GM_getValue("also_watching", false),
hide_views : GM_getValue("views", false),
hide_watch_main : GM_getValue("watch_main", false),
hide_share_options : GM_getValue("share_options", false)
};
if(options['hide_ads']) {
hide("watch-channel-brand-div");
hide("watch-channel-brand-cap");
check("ads");
} else { show("watch-channel-brand-div"); show("watch-channel-brand-cap"); }
if(options['hide_url_form']) {
hide("watch-url-div");
check("url_form");
} else show("watch-url-div");
if(options['hide_embed_form']) {
hide("watch-embed-div");
check("embed_form");
} else show("watch-embed-div");
if(options['hide_more_from']) {
hide("watch-channel-videos-panel");
check("more_from");
} else show("watch-channel-videos-panel");
if(options['hide_related_videos']) {
hide("watch-related-videos-panel");
check("related_videos");
} else show("watch-related-videos-panel");
if(options['hide_promoted_videos']) {
hide("watch-promoted-videos-container", 1);
check("promoted_videos");
} else show("watch-promoted-container", 1);
if(options['hide_comments']) {
hide("watch-comments-stats");
check("comments");
} else show("watch-comments-stats");
if(options['hide_tags']) {
hide("watch-video-tags-div");
check("tags");
} else show("watch-video-tags-div");
if(options['hide_video_details']) {
hide("watch-channel-vids-div");
check("video_details");
} else show("watch-channel-vids-div");
if(options['hide_ratings_and_views']) {
hide("watch-ratings-views");
check("ratings_and_views");
} else show("watch-ratings-views");
if(options['hide_search_box']) {
hide("masthead-search-term", 3);
check("search_box");
} else show("masthead-search-term", 3);
if(options['hide_also_watching']) {
hide("watch-active-sharing");
check("also_watching");
} else show("watch-active-sharing");
if(options['hide_views']) {
hide("watch-views-div");
check("views");
} else show("watch-views-div");
if(options['hide_watch_main']) {
hide("watch-main-area");
check("watch_main");
} else show("watch-main-area");
if(options['hide_share_options']) {
hide("aggregationServicesDiv");
check("share_options");
} else show("aggregationServicesDiv");
}
function options_box() {
toggle("yt_c_options");
}
function save_options() {
GM_setValue("ads", checked("ads"));
GM_setValue("embed_form", checked("embed_form"));
GM_setValue("url_form", checked("url_form"));
GM_setValue("more_from", checked("more_from"));
GM_setValue("related_videos", checked("related_videos"));
GM_setValue("promoted_videos", checked("promoted_videos"));
GM_setValue("comments", checked("comments"));
GM_setValue("tags", checked("tags"));
GM_setValue("video_details", checked("video_details"));
GM_setValue("ratings_and_views", checked("ratings_and_views"));
GM_setValue("search_box", checked("search_box"));
GM_setValue("also_watching", checked("also_watching"));
GM_setValue("views", checked("views"));
GM_setValue("watch_main", checked("watch_main"));
GM_setValue("share_options", checked("share_options"));
options_box();
customize();
}
if(!$g("#yt_c_options")) {
$g("#masthead-nav-main").appendChild(create('a', {textContent:'YouTube Customization',href:'javascript:void(0);',onclick:options_box}));
document.body.insertBefore(create('div', {style:'text-align:left; background-color:#eee; position:fixed; top:50px; right:20px; padding:10px 20px 10px 20px; color:#000; z-index:999999; border: 2px ridge #000; display:none;',id:'yt_c_options',
innerHTML:"<table><th colspan=\"2\">Hide:</th><tbody>"
+"<tr><td>Ads</td><td><input type=\"checkbox\" id=\"ads\"></td></tr>"
+"<tr><td>URL Form</td><td><input type=\"checkbox\" id=\"url_form\"></td></tr>"
+"<tr><td>Embed Form</td><td><input type=\"checkbox\" id=\"embed_form\"></td></tr>"
+"<tr><td>More From Panel</td><td><input type=\"checkbox\" id=\"more_from\"></td></tr>"
+"<tr><td>Related Videos</td><td><input type=\"checkbox\" id=\"related_videos\"></td></tr>"
+"<tr><td>Promoted Videos</td><td><input type=\"checkbox\" id=\"promoted_videos\"></td></tr>"
+"<tr><td>Comments</td><td><input type=\"checkbox\" id=\"comments\"></td></tr>"
+"<tr><td>Video Tags</td><td><input type=\"checkbox\" id=\"tags\"></td></tr>"
+"<tr><td>Video Details</td><td><input type=\"checkbox\" id=\"video_details\"></td></tr>"
+"<tr><td>Ratings & Views</td><td><input type=\"checkbox\" id=\"ratings_and_views\"></td></tr>"
+"<tr><td>Search Box</td><td><input type=\"checkbox\" id=\"search_box\"></td></tr>"
+"<tr><td>Also Watching</td><td><input type=\"checkbox\" id=\"also_watching\"></td></tr>"
+"<tr><td>Views</td><td><input type=\"checkbox\" id=\"views\"></td></tr>"
+"<tr><td>Watch Main Area</td><td><input type=\"checkbox\" id=\"watch_main\"></td></tr>"
+"<tr><td>Share Options</td><td><input type=\"checkbox\" id=\"share_options\"></tr>"
+"</tbody></table><br>",kids:new Array(
create('a', {href:'javascript:void(0);',textContent:'Un-Check All',onclick:uncheckAll,style:'display:block;'}),
create('a', {href:'javascript:void(0);',textContent:'Check All',onclick:checkAll,style:'display:block;'}),
create('input', {value:'Save',type:'button',onclick:save_options,style:'float:left;'}),
create('input', {value:'Close',type:'button',onclick:options_box,style:'float:right;'}),
create('br')
)}), document.body.firstChild);
}
customize();
// addGlobalStyle
function addGlobalStyle(css) {
if(typeof GM_addStyle=='function') GM_addStyle(css);
else if((head=document.getElementsByTagName('head')[0])) {
var style = document.createElement('style');
style.setAttribute('type', 'text/css');
style.innerHTML=css;
head.appendChild(style);
}
}
addGlobalStyle(
"#yt_c_options input[type='checkbox'] {margin-left:8px;}" +
"#yt_c_options input[type='button'] {margin-left:8px; padding:2px 24px 2px 24px;}" +
"#yt_c_options th {font-size: 16px !important;}" +
"#yt_c_options a {margin-bottom:6px;}" +
"#yt_c_options {font-size:14px !important; font-family:tahoma arial !important;}"
);
