-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
69 lines (58 loc) · 2.04 KB
/
index.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
(() => {
let log = (message) => 'FloatPlaneMeta: ' + message
let fpmFactory = () => {
class FloatPlaneMeta {
constructor(){
this.theaterMode = false
this.newPadding = '0px'
this.newMaxWidth = 'none'
this.newDisplay = 'none'
this.retrieveElements()
this.retrieveOriginalStyles()
}
toggleTheaterMode() {
if (this.theaterMode) {
this.leaveTheaterMode()
} else {
this.enterTheaterMode()
}
}
getOriginalStyle(el, style) {
return el.computedStyleMap().get(style).value + (el.computedStyleMap().get(style).unit || '')
}
retrieveElements() {
this.pageWrapper = document.getElementsByClassName("page-wrapper")[0]
this.leftNav = document.getElementsByTagName("leftnav")[0]
this.vidContainer = document
.getElementsByClassName("video-player-wrapper")[0]
.getElementsByClassName("video-player-container")[0]
}
retrieveOriginalStyles() {
this.originalPadding = this.getOriginalStyle(this.pageWrapper, 'padding-left')
this.originalMaxWidth = this.getOriginalStyle(this.vidContainer, 'max-width')
this.originalDisplay = this.getOriginalStyle(this.leftNav, 'display')
}
enterTheaterMode() {
log('entering theater mode')
this.pageWrapper.style.paddingLeft = this.newPadding
this.vidContainer.style.maxWidth = this.newMaxWidth
this.leftNav.style.display = this.newDisplay
this.theaterMode = true
}
leaveTheaterMode() {
log('leaving theater mode')
this.pageWrapper.style.paddingLeft = this.originalPadding
this.vidContainer.style.maxWidth = this.originalMaxWidth
this.leftNav.style.display = this.originalDisplay
this.theaterMode = false
}
}
return new FloatPlaneMeta()
}
if (!window.floatPlaneMeta) {
log('initializing... ⏳')
window.floatPlaneMeta = fpmFactory()
log('ready! ✅')
}
window.floatPlaneMeta.toggleTheaterMode()
})()