youtube video download linker

By jk- Last update Oct 26, 2009 — Installed 7,179 times. Daily Installs: 23, 16, 18, 8, 74, 49, 14, 26, 23, 11, 18, 6, 5, 9, 16, 12, 20, 14, 6, 7, 10, 10, 15, 17, 9, 9, 6, 6, 6, 11, 7, 8

There are 5 previous versions of this script.

// ==UserScript==
// @name           youtube video download linker
// @namespace      http://www.digivill.net/~joykillr
// @description    A video download linker for youtube.  Gives a link on youtube video page.  Does not need javascript and does not use a third-party website.
// @include        http://*.youtube.com/*
// @include        http://youtube.com/*
// ==/UserScript==

//v 1.8

var a1,a2,a22,b3,na,scrhead = document.getElementsByTagName("script");

function addBox(strR) {
	var URLDLbox = document.createElement("a");
	URLDLbox.className = "gm-action-button";
	URLDLbox.href = strR;
	URLDLbox.setAttribute("style", "width:auto !important; color: rgb(0, 51, 204) !important; display: block !important; height: 25px !important; margin-top: 6px !important; margin-left: 1px !important; margin-right: 8px !important; margin-bottom: 6px !important; outline-color: rgb(140, 172, 26) !important; outline-width: 1px !important; visibility: visible !important; float: left !important;");
	//URLDLbox.id = "GMdownloadButton";
	var dlb1 = document.createElement("span");
	dlb1.className = "action-button-leftcap";
	dlb1.setAttribute("style", "vertical-align:baseline!important;");
	URLDLbox.appendChild(dlb1);
	var dlb2 = document.createElement("span");
	dlb2.className = "action-button-text";
	dlb2.textContent = "Download";
	dlb2.setAttribute("style", "vertical-align:baseline!important;");
	URLDLbox.appendChild(dlb2);
	var dlb3 = document.createElement("span");
	dlb3.className = "action-button-rightcap";
	dlb3.setAttribute("style", "vertical-align:baseline!important;");
	URLDLbox.appendChild(dlb3);
		//document.getElementById("upload-wrapper").parentNode.insertBefore(URLDLbox,document.getElementById("upload-button"));
		document.getElementById("masthead-nav-user").appendChild(URLDLbox);
}

function cleanArg(bb){
	bb = bb.split('"')[1].split('"')[0];
	return bb;
}

function procURLS(na) {
	na = cleanArg(na);
	na = unescape(na);
	nasp = na.split(/\|/);
	for (x=0;x<nasp.length;x++) {
		if (nasp[x].indexOf("http")!=-1) {
			if (nasp[x].indexOf(",")!=-1) {nasp[x] = nasp[x].split(/\,/)[0];}
			addBox(decodeURIComponent(nasp[x]));
		}
	}
}

function runIt(a1) {
	for (b3=0; b3<a1.length; b3++) {
		if (a1[b3].innerHTML.indexOf("swfArgs")!=-1||a1[b3].innerHTML.indexOf("CFG_SWF_ARGS")!=-1||a1[b3].innerHTML.indexOf("SWF_ARGS")!=-1) {
			if (a1[b3].innerHTML.indexOf("fmt_url_map")!=-1) {
				a2 = a1[b3].innerHTML.split('"fmt_url_map"')[1].split("}")[0];
				a2 = a2.split(",")[0];
				break;
			}
		}
	}
	
	if (a2!=""&&a2!=null) {
		procURLS(a2);
	} else {
		for (b3=0; b3<a1.length; b3++) {
		if (a1[b3].innerHTML.indexOf("fmt_url_map")!=-1) {
				a22 = a1[b3].innerHTML.split('"fmt_url_map"')[1].split("}")[0];
				a22 = a22.split(",")[0];
				procURLS(a22);
				break;
			}
		}
	}
}

if (scrhead!=null&&scrhead!="") {
	runIt(scrhead);
}