By MooGoo
Has 1 other script.
// ==UserScript==
// @name YouTube Googler
// @namespace http://bigmooworld.com/youtubegoogler
// @include http://youtube.com/w*
// @include http://*.youtube.com/w*
// ==/UserScript==
var youtube_googler = function() {
//********************
//* Useful Functions *
//********************
var log = function() {
unsafeWindow.console.log.apply(this, arguments);
};
var $ = function(id) { return document.getElementById(id); };
var $x = function(xpath) {
var snapshot = document.evaluate(xpath, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
var ar = new Array();
for (var i = 0; i < snapshot.snapshotLength; i++) {
ar.push(snapshot.snapshotItem(i));
}
return ar;
}
var $s = function(s) {
if (!(s instanceof Array)) {
s = [s];
}
var a = [];
for (var i = 0, slen = s.length; i < slen; i++) {
var t = (s[i][0] == '#' ? $(s[i].substr(1)) : $x(s[i]));
if (t instanceof Array) {
for (var n = 0, tlen = t.length; n < tlen; n++) {
a.push(t[n]);
}
} else {
a.push(t);
}
}
return a;
}
var appendChildren = function (parent, children) {
for (var i = 0, len = children.length; i < len; i++) {
if (children[i]) {
parent.appendChild(children[i]);
}
}
}
//Opera stuff
var opera = (window.opera) ? true : false;
var GMO_setValue = function(name, value) {
if (opera) {
alert('dude');
return opera_GM_setValue(name, value);
} else {
return GM_setValue(name, value);
}
}
var GMO_getValue = function(name, defaultValue) {
if (opera) {
return opera_GM_getValue(name, defaultValue);
} else {
return GM_getValue(name, defaultValue);
}
}
var GMO_addStyle = function(css) {
if (opera) {
return opera_GM_addStyle(css);
} else {
return GM_addStyle(css);
}
}
var opera_GM_setValue = function( cookieName, cookieValue, lifeTime ) {
if( !cookieName ) { return; }
if( lifeTime == "delete" ) { lifeTime = -10; } else { lifeTime = 31536000; }
document.cookie = escape( cookieName ) + "=" + escape( cookieValue ) +
";expires=" + ( new Date( ( new Date() ).getTime() + ( 1000 * lifeTime ) ) ).toGMTString() + ";path=/";
}
var opera_GM_getValue = function( cookieName, oDefault ) {
var cookieJar = document.cookie.split( "; " );
for( var x = 0; x < cookieJar.length; x++ ) {
var oneCookie = cookieJar[x].split( "=" );
if( oneCookie[0] == escape( cookieName ) ) {
try {
eval('var footm = '+unescape( oneCookie[1] ));
} catch(e) { return oDefault; }
return footm;
}
}
return oDefault;
}
var opera_GM_addStyle = function(css) {
var style = document.createElement('style');
style.appendChild(document.createTextNode(css));
document.getElementsByTagName('head')[0].appendChild(style);
}
var splitSize = GMO_getValue('splitSize', 400);
//**********
//* Styles *
//**********
//GM_addStyle(<><![CDATA[
GMO_addStyle("\
div#ovMain {\
height: 300px;\
position: relative;\
}\
\
div#ovVid {\
background: black;\
margin-right:"+splitSize+"px;\
height: 100%; \
border-right: solid 1px #000;\
text-align: center;\
}\
\
embed {\
position: relative;\
}\
\
div#ovSide {\
width:"+splitSize+"px;\
height: 100%;\
position: absolute;\
right: 0;\
top: 0;\
overflow: auto;\
}\
\
table.watch-tabs {\
width: 100%;\
}\
\
#watch-rating-div {\
width: 250px;\
}\
\
#watch-views-div {\
width: 120px;\
}\
\
#movie-player {\
width: 100%;\
height: 100%;\
}\
\
#old-masthead .logo, \
#old-masthead .bar .leftcap, \
#old-masthead .bar .rightcap {\
display: none !important;\
}\
\
#old-masthead, \
#tab-wrapper,\
#old-masthead .bar,\
#old-masthead .search-bar,\
#old-masthead .nav-item .content,\
#watch-video-responses-children,\
#top-margin-links-wrapper,\
#lang-locale-picker-links-wrapper,\
#search-advanced-form .search-advanced-main,\
#watch-channel-stats,\
#search-advanced-form .search-subsection {\
width: auto !important;\
}\
\
#old-masthead #tab-wrapper,\
#top-margin-links-wrapper,\
#old-masthead .search-bar,\
#search-form,\
#old-masthead .search-settings-link {\
float: none;\
}\
\
#old-masthead #search-form {\
padding-left: 5px !important;\
}\
\
div#old-masthead #tab-wrapper {\
padding: 0;\
position: relative;\
top: -0px;\
width: 291px !important;\
margin-right: auto;\
margin-left: auto;\
}\
\
.watch-tabs td {\
font-size: inherit;\
}\
\
#old-masthead #search-term {\
width: 140px;\
}\
\
#watch-ratings-views,\
#watch-channel-vids-div,\
#watch-actions-area,\
#watch-comments-stats {\
border-left: none;\
border-right: none;\
}\
\
form#comment_formmain_comment textarea {\
width: 100%;\
}\
\
#search-advanced-form .search-subsection {\
float: none;\
}\
\
input#embed_code {\
width: 100%;\
}\
div.watch-comment-action {\
clear: both;\
}\
\
#old-masthead .bar,\
#old-masthead div#search-form,\
#old-masthead .search-bar {\
height: auto;\
}\
\
#old-masthead .search-bar {\
background: #E5E6E5;\
border: solid 1px #d5d5d5;\
border-left: none;\
border-right: none;\
}\
#old-masthead #search-form {\
float: none;\
}\
\
.search-settings-link {\
position: absolute;\
right: 2px;\
top: 61px;\
}\
#old-masthead div#search-form {\
padding-bottom: .5em;\
}\
\
#old-masthead form div.bar {\
width: 100% !important;\
}\
\
div#ovSide > div {\
border-top: solid 1px #ccc;\
border-bottom: solid 1px #ccc;\
margin-bottom: .5em;\
}\
\
div#old-masthead {\
border-top: none !important;\
border-bottom: none !important;\
}\
");
//************
//* Template *
//************
var template = {
player: '#movie_player',
side: ['#old-masthead', '#watch-channel-brand-cap', '#watch-channel-vids-div', '#watch-ratings-views', '#playlist-panel', '//div[@id="more-from-panel"]/parent::div', '#quicklistDiv', '#watch-related-videos-panel', '#watch-actions-area', '#watch-comments-stats', '#non-logo-masthead']
};
//******************
//* Create Overlay *
//******************
$('baseDiv').style.display = "none";
var overlayhtml = '<div id="ovVid"></div><div id="ovSide"></div>'
var overlay = document.createElement('div');
overlay.id = 'ovMain';
overlay.innerHTML = overlayhtml;
document.body.appendChild(overlay);
var centerVid = function() {
var p = $('ovVid').getElementsByTagName('embed');
if (!p.length) return false;
p = p[0];
p.style.top = ((window.innerHeight / 2) - (p.offsetHeight / 2)) + "px";
}
var overlayHeight = function() {
$('ovMain').style.height = window.innerHeight + 'px';
centerVid();
}
overlayHeight();
window.addEventListener('resize', overlayHeight, false);
//********************
//* Populate Overlay *
//********************
var ovVid = $('ovVid');
var ovSide = $('ovSide');
appendChildren(ovSide, $s(template.side));
var player = $s(template.player)[0];
var vidSize = GMO_getValue('vidSize', 100);
player.setAttribute('height', vidSize + '%');
player.setAttribute('width', vidSize + '%');
ovVid.appendChild(player);
centerVid();
var mouseclick = false;
var doresize = false;
//var dovidresize = false;
//var dovidresize_swidth = null;
var clickpos = false;
var lastpos = false;
var objover = false;
var resizeSplit = function(pos) {
if (pos <= 0) {
pos = 0;
ovVid.style.borderRight = "solid 4px #666";
} else {
ovVid.style.borderRight = '';
}
ovVid.style.marginRight = pos + 'px';
ovSide.style.width = pos + 'px';
}
var resizeVid = function(change) {
//var per = change / window.innerHeight;
var emb = $('ovVid').getElementsByTagName('embed')[0];
var curper = parseInt(emb.getAttribute('height').match(/^(\d+)%/)[1]);
//var inp = $('masthead-search-term');
//var newper = curper * per;
var newval = ((change - lastpos[1])/4) + curper;
//inp.value = per + ', ' + curper + ', ' + newper;
if (newval < 10) newval = 10;
else if (newval > 100) newval = 100;
emb.setAttribute('width', newval + '%');
emb.setAttribute('height', newval + '%');
centerVid();
}
var inResizeArea = function(x) {
var w = 5;
return (x < ovVid.offsetWidth + w && x > ovVid.offsetWidth - w);
}
window.addEventListener('mousemove', function(ev) {
if (doresize) {
ovSide.style.MozUserSelect = 'none';
var nw = (window.innerWidth - ev.clientX);
if (!ev.shiftKey) {
resizeSplit(nw);
}
if (!ev.ctrlKey) {
resizeVid(ev.clientY);
}
/*} else if (dovidresize) {
var np = (ev.clientX / dovidresize_swidth);
resizeVid(np);*/
} else if (inResizeArea(ev.clientX)) {
document.body.style.cursor = 'e-resize';
} else {
document.body.style.cursor = '';
}
lastpos = [ev.clientX, ev.clientY];
}, false);
var rfalse = function() { return false; };
window.addEventListener('mousedown', function(ev) {
mouseclick = ev.button;
if (ev.button === 0 && inResizeArea(ev.clientX)) {
doresize = true;
/*} else if (ev.button === 2 && inResizeArea(ev.clientX)) {
dovidresize = true;
var p = $('ovVid').getElementsByTagName('embed')[0];
dovidresize_swidth = ev.clientX + ((p.offsetWidth / ev.clientX) * ev.clientX);*/
}
clickpos = [ev.clientX, ev.clientY];
lastpos = [ev.clientX, ev.clientY];
}, false);
window.addEventListener('mouseup', function(ev) {
if (doresize && ev.clientX == clickpos[0] && ev.clientY == clickpos[1]) {
if (ovSide.offsetWidth == 0) {
resizeSplit(splitSize);
} else {
resizeSplit(0);
}
} else if (doresize) {
splitSize = ovSide.offsetWidth;
GMO_setValue('splitSize', splitSize);
GMO_setValue('vidSize', $('ovVid').getElementsByTagName('embed')[0].getAttribute('width').match(/^(\d+)%/)[1]);
}
mouseclick = false;
doresize = false;
//dovidresize = false;
//dovidresize_siwdth = null;
clickpos = false;
ovSide.style.MozUserSelect = '';
}, false);
};
if (window.opera) {
window.addEventListener('load', youtube_googler, false);
} else {
youtube_googler();
}