-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
310 lines (291 loc) · 12.2 KB
/
index.html
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>AJ's Live Sub Count</title>
<script src="./odometer.js"></script>
<link rel="stylesheet" href="./odometer.css">
<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon">
<style>
body {
background-color: #121212;
color: #FFF;
font-family: Roboto;
font-size: 2vw;
margin: 0;
}
.grid {
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr 1fr;
grid-gap: 10px;
height: 100%;
}
iframe {
width: 100%;
height: 100%;
border: none;
}
.banner {
width: 100%;
height: 10vw;
object-fit: cover;
filter: blur(10px);
}
.avatar {
width: 10vw;
height: 10vw;
object-fit: cover;
border-radius: 50%;
position: absolute;
border: 0.5vw solid white;
margin-left: -30vw;
}
h2 {
margin-top: 0;
margin-bottom: 0;
}
.name {
font-size: 3vw;
margin-bottom: 0;
margin-top: 0.5vw;
}
.subs {
font-size: 6vw;
margin-top: 0;
margin-bottom: 0.5vw;
}
.counter {
border: 0.5vw solid white;
}
.footer {
margin-top: 0vw;
margin-bottom: 0.5vw;
font-size: 2vw;
}
input,
select,
option {
font-size: 1.4vw;
width: 70%;
}
input[type=checkbox] {
transform: scale(2);
}
button {
font-size: 1.4vw;
}
</style>
</head>
<body>
<div class="grid">
<div>
<center>
<h2>Currently Tracking</h2>
</center>
<hr>
<div class="counter">
<img class="banner" src="/default.png">
<img class="avatar" src="/default.png">
<center>
<h1 class="name">Loading</h1>
<h1 class="subs odometer">000,000,000</h1>
<h2 class="footer">Subscribers</h2>
</center>
</div>
</div>
<div>
<div style="display: flex; gap: 5vw;">
<h2>Settings</h2>
<button id="save" onclick="save()">Save</button>
</div>
<hr>
<label>Channel ID: </label><input type="text" id="ID" autocomplete="off">
<br>
<label>API Source: </label>
<select id="API" autocomplete="off">
<option value="mixerno">Mixerno.space</option>
<option value="xyz">Livecounts.xyz</option>
<option value="axern">Axern.space</option>
<option value="raw">YouTube.com</option>
</select>
<br>
<label autocomplete="off" id="intervalLabel">Update Interval: 5 </label><input type="range" id="interval"
min="1" max="60" value="2" placeholder="2"><br>
<label>Auto Update: </label><input autocomplete="off" type="checkbox" id="autoUpdate" checked
style="margin-left: 0vw;">
<br>
<hr>
<label>Color: </label><input autocomplete="off" type="color" id="color" value="#FF0000"><br><br>
<label>or Gradient</label><input type="checkbox" id="gradientCheck"></input>
<select id="gradientType">
<option>Static</option>
<option>Dynamic</option>
</select><br>
<label>Rainbow</label>
<input type="checkbox" id="rainbow" onclick="rainbow()"></input>
<div id="gradient">
<input type="color" class="color" value="#FF0000">
<input type="color" class="color" value="#0000FF">
<button onclick="addColor()">Add Color</button>
</div>
<br>
<hr>
<h2>Change Channel</h2>
<hr>
<input type="text" autocomplete="off" id="search" placeholder="Search"><button id="searchButton"
onclick="search()">Search</button>
<br>
<div id="results"></div>
</div>
</div>
<script>
let ids = ["", ""]
let id = ""
function addColor() {
document.getElementById('gradient').innerHTML += '<input type="color" class="color" value="#000000">';
}
function save() {
if (id == "") {
alert('Please select a channel first!');
}
let colors = [];
document.querySelectorAll('.color').forEach(color => {
colors.push(color.value);
})
if (document.getElementById('gradientCheck').checked) {
if (document.getElementById('gradientType').value == "Static") {
document.getElementById('color').value = "linear-gradient(90deg, " + colors.join(", ") + ")";
} else {
document.getElementById('color').value = "linear-gradient(90deg, " + colors.join(", ") + ")";
document.getElementById('rainbow').checked = true;
}
}
fetch('/save', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
id: id,
api: document.getElementById('API').value,
interval: document.getElementById('interval').value,
autoUpdate: document.getElementById('autoUpdate').checked,
color: document.getElementById('color').value
})
}).then(res => res.json())
.then(data => {
document.getElementById('ID').value = id;
if (data.status == 'ok') {
alert('Saved!');
} else {
alert('Error!');
}
})
}
function search() {
fetch('/search', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
search: document.getElementById('search').value
})
})
.then(res => res.json())
.then(data => {
if (data.length == 0) {
alert('No results found!');
}
document.getElementById('results').innerHTML = '';
data.forEach(channel => {
document.getElementById('results').innerHTML += `<div cid="${channel.id}" style="display: flex; gap: 5vw;"><img src="${channel.pfp}" style="width: 10vw; height: 10vw; object-fit: cover; border-radius: 50%;"><div><h2>${channel.name}</h2><h2 style="font-size: 2vw;">${channel.mainCount}</h2><button style="font-size: 3vw;" onclick="changeChannel('${channel.id}')">Change</button></div></div><hr>`;
})
})
}
function changeChannel(cid) {
if ((ids[1]) && (ids[1].style)) {
ids[1].style.border = 'none';
}
ids[0] = cid;
id = cid;
ids[1] = document.querySelectorAll('[cid="' + cid + '"]')[0]
ids[1].style.border = '0.5vw solid white';
}
document.getElementById('interval').oninput = function () {
document.getElementById('intervalLabel').innerHTML = 'Update Interval: ' + this.value;
}
let user = {}
function getStats() {
fetch('/user')
.then(res => res.json())
.then(data => {
if (user.snippet == undefined) {
user = data;
document.querySelector('.avatar').src = data.snippet.thumbnails.high.url;
document.querySelector('.name').innerHTML = data.snippet.title;
document.querySelector('.banner').src = data.brandingSettings.image.bannerImageUrl;
if (data.path == "counts[0]") {
document.querySelector('.subs').innerHTML = data.counts[0];
} else if (data.path == "counts[0].count") {
document.querySelector('.subs').innerHTML = data.counts[0].count;
} else if (data.path == "items[0].statistics.subscriberCount") {
document.querySelector('.subs').innerHTML = data.items[0].statistics.subscriberCount;
} else {
document.querySelector('.subs').innerHTML = data[data.path];
}
}
if (user.snippet.thumbnails.high.url != data.snippet.thumbnails.high.url) {
document.querySelector('.avatar').src = data.snippet.thumbnails.high.url;
}
if (user.snippet.title != data.snippet.title) {
document.querySelector('.name').innerHTML = data.snippet.title;
}
if (user[user.path] != data[data.path]) {
if (data.path == "counts[0]") {
document.querySelector('.subs').innerHTML = data.counts[0];
} else if (data.path == "counts[0].count") {
document.querySelector('.subs').innerHTML = data.counts[0].count;
} else if (data.path == "items[0].statistics.subscriberCount") {
document.querySelector('.subs').innerHTML = data.items[0].statistics.subscriberCount;
} else {
document.querySelector('.subs').innerHTML = data[data.path];
}
}
if (user.brandingSettings.image.bannerImagebannerExternalUrlUrl != data.brandingSettings.image.bannerExternalUrl) {
document.querySelector('.banner').src = data.brandingSettings.image.bannerExternalUrl;
}
user = data;
})
}
getStats();
setInterval(() => {
getStats();
}, 2000);
function settings() {
fetch('/settings')
.then(res => res.json())
.then(data => {
id = data.id;
if (data.api == "https://axern.space/api/get?platform=youtube&type=channel&id=") {
data.api = "axern";
} else if (data.api == "https://mixerno.space/api/youtube-channel-counter/user/") {
data.api = "mixerno";
} else if (data.api == "https://livecounts.xyz/api/youtube-live-subscriber-count/live/") {
data.api = "xyz";
} else if (data.api == "https://yt.lemnoslife.com/noKey/channels?part=snippet,statistics&id=") {
data.api = "raw";
}
document.getElementById('ID').value = data.id;
document.getElementById('API').value = data.api;
document.getElementById('interval').value = data.interval;
document.getElementById('autoUpdate').checked = data.autoUpdate;
document.getElementById('color').value = data.color;
document.getElementById('intervalLabel').innerHTML = 'Update Interval: ' + data.interval;
})
}
settings();
</script>
</body>
</html>