-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththefunny.html
More file actions
133 lines (118 loc) · 3.14 KB
/
thefunny.html
File metadata and controls
133 lines (118 loc) · 3.14 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
<!DOCTYPE html>
<html style="background-color: black">
<head>
<title>It's Funny</title>
<style>
* {
margin: none;
padding: none;
}
iframe {
height: 100%;
position: absolute;
top: 0px;
left: 0px;
border: none;
}
</style>
</head>
<body>
<iframe
id="ytEmbed"
width="100%"
src=""
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
autoplay="1"
allowfullscreen
></iframe>
<script>
const THELIST = [
"t5EjBelU-m0",
"ujcjnEO-YKU",
"22_tSN0SKdY",
"yata29OzKIA",
"Mz-GZOQYtYY",
"IIx71XkN9Oo",
"v5pmzj36Ves",
"-nIJdHn1FFE",
"IvcuBaujzIg",
"iyvQ48V7LAQ",
"fGTXTzAvthM",
"nlsiooJ2ALU",
"OVkQLl2Ru5s",
"SKByTOTpVaM",
"ZPrQ5jwRbgM",
"O6jjb2w5das",
"Lv89FZpKd18",
"QOJFaXs5p8Y",
"KIvh9wSLaq0",
"2qR2Xp53e6w",
"QcXO-fv_TS4",
"Eq5O2W3Uq38",
"GPIn1BDCKnU",
"dQw4w9WgXcQ", // rickroll
"VAC-5BQnuXI",
];
function resetCookie() {
const rawCookie = JSON.stringify({ watched: [] });
document.cookie = rawCookie;
}
function checkCookie() {
let cookie = document.cookie;
try {
if (cookie == undefined || cookie == "") {
resetCookie();
return;
}
let cookedie = JSON.parse(cookie);
if (cookedie.watched.length >= THELIST.length) {
console.log("Reset length");
resetCookie();
return;
}
} catch (error) {
console.error(`Cookie error: ${error}\n${cookie}`);
resetCookie();
}
}
function getVideo() {
let cookie = JSON.parse(document.cookie);
console.log(cookie);
let selection;
while (true) {
let maybe = Math.round((Math.random() * 1000) % (THELIST.length - 1));
console.log(maybe);
for (const i of cookie.watched) {
if (maybe == i) {
console.log(`${maybe} == ${i}`);
maybe = -1;
break;
}
}
if (maybe == -1) continue;
selection = maybe;
break;
}
console.log(`Selected entry ${selection}`);
const iframe = document.getElementById("ytEmbed");
console.log(
`https://www.youtube.com/watch?v=${THELIST[selection]}?autoplay=1`
);
cookie.watched.push(selection);
document.cookie = JSON.stringify(cookie);
// Controls for iframe
// iframe.setAttribute(
// "src",
// `https://www.youtube.com/embed/${THELIST[selection]}?autoplay=1`
// );
// Redirect to random
window.location.href = `https://www.youtube.com/watch?v=${THELIST[selection]}?autoplay=1`;
}
document.addEventListener("DOMContentLoaded", () => {
checkCookie();
getVideo();
});
</script>
</body>
</html>