forked from inGenius-2020/website
-
Notifications
You must be signed in to change notification settings - Fork 3
/
getsethack.js
46 lines (39 loc) · 1.15 KB
/
getsethack.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
var passwords = ['InGenius 2020'];
var indexOld;
var index = Math.floor((Math.random() * passwords.length));
var password = passwords[index];
var characters = [];
var counter = 0;
var interval = setInterval(function(){
for(i = 0; i < counter; i++) {
characters[i] = password.charAt(i);
}
for(i = counter; i < password.length; i++) {
characters[i] = Math.random().toString(36).charAt(2);
}
$('.password').text(characters.join(''));
}, 25);
function hack() {
counter++;
if(counter == password.length){
$('.granted, .rerun').removeClass('hidden');
}
}
$(window).on('keydown', hack);
$('.password').on('click', hack);
$('.rerun').on('click', function() {
//prevent from displaying the same password two times in a row
indexOld = index;
do {
index = Math.floor((Math.random() * passwords.length));
} while(index == indexOld);
$('.granted, .rerun').addClass('hidden');
password = passwords[index];
characters = [];
counter = 0;
});
//keyboard events won't fire if the iframe isn't selected first in Full Page view
$('.start').on('click', function() {
$(this).addClass('hidden');
$('.info p:last-child, .password').removeClass('hidden');
});