-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
143 lines (131 loc) · 4.72 KB
/
script.js
File metadata and controls
143 lines (131 loc) · 4.72 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
Youtube Theater Fill Window v2.4
A script to make the theater mode in youtube videos better and big enough to cover the window. - Youtube videolarında tiyatro modunu daha iyi ve pencereyi kaplayacak şekilde büyük hale getirmek için bir script.
https://wolkanca.com/youtube-theater-mode-fix/
Volkan Yılmaz - wolkanca.com
*/
(function () {
'use strict';
let w = window,
d = document,
html = d.getElementsByTagName('html')[0],
V = new URL(document.location).searchParams.get('v'),
Tcount = 0;
const tiyatro = function () {
let V = new URL(d.location).searchParams.get('v'),
ytdapp = d.getElementsByTagName('ytd-app')[0],
ytdwatchflexy = d.getElementsByTagName('ytd-watch-flexy')[0],
wide = cookieStore.get('wide'),
F,
T,
D,
S,
L;
const toggle = function (e) {
if (e == '1') {
html.classList.add('tiyatro');
d.body.classList.add('no-scroll');
ytdapp.setAttribute('scrolling', ''),
ytdapp.setAttribute('masthead-hidden', ''),
ytdapp.setAttribute(
'style',
'--ytd-app-fullerscreen-scrollbar-width: 17px; --ytd-masthead-height: 0px; --ytd-network-status-banner-display: none;'
);
localStorage.setItem('theater', '1');
w.dispatchEvent(new Event('resize'));
//console.log('tiyatro');
} else {
if (!F) {
html.classList.remove('tiyatro');
d.body.classList.remove('no-scroll');
ytdapp.removeAttribute('scrolling', ''),
ytdapp.removeAttribute('masthead-hidden'),
ytdapp.removeAttribute('style');
}
localStorage.removeItem('theater');
//console.log('tiyatro değil');
}
};
if (V) {
if (ytdwatchflexy.hasAttribute('fullscreen')) {
F = true;
T = false;
D = false;
} else if (ytdwatchflexy.hasAttribute('theater')) {
F = false;
T = true;
D = false;
} else if (ytdwatchflexy.hasAttribute('default-layout')) {
F = false;
T = false;
D = true;
}
if (ytdwatchflexy.hasAttribute('flexy-large-window_')) {
L = true;
S = false;
} else if (ytdwatchflexy.hasAttribute('flexy-small-window_')) {
L = false;
S = true;
}
}
if (T && !F) {
toggle('1');
if (L) {
html.classList.add('l');
} else if (S) {
html.classList.add('s');
}
} else {
toggle('0');
T = false;
}
cookieStore.addEventListener('change', ({ changed }) => {
if (wide) {
for (let { name, value } of changed) {
if (value === '1') {
if (!F) {
toggle('1');
} else {
html.classList.remove('tiyatro');
}
} else if (value === '0') {
toggle('0');
}
}
}
});
w.addEventListener('fullscreenchange', function (e) {
if (d.fullscreenElement) {
localStorage.setItem('fullscreen', '1');
} else {
localStorage.removeItem('fullscreen');
if (localStorage.getItem('theater')) {
toggle('1');
} else {
toggle('0');
}
}
});
ytdapp.addEventListener('scroll', function () {
if (ytdapp.scrollTop == 0) {
ytdapp.setAttribute('masthead-hidden', '');
} else {
ytdapp.removeAttribute('masthead-hidden', '');
}
});
};
if (d.readyState === 'loading') {
d.addEventListener('DOMContentLoaded', tiyatro);
} else {
[w, d, html].map((e) =>
w.addEventListener('yt-navigate-finish', tiyatro)
);
}
let interval = setInterval(function () {
Tcount += 1;
if (Tcount > 0) {
clearInterval(interval);
}
tiyatro();
}, 2000);
})();