diff --git a/contrib/smjs/pornotube.js b/contrib/smjs/pornotube.js new file mode 100644 index 00000000..b3e50913 --- /dev/null +++ b/contrib/smjs/pornotube.js @@ -0,0 +1,30 @@ +/* Play videos at pornotube.com with minimal niggling. Just follow the link + * from the front page or the search page, and the video will automatically + * be loaded. */ + +function pornotube_callback(cached) { + var user_re = /\(\d+)\<\/user_id\>/; + var media_re = /\(\d+)\<\/media_id\>/; + + var user = cached.content.match(user_re)[1]; + var media = cached.content.match(media_re)[1]; + + var uri = "http://video.pornotube.com/" + user + "/" + media + ".flv"; + + elinks.location = uri; +} + +function load_pornotube(cached, vs) { + if (!cached.uri.match(/^http:\/\/(?:www\.)?pornotube\.com\/media\.php/)) + return true; + + var re = /SWFObject\("player\/v\.swf\?v=(.*?)"/; + var hash = cached.content.match(re)[1]; + + var uri = "http://www.pornotube.com/player/player.php?" + hash; + + elinks.load_uri(uri, pornotube_callback); + + return true; +} +elinks.preformat_html_hooks.push(load_pornotube); diff --git a/contrib/smjs/youtube.js b/contrib/smjs/youtube.js new file mode 100644 index 00000000..c81db88d --- /dev/null +++ b/contrib/smjs/youtube.js @@ -0,0 +1,27 @@ +/* Play videos at YouTube with minimal niggling. Just load the page for a video, + * and the video will automatically be loaded. */ +function load_youtube(cached, vs) { + if (!cached.uri.match(/http:\/\/(?:www\.)?youtube\.com\/(?:watch(?:\.php)?)?\?v=(?:[^&]+).*/)) + return true; + + var params_match = cached.content.match(/player2\.swf\?([^"]+)"/); + if (!params_match) return true; + + var url = 'http://www.youtube.com/get_video?' + params_match[1]; + var meta = ''; + + cached.content = cached.content.replace(//, "" + meta); + + return true; +} +elinks.preformat_html_hooks.push(load_youtube); + +/* When one tries to follow a link to , + * redirect to , which has the information + * that is necessary to get the actual video file. */ +function redirect_embedded_youtube(uri) { + var uri_match = uri.match(/http:\/\/(?:www\.)?youtube\.com\/v\/([^&]+).*/); + if (!uri_match) return true; + return 'http://www.youtube.com/watch?v=' + uri_match[1]; +} +elinks.follow_url_hooks.push(redirect_embedded_youtube);