This repository has been archived by the owner on Sep 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
185 lines (151 loc) · 5.98 KB
/
main.js
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
function getThumbnailLink() {
// there is 3x chance for the first thumbnail
const thumbnails = 9
const thumbnail = Math.max(
Math.floor(Math.random() * (thumbnails + 2)) - 1, 1
)
return `https://raw.githubusercontent.com/legitna/nux/main/${thumbnail}.png`
}
function addNux(thumbnailElement) {
if (thumbnailElement.classList.contains("nuxified")) {
return
}
const nuxImage = document.createElement("img")
nuxImage.setAttribute("src", getThumbnailLink())
nuxImage.style.position = "absolute"
nuxImage.style.width = "100%"
nuxImage.style.left = 0
nuxImage.style.bottom = 0
nuxImage.style.objectFit = "cover"
thumbnailElement.append(nuxImage)
thumbnailElement.classList.add("nuxified")
}
function generateRegex(r) {
r = r.replace("'", "['’]")
return new RegExp(`(^${r}|(?<=\\s)${r})(?=\\s)`)
}
function nuxifyTitle(title) {
const newTitle = title
// I -> We
.replace(generateRegex("I"), "WE")
.replace(generateRegex("i"), "we")
// I'm -> We're
.replace(generateRegex("I'm"), "We're")
.replace(generateRegex("I'M"), "WE'RE")
.replace(generateRegex("i'm"), "we're")
.replace(generateRegex("i'M"), "we'RE")
// I've -> We're
.replace(generateRegex("I've"), "We've")
.replace(generateRegex("I'VE"), "WE'VE")
.replace(generateRegex("i've"), "we've")
.replace(generateRegex("i'VE"), "we'VE")
// Me -> Us
.replace(generateRegex("Me"), "Us")
.replace(generateRegex("ME"), "US")
.replace(generateRegex("mE"), "uS")
.replace(generateRegex("me"), "us")
// My -> Our
.replace(generateRegex("My"), "Our")
.replace(generateRegex("MY"), "OUR")
.replace(generateRegex("mY"), "our")
.replace(generateRegex("my"), "our")
// My -> Our
.replace(generateRegex("Your"), "Our")
.replace(generateRegex("YOUR"), "OUR")
.replace(generateRegex("yOUR"), "oUR")
.replace(generateRegex("your"), "our")
// Mine -> Ours
.replace(generateRegex("Mine"), "Ours")
.replace(generateRegex("MINE"), "OURS")
.replace(generateRegex("mine"), "ours")
// I'll -> We'll
.replace(generateRegex("I'll"), "We'll")
.replace(generateRegex("I'LL"), "WE'LL")
.replace(generateRegex("i'll"), "we'll")
// I'd -> We'd
.replace(generateRegex("I'd"), "We'd")
.replace(generateRegex("I'D"), "WE'D")
.replace(generateRegex("i'd"), "we'd")
// am -> are
.replace(generateRegex("am"), "are")
.replace(generateRegex("AM"), "ARE")
.replace(generateRegex("Am"), "Are")
// POLISH
// ja -> my
.replace(generateRegex("Ja"), "My")
.replace(generateRegex("JA"), "MY")
.replace(generateRegex("ja"), "my")
// jestem -> jesteśmy
.replace(generateRegex("Jestem"), "Jesteśmy")
.replace(generateRegex("JESTEM"), "JESTEŚMY")
.replace(generateRegex("jestem"), "jesteśmy")
// mam -> mamy
.replace(generateRegex("Mam"), "Mamy")
.replace(generateRegex("MAM"), "MAMY")
.replace(generateRegex("mam"), "mamy")
// mnie -> nas
.replace(generateRegex("Mnie"), "Nas")
.replace(generateRegex("MNIE"), "NAS")
.replace(generateRegex("mnie"), "nas")
// mój -> nasz
.replace(generateRegex("Mój"), "Nasz")
.replace(generateRegex("MÓJ"), "NASZ")
.replace(generateRegex("mój"), "nasz")
// moja -> nasza
.replace(generateRegex("Moja"), "Nasza")
.replace(generateRegex("MOJA"), "NASZA")
.replace(generateRegex("moja"), "nasza")
// moje -> nasze
.replace(generateRegex("Moje"), "Nasze")
.replace(generateRegex("MOJE"), "NASZE")
.replace(generateRegex("moje"), "nasze")
// moje -> nasze (when "moje" is masculine)
.replace(generateRegex("Mojego"), "Naszego")
.replace(generateRegex("MOJEGO"), "NASZEGO")
.replace(generateRegex("mojego"), "naszego")
// mnie -> nas (in accusative case)
.replace(generateRegex("Mnie"), "Nas")
.replace(generateRegex("MNIE"), "NAS")
.replace(generateRegex("mnie"), "nas")
// moim -> naszym
.replace(generateRegex("Moim"), "Naszym")
.replace(generateRegex("MOIM"), "NASZYM")
.replace(generateRegex("moim"), "naszym")
// będę -> będziemy
.replace(generateRegex("Będę"), "Będziemy")
.replace(generateRegex("BĘDĘ"), "BĘDZIEMY")
.replace(generateRegex("będę"), "będziemy")
// bym -> byśmy
.replace(generateRegex("Bym"), "Byśmy")
.replace(generateRegex("BYM"), "BYŚMY")
.replace(generateRegex("bym"), "byśmy")
// muszę -> musimy
.replace(generateRegex("Muszę"), "Musimy")
.replace(generateRegex("MUSZĘ"), "MUSIMY")
.replace(generateRegex("muszę"), "musimy")
// potrzebuję -> potrzebujemy
.replace(generateRegex("Potrzebuję"), "Potrzebujemy")
.replace(generateRegex("POTRZEBUJĘ"), "POTRZEBUJEMY")
.replace(generateRegex("potrzebuję"), "potrzebujemy");
return newTitle
}
function main() {
Array.from(
document.querySelectorAll("yt-image.ytd-thumbnail:has(img), yt-image.ytd-playlist-video-thumbnail-renderer:has(img)")
).forEach(addNux)
Array.from(
document.querySelectorAll(
"yt-formatted-string#video-title, span#video-title, a#video-title, " +
"span.cbCustomTitle, yt-formatted-string.ytd-watch-metadata, " +
"title" +
"yt-formatted-string.promo-body-text" // easter egg
)
).forEach(titleElement => {
if (titleElement.classList.contains("nuxified")) {
return
}
titleElement.innerHTML = nuxifyTitle(titleElement.innerText)
titleElement.classList.add("nuxified")
})
}
setInterval(main, 1000)