DailyMotion Video Download Linker

By jk- Last update Jul 5, 2010 — Installed 7,862 times.

There are 4 previous versions of this script.

// ==UserScript==
// @name         dailymotion.com video download link
// @namespace     http://www.digivill.net/~joykillr
// @description   Adds download links for multiple formats to dailymotion.com so videos can be downloaded.  Works with and without javascript.
// @include        http://*.dailymotion.com/*
// @include        http://dailymotion.com/*
// ==/UserScript==
//
//v 2.1

var boo, tID, yz;
function addBox(strR,typ) {
	var detdsc = strR.match(/\d{1,4}x\d{1,4}/gi);
	if (strR.match(/\.flv/gi)) {detcdc = "FLV"} else if (strR.match(/\.on2/gi)) {detcdc = "ON2"} else if (strR.match(/\.mp4/gi)) {detcdc = "MP4"} else {detcdc = ""}
	if (typ&&typ!="") {detcdc = typ+"\ "+detcdc;}
	var URLDLbox = document.createElement("div");
	URLDLbox.setAttribute("style", "z-index:10000 !important; display: block !important;");
	URLDLbox.innerHTML = '<br /><table style="width:auto; margin-left: auto; margin-right:auto;"><tbody style="background-color:inherit!important;">' +
		'<tr style="background-color:inherit!important;">' +
		'<td style="text-align:center;background-color:inherit!important;">' +
		'<a href="' + strR + '" style="display: block; z-index:10001 !important; font-size:108%; line-height:108%; color: #ffffff; background-color: #222222; border: 2px solid #7f7ebe; margin-left: auto; margin-right:auto; text-align:center; font-weight:bold;">Download ' + detdsc + ' ' + detcdc + ' Video </a>' + 
		'<br /></td></tr></tbody></table>';
	boo = true;
	//alert(URLDLbox);
	var nElem = document.getElementsByTagName("div");
	for (var nn = 0; nn < nElem.length; nn++) {
	if (document.getElementById("right_content_box")) {document.getElementById("right_content_box").appendChild(URLDLbox);}
		else {
		if (nElem[nn].getAttribute("class")){
		if (nElem[nn].getAttribute("class").match(/dm_widget_videoplayer/i)) {
			nElem[nn].insertBefore(URLDLbox,nElem[nn].lastChild);
		} else if (nElem[nn].getAttribute("class").indexOf("video_player")!=-1) {
			nElem[nn].insertBefore(URLDLbox,nElem[nn].lastChild);
		} else if (nElem[nn].getAttribute("class").indexOf("videoplayer")!=-1) {
			nElem[nn].insertBefore(URLDLbox,nElem[nn].lastChild);
		}}
		}
	}
}

boo = false;	
function altMeth(){
	var tID = "";
	tID = document.body.innerHTML.toString();
	if (tID&&tID!=""&&tID.indexOf("flashvars")!=-1) {
			yz = tID.split("flashvars")[1].split("\>")[0];
			if (yz.split('value\=\"')[1]) { yz = yz.split('value\=\"')[1];}
			if (yz.split('\&nextURL\=')[1]) {
				yz3 = yz.split('\&nextURL\=')[1].split('\"')[0];
				if (yz3!="" && yz3!=null) {yz3 = yz3.split('&url\=')[1].split('\&allowZoom\=')[0]; }
				yz3 = unescape(yz3);
				addBox(yz3);
			} else {
				yz = unescape(yz);
				if (zy.split("&video=")[1]) {zy = zy.split("&video=")[1].split("&")[0];}
				vrdo(yz);
			}
		}
	}

function vrdo(zy) {
	var n12 = zy.indexOf("http");
	if (n12!=0) {n12 = n12 - 1;
		n12 = zy.charAt(n12);
		zy = zy.split(n12)[1].split(n12)[0];
		}
	if (zy.indexOf("||")!=-1) {yzArray = zy.split("||");
	for (myAx = 0; myAx < yzArray.length; myAx++) {
		//addBox(yzArray[myAx].split("@@")[0],yzArray[myAx].split("@@")[1]);
		if (yzArray[myAx].indexOf("@@")!=-1) {
			var zx = yzArray[myAx].split("@@");
			addBox(zx[0],zx[1]);
		} else {addBox(yzArray[myAx]);} 
		}
	} else {addBox(zy);}
}

function newdo(zzy) {
if (zzy.indexOf('"sdURL":')!=-1) {
	var sdurl = zzy.split('"sdURL":')[1].split('"')[1].split('"')[0].toString(); 
	sdurl = sdurl.replace(/\\/gmi,"");
	addBox(sdurl,"SD");}
if (zzy.indexOf('"hqURL":')!=-1) {
	var hqurl = zzy.split('"hqURL":')[1].split('"')[1].split('"')[0].toString();
	hqurl = hqurl.replace(/\\/gmi,"");
	addBox(hqurl,"HQ");}
}
	
if (document.body.getElementsByTagName("script")) {
	var n10 = document.body.getElementsByTagName("script");
	for (var yy = 0; yy<n10.length; yy++){
		if (n10&&n10[yy].innerHTML) {
			var n11 = n10[yy].innerHTML.toString();
			if ((n11&&n11.indexOf('addVariable(\"sequence\"')!=-1)&&n11.indexOf("GMdownloadButton")==-1) {
				yz = n11.split('addVariable(\"sequence\"')[1].split("\)\;")[0];
				yz = unescape(yz);
				newdo(yz.toString());
			} else if ((n11&&n11.indexOf('addVariable(\"video\"')!=-1)&&n11.indexOf("GMdownloadButton")==-1) {
				yz = n11.split('addVariable(\"video\"')[1].split("\)\;")[0];
				yz = unescape(yz);
				vrdo(yz);
			} 
		} else if (boo==false&&yy+1==n10.length) {altMeth();}
	}
} else if (boo==false) {altMeth();}