There are 32 previous versions of this script.
// ==UserScript==
// @name Free Youtube!
// @author Stephen Paul Weber
// @namespace http://singpolyma.net/
// @version 1.9.5
// @description Install and then use YouTube as normal, only without the flash. Plays videos with your local FLV-capable media player (VLC reccomended). Some support for embed codes and other sites (Vimeo, Google Video, blip.tv, academicearth.org, lastampa.it).
// @include http://*.youtube.com/watch*
// @include http://*.vimeo.com/*
// @include http://*blip.tv/*
// @include http://video.google.com/videoplay*
// @include http://academicearth.org/lectures/*
// @include *
// ==/UserScript==
if(typeof(unsafeWindow) == 'undefined') {
this.unsafeWindow = window;
}
toremove = [];
lock = false;
function videoReplaceHTML(videourl, type) {
if(!type) type = 'video/flv';
return'<object type="'+type+'" data="'+videourl+'" width="500" height="400"><param name="autoplay" value="false" /><param name="autoStart" value="0" /><param name="src" value="'+videourl+'" />Your browser doesn\'t seem to support this video, please use the download link below.</object>'
+ '<a type="'+type+'" style="display:block;text-align:center;font-size:2em;margin:1em;" href="'+videourl+'" rel="enclosure">Download</a>';
}
function embedLink(node, linkurl) {
var link = document.createElement('a');
link.href = linkurl;
link.rel = 'enclosure';
link.style.display = 'block';
link.style.padding = '1em';
link.style.border = '1px solid black';
link.style.textAlign = 'center';
link.style.maxWidth = '25em';
link.innerHTML = 'Click for video';
node.parentNode.insertBefore(link, node);
toremove.push(node);
}
function embed_codes(objects) {
for(var i = 0; i < objects.length; i++) {
var linkurl = false;
var data = objects[i].src || objects[i].data;
var ytid = data.match(/youtube\.com\/v\/([^\&]+)/);
var vimeoid = data.match(/vimeo\.com\/[^\?]+\?clip_id=([^\&]+)/);
var blipid = data.match(/blip\.tv\/play\/.+$/);
var wpid = data.match(/v\.wordpress\.com\/([^\/\&?#]+)/);
var flowplayer = data.match(/flowplayer/);
if(objects[i].parentNode.nodeName == "OBJECT")
var o = objects[i].parentNode;
else
var o = objects[i];
if(ytid && ytid[1]) {
ytid = ytid[1];
linkurl = 'http://youtube.com/watch?v=' + ytid;
} else if(vimeoid && vimeoid[1]) {
vimeoid = vimeoid[1];
linkurl = 'http://vimeo.com/' + vimeoid;
} else if(blipid) {
GM_xmlhttpRequest({
method: 'GET',
url: objects[i].src,
onload: function(responseDetails) {
GM_xmlhttpRequest({
method: 'GET',
url: unescape(responseDetails.finalUrl.match(/file=([^\&]+)\&/)[1]),
onload: function(responseInner) {
linkurl = responseInner.responseText.match(/<item>[^\f]+<link>(.+)<\/link>/)[1];
embedLink(o, linkurl);
o.parentNode.removeChild(o);
}
});
}
});
} else if(flowplayer) {
var config = eval('(' + objects[i].getAttribute('flashvars').match(/^config=(\{.+\})$/)[1] + ')');
var div = document.createElement('div');
div.innerHTML = videoReplaceHTML(config.playlist[1].url, 'video/mp4');
o.parentNode.insertBefore(div, o);
toremove.push(o);
} else if(wpid) {
GM_xmlhttpRequest({
method: 'GET',
url: 'http://v.wordpress.com/wp-content/plugins/video/video-xml.php?guid=' + wpid[1],
onload: function(responseDetails) {
var videourl = responseDetails.responseText.match(/movie_file>([^<]+)</)[1];
o.innerHTML = videoReplaceHTML(videourl);
}
});
} else if(o.getAttribute('flashvars')) {
var videourl = o.getAttribute('flashvars').match(/file=(.+)/)[1];
if(videourl) {
var div = document.createElement('div');
div.innerHTML = videoReplaceHTML(videourl);
o.parentNode.insertBefore(div, o);
toremove.push(o);
}
}
if(linkurl) {
embedLink(o, linkurl);
}
}
}
function init() {
if(lock) return;
lock = true;
/* YOUTUBE */
if(window.location.href.match(/youtube.com\/watch/)) {
var videourl = 'http://youtube.com/get_video.php?';
swfArgs = unsafeWindow.yt.config_.SWF_ARGS;
swfArgs['vq'] = '2'; /* use higher quality */
swfArgs['fmt'] = (unsafeWindow.yt.config_.IS_HD_AVAILABLE?'22':'18'); /* use higher quality */
for(var i in ['fmt','video_id','vq','t']) {
i = ['fmt','video_id','vq','t'][i];
videourl += '&' + i + '=' + swfArgs[i];
}
document.getElementById('watch-player-div').innerHTML = videoReplaceHTML(videourl, 'video/mp4');
/* GOOGLE VIDEO */
} else if (window.location.href.match(/video.google.com\/videoplay/)) {
var videourl = unescape(document.getElementById('VideoPlayback').src.match(/videoUrl=(.+)$/)[1]);
document.getElementById('player').innerHTML = videoReplaceHTML(videourl);
/* VIMEO */
} else if (window.location.href.match(/vimeo.com\/\d+\/?$/)) {
var vimeoid = window.location.href.match(/vimeo.com\/(\d+)\/?$/)[1];
GM_xmlhttpRequest({
method: 'GET',
url: 'http://www.vimeo.com/moogaloop/load/clip:' + vimeoid,
onload: function(responseDetails) {
var request_signature = responseDetails.responseText.match(/request_signature>([^<]+)</)[1];
var request_signature_expires = responseDetails.responseText.match(/request_signature_expires>([^<]+)</)[1];
var videourl = 'http://www.vimeo.com/moogaloop/play/clip:' + vimeoid + '/' + request_signature + '/' + request_signature_expires + '/?q=sd';
document.getElementById('vimeo_player_' + vimeoid).innerHTML = videoReplaceHTML(videourl);
}
});
/* BLIP.TV */
} else if(window.location.href.match(/blip\.tv\/file\/\d+\/?$/)) {
var videourl = '';
for(var i in unsafeWindow.ATOf['attributes']) {
if(unsafeWindow.ATOf['attributes'][i]['attribute'].match(/\.flv$/)) {
videourl = unsafeWindow.ATOf['attributes'][i]['attribute'];
}
}
document.getElementById('video_player').innerHTML = videoReplaceHTML(videourl);
} else if(window.location.href.match(/viddler\.com\/.+\/videos\/\d+/)) {
var videourl = window.location.href.replace(/\/?$/,'.flv')
document.getElementById('flashcontent').innerHTML = videoReplaceHTML(videourl);
/* ACADEMICEARTH.COM */
} else if(window.location.href.match(/academicearth.org\/lectures\/.*$/)) {
var videourl = unsafeWindow.flashVars.flvURL;
var div = document.createElement('div');
div.innerHTML = videoReplaceHTML(videourl);
document.getElementById('video-player').parentNode.insertBefore(div, document.getElementById('video-player'));
document.getElementById('video-player').parentNode.removeChild(document.getElementById('video-player'));
/* LASTAMPA.IT */
/* Code by Iron Bishop */
} else if (window.location.href.match(/lastampa\.it\/multimedia/)) {
var videourl = unescape(document.getElementById('VideoPlayer1').innerHTML.match(/.*x-mplayer2.*url=(.+)wmv/)[1]) + "wmv";
document.getElementById('VideoPlayer1').innerHTML = videoReplaceHTML(videourl);
/* EMBED CODES */
} else {
unsafeWindow.addEventListener('DOMNodeInserted', init, false);
embed_codes(document.getElementsByTagName('embed'));
embed_codes(document.getElementsByTagName('object'));
for(var i in toremove) {
toremove[i].parentNode.removeChild(toremove[i]);
}
toremove = [];
}
lock = false;
}
// We really do want it to run twice if necessary.
init();
unsafeWindow.addEventListener('load', init, false);
