Tuesday, February 9, 2010
 

YouTube HD-fier Script

I wasn’t too happy having to click on the HD button of a video in order to view it in high resolution, so I whipped up this little grease monkey script. It simply enables HD, when available, for any links on the YouTube Homepage, My Videos & My Favorites.

Feel free to improve it, and leave a comment if you find it useful.

Install

// ==UserScript==
// @name			YouTube HD-fier
// @version			1.0.0
// @namespace		http://claude.betancourt.us/greasemonkey/youtube/hdfier/1.0.0
// @description		Modifies links to enable HD, when available.
// @include			http://www.youtube.com/*
// @license			(CC) Attribution Non-Commercial Share Alike; http://creativecommons.org/licenses/by-nc-sa/3.0/
// ==/UserScript==

// Add jQuery
var GM_jQuery = document.createElement('script');
GM_jQuery.src = 'http://jqueryjs.googlecode.com/files/jquery-1.2.6.pack.js';
GM_jQuery.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(GM_jQuery);

// Wait until jQuery has loaded
function GM_wait() {
    if( typeof unsafeWindow.jQuery == 'undefined' ) {
        window.setTimeout(GM_wait,100);
    } else {
        $ = unsafeWindow.jQuery;
        GM_ready();
    }
}
GM_wait();

// Once document and jQuery are loaded
function GM_ready() {

	var selectors = [
		'.video-short-title a',
		'.video-mini-title a',
		'.clipper a'
	];

	HDify(selectors);

}

function HDify(selectors) {
	try {
		$.each(selectors,function(i,s){
			var l = $(s);
			$.each(l, function(i,a){
				a.href += '&fmt=18';
			});
		});
	} catch(e){}
}
 

Tags: , , , ,

Related Posts

Comments

No comments so far.
  • Leave a Reply
     
    Your gravatar
    Your Name
     
     
     
     
     
 
About Me

I work as an application architect at Dow Jones & Company, the parent company of The Wall Street Journal, Dow Jones Indexes and Marketwatch.com.

On my time *off* I do freelance work for small businesses. I also like to tinker with electronics and have recently taken up photography and competitive shooting.

Learn more »
Focus

Front-end engineering. Full cycle application architecture and development of Internet based systems including conceptualization, logical modeling, physical design, development and implementation.

Specialties

Ajax, JavaScript, Ext-JS, jQuery, UX, CFML, PHP, CodeIgniter, C#, WordPress customization

Get in touch

Phone: +1 732 391 1122
Email: consulting@betancourt.us