Source for "Google Video Download Linker"

By jk-
Has 35 other scripts.


// ==UserScript==
// @name           Google Video Download Linker
// @namespace      http://www.digivill.net/~joykillr
// @description    A working video download linker.  Gives a direct link on any google video page.
// @include        http://video.google.com/*
// @include        http://video.google.co.uk/*
// @include        http://video.google.ca/*
// @include        http://video.google.de/*
// ==/UserScript==

//v0.7 - google changed stuff
//v0.6 - better handing of capitalized I in docId
//0.5 - updated to work for not just video.google.com

var z, j = window.content.location.href.toString(), k = window.content.location.host.toString();

function getDat(x) {
	GM_xmlhttpRequest({
		method:"GET",
		url:x,
		headers:{
			"User-Agent":"Mozilla/5.0 Firefox/2.0.0.7",
			"Accept":"text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5",
		},
		onload:function(details) {
			var URLstring = new String(details.responseText);
			if (URLstring) {
				var l = isolate(URLstring);
				addDLLink(l);
				}
			
			}
		});
	}

function isolate(u){
	if (u.indexOf("insertFlashHtmlOnLoad")!=-1) {
		u = u.split("function\ insertFlashHtmlOnLoad\(\)")[1].split("\}")[0];
		if (u.indexOf("&videoUrl")!=-1) {
			u = u.split("\&videoUrl")[1].split("http")[1].split("http")[0];
		} else if (u.indexOf("videoUrl\\")!=-1) {
			u = u.split("videoUrl\\")[1].split("http")[1].split("http")[0];
		}
		if (u.indexOf("thumbnailUrl")!=-1) {
			var spt = u.indexOf("thumbnailUrl")-3;
			u = u.substring(0,spt);
			//alert(u);
		}
	}
	u = unescape(u);
	return u;
}

function parseL(j) {
	if (j.search("docid")!=-1) {z=j.split("docid=")[1].split("&")[0];}
	else if (j.search("docId")!=-1) {z=j.split("docId=")[1].split("&")[0];}
	return z;
}

function addDLLink(l) {
	var nn = document.createElement("div");
	nn.setAttribute("id","dlink");
	nn.innerHTML = '\<a\ href\=\"http'+l+'\"\ style=\"z-index:1000 !important; height: auto !important; font-size:14px!important; color:black!important; text-align:center!important; margin-left:auto!important; margin-right:auto!important; \"\>Direct\ Download\ Link\ \<\/a\>';
	nn.setAttribute("style", "font-size:14px!important;dispay:block!important;visibility:visible!important;height:16px!important;min-width:160px!important;color:white!important;background-color:yellow!important;width:100%!important;margin-left:auto!important;margin-right:auto!important;text-align:center!important;");
	document.body.insertBefore(nn,document.body.firstChild);
}
			
function run1(j,k) {
	z = parseL(j);
	if (z) {
		getDat("http\:\/\/"+k+"\/videohosted\?docid\="+z);
	}
}

if ((j.search("docid")!=-1)||(j.search("docId")!=-1)) {
	run1(j,k);
}