mirror of
https://github.com/rkd77/elinks.git
synced 2025-01-03 14:57:44 -05:00
SMJS: Add scripts for YouTube and PornoTube
This commit is contained in:
parent
f22dbfb6f5
commit
c884123d53
30
contrib/smjs/pornotube.js
Normal file
30
contrib/smjs/pornotube.js
Normal file
@ -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 = /\<user_id\>(\d+)\<\/user_id\>/;
|
||||
var media_re = /\<media_id\>(\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);
|
27
contrib/smjs/youtube.js
Normal file
27
contrib/smjs/youtube.js
Normal file
@ -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 = '<meta http-equiv="refresh" content="1; url=' + url + '" />';
|
||||
|
||||
cached.content = cached.content.replace(/<head>/, "<head>" + meta);
|
||||
|
||||
return true;
|
||||
}
|
||||
elinks.preformat_html_hooks.push(load_youtube);
|
||||
|
||||
/* When one tries to follow a link to <http://www.youtube.com/v/foo>,
|
||||
* redirect to <http://www.youtube.com/watch?v=foo>, 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);
|
Loading…
Reference in New Issue
Block a user