There are 6 previous versions of this script.
// ==UserScript==
// @name Download Youtube Videos
// @namespace youtube
// @description Downloads youtube videos
// @include http://youtube.com/watch?v=*
// @include http://*.youtube.com/watch*
// ==/UserScript==
var frmts={5:"Regular Quality FLV",6:"High Quality FLV",13:"3GP Cell Phone (No Sound)",17:"3GP Cell Phone (With Sound)",18:"MP4 iPod Compatible",22:"720p High Def Video",37:"1080p High Def Video"};
var url,s;
var vid=window.location.href.match(new RegExp(".*?v=([a-zA-Z0-9]+)"))[1];
var dl=document.createElement("a");
dl.textContent="Download";
dl.style.setProperty("text-decoration","none",null);
dl.style.setProperty("font-size","12pt",null);
if(vid.indexOf("&")!=-1) vid=vid.substr(0,vid.indexOf("&"));
GM_xmlhttpRequest(
{
method:"GET",
url:"http://www.youtube.com/get_video_info?&video_id="+vid,
onload:function(r)
{
var token=r.responseText.match(new RegExp(".*?&token=([a-zA-Z0-9_\\-+/=%]+)"))[1];
url="http://youtube.com/get_video?video_id="+vid+"&t="+token+"&fmt=";
s=document.createElement("select");
var vta=document.getElementById('watch-vid-title');
vta.appendChild(s);
for(i in frmts)
{
var t=document.createElement("option");
t.value=i;
t.innerHTML=frmts[i];
s.appendChild(t);
}
s.addEventListener("change",changeURL,false);
vta.appendChild(dl);
changeURL();
}
});
function changeURL(e)
{
dl.href=url+s.value;
}
