There are 14 previous versions of this script.
Add Syntax Highlighting (this will take a few seconds, probably freezing your browser while it works)
// ==UserScript==
// @name YouTube HD Suite
// @namespace http://creazy.net/
// @description Perfect package to enjoy HD videos in YouTube. Always watching or downloading the highest quality format ( HD 1080p / HD 720p / HQ FLV / MP4 iPod ). Add download icons in video list page.
// @include http://*.youtube.com/*
// @include http://youtube.com/*
// ==/UserScript==
(function() {
var w = (typeof(unsafeWindow) != 'undefined') ? unsafeWindow : window;
var d = w.document;
var l = w.location;
var s = w.yt.config_.SWF_ARGS;
/**
* YouTube HD Suite Object
*/
w.hdsuite = {
/**
* YouTube HD Suite version
*/
version: { text:'2.0.3', rev:200911240030 },
/**
* Auto version check
*/
checkVersionCallback: function(json) {
//console.log(json);
w.hdsuite.addCookie('hdsuite_last_update_rev',json.rev);
if ( json.rev > w.hdsuite.version.rev ) {
var a = document.getElementById('hdsuite_update_button');
a.href = 'http://userscripts.org/scripts/source/39167.user.js';
a.title = 'Update now!';
a.style.backgroundPosition = '-20px 0';
alert("New YouTube HD Suite "+json.text+" is now available!\nClick the buttom of right side, Update now!");
}
},
/**
* YouTube All Format
*/
formats: {
37: {icon:'FHD',desc:'fmt=37 ( HD1080p/MP4/H.264/AAC )',color:"F0F",check:1},
22: {icon:'HD', desc:'fmt=22 ( HD720p /MP4/H.264/AAC )',color:"F00",check:1},
35: {icon:'HQ', desc:'fmt=35 ( HQ /FLV/H.264/AAC )',color:"0F0",check:1},
34: {icon:'LQ', desc:'fmt=34 ( LQ /FLV/H.264/AAC )',color:"00F",check:1},
18: {icon:'SD', desc:'fmt=18 ( iPod /MP4/H.264/AAC )',color:"666",check:0},
6: {icon:'OLD',desc:'fmt=6 ( OldHQ /FLV/H.263/MP3 )',color:"999",check:1},
5: {icon:'OLD',desc:'fmt=5 ( OldLQ /FLV/H.263/MP3 )',color:"999",check:0},
17: {icon:'MOB',desc:'fmt=17 ( Hmobile/3GP/MPEG4/AAC )',color:"999",check:0},
13: {icon:'MOB',desc:'fmt=13 ( Lmobile/3GP/H.263/AMR )',color:"999",check:0}
},
/**
* Function add cookie
*/
addCookie: function(key, value) {
if ( !key ) {
return false;
}
document.cookie
= key + '=' + escape(value) + '; '
+ 'expires=Tue, 1-Jan-2030 00:00:00 GMT; '
+ 'path=/; ';
},
/**
* Get cookie
*/
getCookie: function(key) {
var cookies = document.cookie.split(';');
for ( var i=0; i<cookies.length; i++ ) {
if ( cookies[i].indexOf('=') < 0 ) continue;
key_value = cookies[i].replace(/(^[\s]+|;)/g,'');
deli_index = key_value.indexOf('=');
if ( key_value.substring(0,deli_index) == key ) {
return unescape(key_value.substring(deli_index+1,key_value.length));
}
}
return '';
},
/**
* Configs
*/
config: {
// default settings
redirect: 1, // Do redirect to highest format page
show_highest_link: 1, //
//show_highest_embed: 1, //
visualize: 1, // Do check format of listed videos
download_formats: {
37: 1,
22: 1,
35: 1,
34: 1,
18: 1,
6: 0,
5: 0,
17: 0,
13: 0
}
},
/**
* Set Config to cookie
*/
setConfig: function() {
var config
= '{'
+ 'redirect:'+(document.getElementById('hdsuite_config_redirect').checked?1:0)+','
+ 'show_highest_link:'+(document.getElementById('hdsuite_config_showlink').checked?1:0)+','
//+ 'show_highest_embed:'+(document.getElementById('hdsuite_config_showembed').checked?1:0)+','
+ 'visualize:'+(document.getElementById('hdsuite_config_visualize').checked?1:0)+','
+ 'download_formats: {'
+ '37:'+(document.getElementById('hdsuite_config_dl37') && document.getElementById('hdsuite_config_dl37').checked?1:0)+','
+ '22:'+(document.getElementById('hdsuite_config_dl22') && document.getElementById('hdsuite_config_dl22').checked?1:0)+','
+ '35:'+(document.getElementById('hdsuite_config_dl35') && document.getElementById('hdsuite_config_dl35').checked?1:0)+','
+ '34:'+(document.getElementById('hdsuite_config_dl34') && document.getElementById('hdsuite_config_dl34').checked?1:0)+','
+ '18:'+(document.getElementById('hdsuite_config_dl18') && document.getElementById('hdsuite_config_dl18').checked?1:0)+','
+ '6:'+(document.getElementById('hdsuite_config_dl6') && document.getElementById('hdsuite_config_dl6').checked?1:0)+','
+ '5:'+(document.getElementById('hdsuite_config_dl5') && document.getElementById('hdsuite_config_dl5').checked?1:0)+','
+ '17:'+(document.getElementById('hdsuite_config_dl17') && document.getElementById('hdsuite_config_dl17').checked?1:0)+','
+ '13:'+(document.getElementById('hdsuite_config_dl13') && document.getElementById('hdsuite_config_dl13').checked?1:0)+''
+ '}'
+ '}';
w.hdsuite.addCookie('hdsuite_config', config);
alert("Saved!\nAfter reloading the page, the setting will become effective.");
w.hdsuite.closeConfig();
},
/**
* Get Config from cookie
*/
getConfig: function() {
var config = w.hdsuite.getCookie('hdsuite_config');
if ( config ) {
w.hdsuite.config = eval('('+config+')');
}
},
/**
*
*/
openConfig: function() {
document.getElementById('hdsuite_config_panel').style.display = 'block';
document.getElementById('hdsuite_switch').href = 'javascript:hdsuite.closeConfig();';
document.getElementById('hdsuite_switch').title = 'Close config panel.';
document.getElementById('hdsuite_switch').style.backgroundPosition = '-20px -100px';
},
/**
*
*/
closeConfig: function() {
document.getElementById('hdsuite_config_panel').style.display = 'none';
document.getElementById('hdsuite_switch').href = 'javascript:hdsuite.openConfig();';
document.getElementById('hdsuite_switch').title = 'Open config panel.';
document.getElementById('hdsuite_switch').style.backgroundPosition = '0 -100px';
},
/**
* create Menu
*/
createMenu: function() {
/* update button */
var a = d.createElement('a');
a.id = 'hdsuite_update_button';
a.href = 'javascript:hdsuite.checkVersion(true);';
a.title = 'Check version.';
a.style.display = 'block';
a.style.width = '20px';
a.style.height = '20px';
a.style.overflow = 'hidden';
a.style.zIndex = '999';
a.style.position = 'fixed';
a.style.top = '100px';
a.style.right = '0';
a.style.background = 'url('+w.hdsuite.sprite+') no-repeat scroll 0 0';
d.body.appendChild(a);
/* visualize button */
a = d.createElement('a');
a.href = 'javascript:hdsuite.visualize();';
a.title = 'Check formats again!';
a.setAttribute('onmouseover','this.style.backgroundPosition=\'-20px -20px\';');
a.setAttribute('onmouseout','this.style.backgroundPosition=\'0 -20px\';');
a.style.display = 'block';
a.style.width = '20px';
a.style.height = '20px';
a.style.overflow = 'hidden';
a.style.zIndex = '999';
a.style.position = 'fixed';
a.style.top = '120px';
a.style.right = '0';
a.style.background = 'url('+w.hdsuite.sprite+') no-repeat scroll 0 -20px';
d.body.appendChild(a);
/* icon */
a = d.createElement('a');
a.id = 'hdsuite_logo';
a.href = 'http://userscripts.org/scripts/show/39167';
a.title = 'Go to userscripts.org page.';
a.setAttribute('onmouseover','this.style.backgroundPosition=\'-20px -40px\';');
a.setAttribute('onmouseout','this.style.backgroundPosition=\'0 -40px\';');
a.style.display = 'block';
a.style.width = '20px';
a.style.height = '60px';
a.style.overflow = 'hidden';
a.style.zIndex = '999';
a.style.position = 'fixed';
a.style.top = '140px';
a.style.right = '0';
a.style.background = 'url('+w.hdsuite.sprite+') no-repeat scroll 0 -40px';
d.body.appendChild(a);
/* open button */
a = d.createElement('a');
a.id = 'hdsuite_switch';
a.href = 'javascript:hdsuite.openConfig();';
a.title = 'Open configration panel.';
a.style.display = 'block';
a.style.width = '20px';
a.style.height = '20px';
a.style.overflow = 'hidden';
a.style.zIndex = '999';
a.style.position = 'fixed';
a.style.top = '200px';
a.style.right = '0';
a.style.background = 'url('+w.hdsuite.sprite+') no-repeat scroll 0 -100px';
d.body.appendChild(a);
/* Configration panel */
var div = d.createElement('div');
div.id = 'hdsuite_config_panel';
div.style.display = 'none';
div.style.width = '400px';
div.style.zIndex = '998';
div.style.position = 'fixed';
div.style.top = '20px';
div.style.right = '0';
div.style.background = '#EEE';
div.style.borderTop = '3px solid #999';
div.style.borderBottom = '3px solid #999';
div.style.borderLeft = '3px solid #999';
div.style.MozBorderRadiusTopleft = '10px';
div.style.MozBorderRadiusBottomleft = '10px';
div.style.WebkitBorderTopLeftRadius = '10px';
div.style.WebkitBorderBottomLeftRadius = '10px';
div.innerHTML
= '<form id="hdsuite_form" name="hdsuite_form" onsubmit="return false;" style="margin:10px;padding:0;">'
+ '<h3 style="padding:5px;background:#CCC;border:1px solid #999;-moz-border-radius:5px;-webkit-border-radius:5px;">Config Panel</h3>'
+ '<h4>List Page</h4>'
+ '<ul style="margin:0 0 0 15px;">'
+ '<li><input id="hdsuite_config_visualize" name="hdsuite_config_visualize" type="checkbox" value="1" '
+ (w.hdsuite.config.visualize?'checked="checked" ':'')
+ '/>'
+ ' Show icons that checked the highest quality format</li>'
+ '</ul>'
+ '<h4>Watch Page</h4>'
+ '<ul style="margin:0 0 0 15px;">'
+ '<li><input id="hdsuite_config_redirect" name="hdsuite_config_redirect" type="checkbox" value="1" '
+ (w.hdsuite.config.redirect?'checked="checked" ':'')
+ '/> Always watch in highest quality format</li>'
+ '<li><input id="hdsuite_config_showlink" name="hdsuite_config_showlink" type="checkbox" value="1" '
+ (w.hdsuite.config.show_highest_link?'checked="checked" ':'')
+ '/> Show the link in highest quality format</li>'
// comment out embed setting
/*
+ '<li><input id="hdsuite_config_showembed" name="hdsuite_config_showembed" type="checkbox" value="1" '
+ (w.hdsuite.config.show_highest_embed?'checked="checked" ':'')
+ '/>'
+ ' Show the embed code in highest quality format</li>'
*/
+ '</ul>'
+ '<h4>Download formats</h4>'
+ '<table cellpadding="0" cellspacing="5" id="hdsuite_config_downloads" style="margin:0 0 0 15px;"></table>'
+ '<p style="padding:10px;text-align:center;">'
+ '<input id="hdsuite_config_submit" name="hdsuite_config_submit" type="button" value="Save" onclick="hdsuite.setConfig();"'
+ ' style="margin:0 auto;font:20px/20px Arial;" />'
+ '</form>';
d.body.appendChild(div);
html = '';
for ( var i in w.hdsuite.config.download_formats ) {
fmt = w.hdsuite.config.download_formats[i];
config = w.hdsuite.formats[i];
html
+= '<tr>'
+ '<td><input id="hdsuite_config_dl'+i+'" name="hdsuite_config_dl'+i+'" type="checkbox" value="1" '+(fmt?'checked="checked" ':'')+'/></td>'
+ '<td><span style="color:#fff;font:bold 10px/10px Arial;padding:1px 2px;border:1px solid #'+config.color+';-moz-border-radius:3px;-webkit-border-radius:3px;background-color:#'+config.color+';">'+config.icon+'</span></td>'
+ '<td style="'+w.hdsuite.tx.mono+'">'+w.hdsuite.formats[i].desc+'</td>'
+ '</tr>';
}
d.getElementById('hdsuite_config_downloads').innerHTML = html;
},
/**
* create XmlHttpRequest
*/
createXHR: function() {
if ( w.ActiveXObject ) {
try {
return new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
return new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
return null;
}
}
} else if ( w.XMLHttpRequest ) {
return new XMLHttpRequest();
} else {
return null;
}
},
/**
* check URL
*/
checkURL: function(video_id) {
var url = '';
if ( video_id.match(/.+==$/) ) {
url = 'http://'+l.host+'/cthru?key='+video_id;
} else {
url = 'http://'+l.host+'/watch' + '?v='+video_id;
}
var XHR = w.hdsuite.createXHR();
XHR.open( 'GET', url, true );
XHR.onreadystatechange = function() {
if ( XHR.readyState==4 && (match = XHR.responseText.match(/'SWF_ARGS': ({.*})/)) ) {
var json = eval('('+RegExp.$1+')');
var map = decodeURIComponent(json['fmt_url_map']);
var strong = d.getElementsByTagName('strong');
for ( var i=0; i<strong.length; i++ ) {
if ( !strong[i].innerHTML && strong[i].getAttribute('class') == json['video_id'] ) {
link = d.createElement('a');
link.style.color = '#fff';
link.style.font = 'bold 10px/10px Arial';
link.style.padding = '1px 2px';
for ( var j in w.hdsuite.config.download_formats ) {
fmt = w.hdsuite.formats[j];
flag = w.hdsuite.config.download_formats[j];
if ( flag && (
map.indexOf(j+'|') > -1 ||
!fmt.check
)
) {
link.style.border = '1px solid #'+fmt.color;
link.style.MozBorderRadius = '3px';
link.style.WebkitBorderRadius = '3px';
link.style.backgroundColor = '#'+fmt.color;
link.href = '/get_video?fmt='+j+'&video_id='+json['video_id']+'&t='+json['t'];
link.innerHTML = fmt.icon;
if ( strong[i].nextSibling.href && !strong[i].nextSibling.href.match(/#$/) && w.hdsuite.config.redirect ) {
strong[i].nextSibling.href += "&fmt="+j;
}
break;
}
}
strong[i].appendChild(link);
}
}
}
}
XHR.send('');
},
/**
* Add HD or MP4 on each links in YouTube List Page
*/
visualize: function() {
var a = d.getElementsByTagName('a');
for ( var i=0; i<a.length; i++ ) {
match = '';
if ( a[i].innerHTML.match(/<img/i) ) continue; // Skip Image Link
if ( a[i].getAttribute('vid') ) continue; // Skip checked Link
if ( a[i].getAttribute('class') == 'yt-button' ) continue; // Skip Button Link
if ( a[i].parentNode.getAttribute('class') == 'video-time' ) continue; // Skip time
// functional links
if ( a[i].href.match(/#$/) ) {
if ( a[i].getAttribute('onclick') &&
( a[i].getAttribute('onclick').match(/^onPlayVideos\(\['([a-zA-Z0-9_-]*)'\]\)/) ||
a[i].getAttribute('onclick').match(/^onPlayVideos\('\/watch\?v=([a-zA-Z0-9_-]*)'\)/) )
) {
match = RegExp.$1;
a[i].setAttribute('vid',1);
strong = d.createElement('strong');
strong.setAttribute('class',match);
a[i].parentNode.insertBefore(strong, a[i]);
a[i].style.display = 'inline';
} else {
continue;
}
}
// normal 'watch' and 'play list'
else if ( a[i].href.match(/watch\?v=([a-zA-Z0-9_-]*)/) || a[i].href.match(/view_play_list\?.+&v=([a-zA-Z0-9_-]*)/) ) {
match = RegExp.$1;
a[i].setAttribute('vid',2);
strong = d.createElement('strong');
strong.setAttribute('class',match);
a[i].parentNode.insertBefore(strong, a[i]);
}
// new channel page
else if ( !a[i].href && a[i].getAttribute('onclick') && a[i].getAttribute('onclick').match(/playnav.playVideo\(\'.+\',\'[0-9]\',\'([a-zA-Z0-9_-]*)\'\);/) ) {
match = RegExp.$1;
a[i].setAttribute('vid',3);
strong = d.createElement('strong');
strong.setAttribute('class',match);
a[i].parentNode.insertBefore(strong, a[i]);
}
}
var s = d.getElementsByTagName('strong');
var c = '';
for ( var i=0; i<s.length; i++ ) {
if ( !s[i].innerHTML && s[i].getAttribute('class') && c.indexOf(s[i].getAttribute('class')) < 0 ) {
c += ' ' + s[i].getAttribute('class');
w.hdsuite.checkURL( s[i].getAttribute('class') );
}
}
},
/**
* check Format
*/
checkFormat: function(fmt) {
// Local check
var map = decodeURIComponent(s['fmt_url_map']);
if ( map.indexOf(fmt+'|') > -1 ) {
//console.log(fmt);
d.getElementById('check_fmt_'+fmt).innerHTML
= '<a href="'+w.hdsuite.makeDownloadURL(fmt)+'" style="'+w.hdsuite.tx.dl+'background:#'+w.hdsuite.formats[fmt].color+';border:1px solid #'+w.hdsuite.formats[fmt].color+';">[OK] '+w.hdsuite.formats[fmt].desc+'</a>';
return true;
}
// Remote check
var url = 'http://'+l.host+'/watch' + '?fmt='+fmt+'&v='+s['video_id'];
var XHR = w.hdsuite.createXHR();
XHR.open( 'GET', url, true );
XHR.onreadystatechange = function() {
if (XHR.readyState==4) {
if ( match = XHR.responseText.match(/<link\srel=\"alternate\"\smedia=\"handheld\"\shref=\".+?\&fmt=([0-9]+)/) ) {
fmt = RegExp.$1;
//console.log('found fmt='+fmt);
} else {
//console.log('not found');
}
if ( match = XHR.responseText.match(/'SWF_ARGS': ({.*})/) ) {
var block = d.getElementById('check_fmt_'+fmt);
block.innerHTML = '';
var json = eval('('+RegExp.$1+')');
var map = decodeURIComponent(json['fmt_url_map']);
if ( map.indexOf(fmt+'|') > -1 ) {
block.innerHTML
+= '<a href="'+w.hdsuite.makeDownloadURL(fmt)+'" style="'+w.hdsuite.tx.dl+'background:#'+w.hdsuite.formats[fmt].color+';border:1px solid #'+w.hdsuite.formats[fmt].color+';">'
+ '[OK] '+w.hdsuite.formats[fmt].desc+'</a>';
} else {
block.innerHTML
+= '<span style="'+w.hdsuite.tx.mono+'">[NG] '+w.hdsuite.formats[fmt].desc+'</span>';
}
}
}
}
XHR.send('');
},
/**
* Make Download URL
*/
makeDownloadURL: function(num) {
var u = 'http://'+l.host+'/get_video' + '?video_id='+s['video_id'] + '&t=' + s['t'];
if ( num ) {
u += '&fmt='+num;
}
return u;
},
/**
* Redirect Higher Quality URL
*/
redirect: function() {
if ( !w.hdsuite.config.redirect ) return;
var map = decodeURIComponent(s['fmt_url_map']);
if ( map.indexOf('37|') > -1 ) {
l.replace(l.href + '&fmt=37');
}
else if ( map.indexOf('22|') > -1 ) {
l.replace(l.href + '&fmt=22');
}
else if ( map.indexOf('35|') > -1 ) {
l.replace(l.href + '&fmt=35');
}
else if ( map.indexOf('34|') > -1 ) {
l.replace(l.href + '&fmt=34');
}
else {
l.replace(l.href + '&fmt=18');
}
},
/**
* Add Customized Embed Link
*/
showCopyLink: function() {
if ( !w.hdsuite.config.show_highest_link ) return;
var map = decodeURIComponent(s['fmt_url_map']);
for ( var i in w.hdsuite.formats ) {
if( map.indexOf(i+'|') > -1 ) {
document.getElementById('watch-url-field').value += '&fmt='+i;
break;
}
}
/*
embed_command
= 'prompt('
+ '\'Copy & Past the '+m+' embed tag\','
+ 'document.getElementById(\'embed_code\').value.replace(/(http:\\/\\/[a-zA-Z0_-]*\\.youtube\\.com\\/[-_.a-zA-Z0-9\\/?&=%]+)/g,\'$1&ap=%252526fmt%253D'+i+'\')'
+ ');'
+ 'void(0);';
d.getElementById('watch-embed-div').innerHTML
+= '<div id="EMBED-YT-video" style="text-align:right;padding-right:30px;">'
+ '<a href="javascript:'+embed_command+'">[ Highest-Quality-Embed ]</a>'
+ '</div>';
*/
},
/**
* Add Download Links
*/
showDownloadLinks: function() {
if( !d.getElementById('hdsuite_dl_div') ) {
// Create Links Block
d.getElementById('watch-embed-div').innerHTML += '<div id="hdsuite_dl_div" style="margin:10px 0;"></div>';
}
for ( var i in w.hdsuite.config.download_formats ) {
fmt = w.hdsuite.config.download_formats[i];
if ( !fmt ) continue;
config = w.hdsuite.formats[i];
if ( config.check ) {
d.getElementById('hdsuite_dl_div').innerHTML
+= '<div id="check_fmt_'+i+'">checking fmt='+i+'</div>';
w.hdsuite.checkFormat(i);
} else {
d.getElementById('hdsuite_dl_div').innerHTML
+= '<div><a href="'+w.hdsuite.makeDownloadURL(i)+'" style="'+w.hdsuite.tx.dl+'background:#'+w.hdsuite.formats[i].color+';">[OK] '+config.desc+'</a></div>';
}
}
},
sprite:
'data:image/gif;base64,'+
'R0lGODlhKAB4ANU/AO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+
'kJCE5CH54hdGAEYKLoikJguJyMNUsgiNicIANklKF1yGAxx42ic/w4JHknKTMgDI5hbhKSbUZpSk'+
'xKUEIFACCSCgGBGYJXIGxIRMDJKUEMAlLwl5nWBKhFLRWok08fAdQpbgmtgsgSh32UsJyAAcs/QZ'+
'FSAIBWZChQbL9CY4JcKBXoXRPeX0JQLmSc8oZDKd3xyQMNv5TmO+EgKZ5CYzobAJMSgDlbbMhC41'+
'eUxvZvKXDyHIKjPRylfCkkafHM5JFmpRU3LlSNu5pD0tyklxyEGiRpCSNaTgyFdqUwsffMDSUbYE'+
'U0gEsqGG7KQWzNCVK/T0CRktghKCaoQgAAA7',
/**
* text
*/
tx: {
mono: 'display:block;font:12px/12px Osaka-Mono,\'MS Gothic\',Monaco,monospace;white-space:pre;padding:3px;',
dl: 'display:block;font:12px/12px Osaka-Mono,\'MS Gothic\',Monaco,monospace;white-space:pre;padding:3px;color:#FFF;-moz-border-radius:3px;-webkit-border-radius:3px;'
},
/**
* init
*/
init: function() {
w.hdsuite.getConfig();
},
/**
* checkVersion
*/
checkVersion: function( force ) {
if ( !force ) force = false;
// if you don't check version in 24hours, check update automatically.
var last_update_check = w.hdsuite.getCookie('hdsuite_last_update_check');
var now = new Date().getTime();
if ( force || !last_update_check || (now - last_update_check) > (3600 * 24 * 1000) ) {
w.hdsuite.addCookie('hdsuite_last_update_check',now);
var script = d.createElement('script');
script.type = 'text/javascript';
script.src = 'http://labs.creazy.net/greasemonkey/youtube_hd_suite_check.js';
d.body.appendChild(script);
} else {
var rev = w.hdsuite.getCookie('hdsuite_last_update_rev');
if ( rev > w.hdsuite.version.rev ) {
var a = document.getElementById('hdsuite_update_button');
a.href = 'http://userscripts.org/scripts/source/39167.user.js';
a.title = 'Update now!!';
a.style.backgroundPosition = '-20px 0';
}
}
}
}
/* add eventLister for cross browser */
function _AddEventListener(e, type, fn) {
if (e.addEventListener) {
e.addEventListener(type, fn, false);
}
else {
e.attachEvent('on' + type, function() {
fn(window.event);
});
}
}
/**
* Controller
*/
// Watching Page
w.hdsuite.init();
if ( l.pathname.match(/\/watch/) ) {
// always watch in Highest Quality
if ( !l.search.match(/fmt=[0-9]*/) ) {
w.hdsuite.redirect();
}
w.hdsuite.showCopyLink();
w.hdsuite.showDownloadLinks();
}
// Other Page (Top, Browse, seache, ...)
else {
if ( w.hdsuite.config.visualize ) {
// for Auto Pager
var scrollHeight = d.documentElement.scrollHeight;
_AddEventListener(
w,
"scroll",
function(e){
if(d.documentElement.scrollHeight - scrollHeight > 100){
scrollHeight = d.documentElement.scrollHeight;
w.hdsuite.visualize();
}
}
);
}
}
w.hdsuite.createMenu();
w.hdsuite.checkVersion();
if ( w.hdsuite.config.visualize ) {
w.hdsuite.visualize();
}
})();
