-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
67 lines (58 loc) · 2.02 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<p>If you still stuck. <a id="site" href="#here">Click Here</a></p>
<script>
// Mapping of special dates to their JSON files
const DayMap = {
"01-01": "url/day/new-year.json",
};
// Regular sites fallback
const defaultsite = "url/default.json";
// Function to get current date string
function curr_date() {
const today = new Date();
return `${today.getMonth() + 1}`.padStart(2, '0') +
`-${today.getDate()}`.padStart(2, '0');
}
// Function to load JSON from file
async function load(filename) {
try {
const response = await fetch(filename);
const data = await response.json();
return data.sites;
} catch (error) {
console.error('Error loading sites:', error);
return [];
}
}
// Randomly select and redirect to a site
async function randomRedirect() {
const today = curr_date();
let filename = DayMap[today] || defaultsite;
const url = document.getElementById('site');
const c = Math.floor(Math.random() * 11);
const sd = Math.floor(Math.random() * 2);
if (filename == DayMap[today] && sd === 2) {
filename = defaultsite;
}
if (c === 10) {
filename = "url/anime/enstar/fine.json";
}
const list = await load(filename);
if (list.length > 0) {
const x = Math.floor(Math.random() * list.length);
url.href = list[x];
window.location.href = list[x];
} else {
console.error('No sites available at the moment.');
}
}
// Redirect immediately when page loads
randomRedirect();
</script>
</body>
</html>