// Youtube Auto High-Quality
// version 1.0
// 2008-11-15
// By Zarel - aesoft.org/zarel/
// Released under public domain
// Also licensed under BSD, MIT, GPL, LGPL, in case public domain
// doesn't apply in your jurisdiction
//
// --------------------------------------------------------------------
//
// This is a Greasemonkey user script.
//
// To install, you need Greasemonkey: http://greasemonkey.mozdev.org/
// Then restart Firefox and revisit this script.
// Under Tools, there will be a new menu item to "Install User Script".
// Accept the default configuration and install.
//
// To uninstall, go to Tools/Manage User Scripts,
// select "Youtube Auto High-Quality", and click Uninstall.
//
// --------------------------------------------------------------------
//
// ==UserScript==
// @name           Youtube Auto High-Quality
// @namespace      http://aesoft.org/
// @description    Automatically displays the high-quality versions of YouTube videos.
// @include        http://www.youtube.com/*
// @include        http://youtube.com/*
// ==/UserScript==

if (window.location.href.indexOf("youtube.com/watch?") != -1
&& window.location.href.indexOf("fmt=") == -1)
	window.location.replace(window.location.href + '&fmt=18');
else
{
	var i, l = document.getElementsByTagName('a');
	
	for (i=0; i<l.length; i++)
	{
		if ((l[i].href.substr(0,29) == "http://www.youtube.com/watch?"
		|| l[i].href.substr(0,25) == "http://youtube.com/watch?")
		&& l[i].href.indexOf("fmt=") == -1)
			l[i].href = l[i].href + '&fmt=18';
	}
}