All pastes #993947 Raw Edit

Stuff

public text v1 · immutable
#993947 ·published 2008-04-23 00:05 UTC
rendered paste body
var videos = [
{ // YouTube
reLink : /^(http:\/\/(?:www\.)?youtube\.com\/)watch\?v=(\w+)/,
replaceString4link : '$1v/$2',
html4embed : function (flash_url) { return '<object width="425" height="350"> <param name="movie" value="'+ flash_url +'"></param> <param name="wmode" value="transparent"></param> <embed src="'+ flash_url +'" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"> </embed> </object>' }
},
{ // Google Video
reLink : /^(http:\/\/video\.google\.com\/)videoplay\?docid=(-?\d+)/,
replaceString4link : '$1googleplayer.swf?docId=$2',
html4embed : function (flash_url) { return '<embed style="width:425px; height:350px;" id="VideoPlayback" type="application/x-shockwave-flash" src="'+ flash_url +'"> </embed>' }
},
]; // end videos[]

function inlineVideo() {
// find links to video and insert corresponding flash video objects
var allas = document.getElementsByTagName('a');
for each(var a in allas) {
if (a.href) for each(var v in videos) {
if (a.href.match(v.reLink)) {
//GM_log(a.href);
objVideo = document.createElement('p');
objVideo.innerHTML = v.html4embed(a.href.replace(v.reLink, v.replaceString4link));
a.parentNode.insertBefore(objVideo, a.nextSibling); // insert after the link
break;
}
}
}
} // end inlineVideo()

window.addEventListener('load', inlineVideo, false);