This repository was archived by the owner on Mar 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
94 lines (85 loc) · 2.92 KB
/
Copy pathscript.js
File metadata and controls
94 lines (85 loc) · 2.92 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
function GetGoal(count2) {
var count = parseFloat(count2);
var t = parseFloat(count2);
if (count == null) return 0;
if (10 > t) return 10 - t;
var e = "" + t;
return Math.abs(
t -
(e.length > 6
? 1e6 * (Math.floor(t / 1e6) + 1)
: (parseInt(e.charAt(0)) + 1) * Math.pow(10, e.length - 1))
);
}
function GetGoal2(count2) {
var count = parseFloat(count2);
var t = parseFloat(count2);
if (count == null) return 0;
if (10 > t) return 10;
var e = "" + t;
return e.length > 6
? 1e6 * (Math.floor(t / 1e6) + 1)
: (parseInt(e.charAt(0)) + 1) * Math.pow(10, e.length - 1);
}
function GetGoalText(t) {
return ("" + t).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
const params = new URLSearchParams(window.location.search);
const id = params.get("id") || "UCX6OQ3DkcsbYNE6H8uQQuVA";
document.getElementById("imageLink").href = `https://youtube.com/channel/${id}`;
document.getElementById(
"subscribeBtn"
).href = `https://youtube.com/channel/${id}?sub_confirmation=1`;
setInterval(() => {
fetch(`https://axern.space/api/get?platform=youtube&type=channel&id=${id}`)
.then((res) => res.json())
.then((data) => {
document.getElementById("name").textContent = data.snippet.title;
document.querySelector(
'[data-icon="zondicons:checkmark"]'
).style.display = data.isStudio ? "block" : "none";
const image = document.getElementById("image");
image.src =
data.snippet.thumbnails.high.url ||
data.snippet.thumbnails.medium.url ||
data.snippet.thumbnails.default.url;
image.alt = data.snippet.title;
document.getElementById("subscribers").innerHTML = data.estSubCount;
document.getElementById("goal").innerHTML = GetGoal(data.estSubCount);
document.getElementById(
"goalText"
).textContent = `subscribers to ${GetGoalText(
GetGoal2(data.estSubCount)
)}`;
});
}, 2000);
function toggleLightMode() {
document.body.classList.toggle("light");
const localTheme = localStorage.getItem("theme");
if (!localTheme || localTheme === "dark")
localStorage.setItem("theme", "light");
else localStorage.setItem("theme", "dark");
}
window.onload = () => {
const localTheme = localStorage.getItem("theme");
if (!localTheme) {
if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
localStorage.setItem("theme", "dark");
} else if (window.matchMedia("(prefers-color-scheme: light)").matches) {
document.body.classList.toggle("light");
localStorage.setItem("theme", "light");
}
}
if (localTheme === "light") document.body.classList.toggle("light");
};
function search() {
const prompt = window.prompt("Enter channel name, ID, or URL.");
if (prompt)
fetch(
`https://axern.space/api/search?platform=youtube&type=channel&query=${prompt}`
)
.then((res) => res.json())
.then((data) => {
window.location.href = "?id=" + data[0].id;
});
}