forked from uky/greasemonkey
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyt-html5_enlarge.user.js
79 lines (59 loc) · 2.08 KB
/
yt-html5_enlarge.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// ==UserScript==
// @name YouTube HTML5 Video Maximizer
// @namespace http://github.com/uky/greasemonkey
// @description Stretches the video to fit the size of the browser window.
// @version 0.1.1
// @author Uky
// @match http://www.youtube.com/watch?*
// ==/UserScript==
// [ Constants ]
var base_ID = 'baseDiv';
var header_ID = 'watch-vid-title';
var player_ID = 'video-player';
var container_class = 'video-content';
var video_class = 'video-stream';
var controls_class = 'video-controls';
// Get elements:
var base = document.getElementById(base_ID);
var header = document.getElementById(header_ID);
var player = document.getElementById(player_ID);
var container = player.getElementsByClassName(container_class)[0];
var controls = player.getElementsByClassName(controls_class)[0];
var header_height = header.offsetHeight;
var controls_height = controls.offsetHeight;
header.scrollIntoView(true);
var video = document.getElementsByClassName(video_class)[0];
// Wait for <video> to be inserted before acting:
function get_video(event) {
if (event.target.className != video_class)
return;
video = event.target;
resize();
}
if (!video) {
document.addEventListener('DOMNodeInserted', get_video, false);
}
else {
resize();
}
// Resize video player to fit window:
function resize() {
if (!video)
return;
var win_height = document.body.offsetHeight;
var win_width = document.body.offsetWidth;
var player_width = win_width + "px";
var player_height = (win_height - header_height - 5) + "px";
var video_height = (win_height - header_height - controls_height - 5) + "px";
base.style.marginLeft = 0;
base.style.paddingLeft = 0;
player.style.width = player_width;
player.style.height = player_height
container.style.width = player_width;
container.style.height = video_height;
controls.style.width = player_width;
video.style.width = player_width;
video.style.height = video_height;
header.scrollIntoView(true);
}
window.addEventListener('resize', resize, false);