-
Notifications
You must be signed in to change notification settings - Fork 10
/
focus.js
47 lines (43 loc) · 1.61 KB
/
focus.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
$ = (queryString) => document.querySelector(queryString);
refresh();
function refresh() {
browser.storage.local.get("focustube")
.then(function (settings) {
console.debug('existing: ' + JSON.stringify(settings));
if (settings.focustube.focus) {
focus();
} else {
reset();
}
}, function (error) {
console.debug('error: ' + JSON.stringify(error));
});
}
function focus() {
// fix player itself
const playerElem = $('.html5-video-player');
playerElem.style.position = 'fixed';
playerElem.style.height = '52vh'; // 3:2
playerElem.style.width = '78vh';
playerElem.style.left = '15px';
playerElem.style.top = '75px';
playerElem.style.zIndex = '999';
// update background also
const playerContainerElem = $('#player-container-outer');
playerContainerElem.style.height = playerElem.style.height;
playerContainerElem.style.width = playerElem.style.width;
playerContainerElem.style.setProperty('background-color', 'black');
}
function reset() {
const playerElem = $('.html5-video-player');
playerElem.style.position = 'relative';
playerElem.style.height = '100%';
playerElem.style.width = '100%';
playerElem.style.left = '0px';
playerElem.style.top = '0px';
playerElem.style.zIndex = 'auto';
const playerContainerElem = $('#player-container-outer');
playerContainerElem.style.height = playerElem.style.height;
playerContainerElem.style.width = playerElem.style.width;
playerContainerElem.style.setProperty('background-color', 'white');
}