-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
66 lines (65 loc) · 1.63 KB
/
index.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
const code = document.getElementById('code')
const speed = 25
const chars = 250
const sources = [
'https://cdn.jsdelivr.net/gh/quantum9innovation/the-jankiest/index.min.js',
'https://cdn.jsdelivr.net/gh/quantum9innovation/hulet/dist/hulet.min.js',
'https://cdn.jsdelivr.net/gh/quantum9innovation/sost/dist/sost.min.js',
'https://code.jquery.com/jquery-3.6.3.min.js',
'https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js',
]
const trash = []
let jank = `console.log("Hacking...");`
let strings = jank.split('')
let i = 0
let j = 0
const highlight = () => {
document.querySelectorAll('pre code').forEach(el => {
hljs.highlightElement(el)
})
}
const shuffle = (arr) => {
for (var i = arr.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1))
var temp = arr[i]
arr[i] = arr[j]
arr[j] = temp
}
}
const clear = () => code.innerText = ''
const reset = () => {
j++
if (j == trash.length) {
j = 0
shuffle(trash)
clear()
}
if (trash[j] !== undefined) {
jank = trash[j]
strings = jank.split('')
} else return
}
const type = () => {
if (i < strings.length && code.innerText.length < 50000) {
let selected = strings.slice(i, i + chars)
code.innerText += selected.join('')
i += chars
highlight()
code.scrollTop = code.scrollHeight;
setTimeout(type, speed)
} else {
reset()
i = 0
type()
}
}
sources.forEach((source) => {
fetch(source).then(res => {
res.text().then(text => {
let formatted = text.replace(/\n/g, '')
trash.push(formatted)
})
})
})
setTimeout(type, 1000)
document.addEventListener('keypress', clear)