window.js: Ensure that window_initialize_late_hook is run before other "late" hooks
[conkeror.git] / modules / page-modes / youtube-player.js
blob5ec130d4de2f05fbe13fcbf084b4a3c4ef735b5b
1 /**
2  * (C) Copyright 2012 Scott Jaderholm
3  *
4  * Use, modification, and distribution are subject to the terms specified in the
5  * COPYING file.
6 **/
8 require("content-buffer.js");
10 define_keymap("youtube_player_keymap", $display_name = "youtube-player");
12 function youtube_player_click_command (selector, error_message) {
13     return function (I) {
14         var buf = I.buffer;
15         var elem = buf.document.querySelector(selector);
16         if (elem)
17             dom_node_click(elem, 1, 1);
18         else
19             I.minibuffer.message(error_message + ", ensure html5 is enabled for youtube by visiting http://youtube.com/html5");
20     };
23 interactive("youtube-player-play-or-pause",
24     "Click the Youtube html5 player play/pause button.",
25     youtube_player_click_command("button.html5-pause-button, button.html5-play-button",
26                                  "No play or pause button found"));
28 interactive("youtube-player-mute",
29     "Click the Youtube html5 player mute button.",
30     youtube_player_click_command("button.html5-volume-button",
31                                  "No mute button found"));
33 interactive("youtube-player-fullscreen",
34     "Click the Youtube html5 player fullscreen button.",
35     youtube_player_click_command("button.html5-fullscreen-button",
36                                  "No fullscreen button found"));
38 define_key(youtube_player_keymap, "C-c return", "youtube-player-play-or-pause");
39 define_key(youtube_player_keymap, "C-c C-m", "youtube-player-mute");
40 define_key(youtube_player_keymap, "C-c C-f", "youtube-player-fullscreen");
42 define_keymaps_page_mode("youtube-player-mode",
43     build_url_regexp($domain = "youtube", $allow_www = true),
44     { normal: youtube_player_keymap },
45     $display_name = "Youtube-Player");
47 page_mode_activate(youtube_player_mode);
49 provide("youtube-player");