Add facilities for querying information about installed extensions
[conkeror.git] / modules / page-modes / youporn.js
blob96891413cd7d85e84c21ab8365947dbf88da9cf1
1 require("content-buffer.js");
2 require("media.js");
4 const media_youporn_title_regexp = /^.*? - (.*)$/;
5 const media_youporn_flv_regexp = /var player_url = '(.*?)';/;
7 function media_scrape_youporn(buffer) {
8     try {
9         var doc = buffer.document;
11         var title = doc.title;
12         var usable_title_res = media_youporn_title_regexp.exec(title);
13         var usable_title = usable_title_res[0];
15         let text = doc.documentElement.innerHTML;
16         let res = media_youporn_flv_regexp.exec(text);
18         if (res) {
19             return [load_spec({uri: res[1],
20                                suggest_filename_from_uri: false,
21                                title: usable_title,
22                                filename_extension: "flv",
23                                source_frame: buffer.top_frame,
24                                mime_type: "video/x-flv"})];
25             }
26     } catch (e if !(e instanceof interactive_error)) {}
27     return null;
30 define_page_mode("youporn_mode", "YouPorn", $enable = function (buffer) {
31     buffer.local_variables.media_scraper = media_scrape_youporn;
32     media_setup_local_object_classes(buffer);
33 });
35 auto_mode_list.push([/^http:\/\/youporn\.com\//, youporn_mode]);