1 /* Play videos at YouTube with minimal niggling. Just load the page for a video,
2 * and the video will automatically be loaded. */
3 function load_youtube(cached
, vs
) {
4 var par
= cached
.uri
.match(/http:\/\/\w+\.youtube\.com\/watch\?v=([^&]+).*/);
7 var t
= cached
.content
.match(/, \"t\": \"([^"]+)\"/);
10 var url
= 'http://uk.youtube.com/get_video?video_id=' + par
[1] + '&t=' + t
[1];
12 cached
.content
= '<a href="' + url
+ '">View</a>';
16 elinks
.preformat_html_hooks
.push(load_youtube
);
18 /* When one tries to follow a link to <http://www.youtube.com/v/foo>,
19 * redirect to <http://www.youtube.com/watch?v=foo>, which has the information
20 * that is necessary to get the actual video file. */
21 function redirect_embedded_youtube(uri
) {
22 var uri_match
= uri
.match(/http:\/\/\w+\.youtube\.com\/v\/([^&]+).*/);
26 return 'http://uk.youtube.com/watch?v=' + uri_match
[1];
28 elinks
.follow_url_hooks
.push(redirect_embedded_youtube
);