-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjs.js
43 lines (36 loc) · 1010 Bytes
/
js.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
const randomArenaBlock = () => {
const baseUrl =
"https://cors-anywhere.herokuapp.com/https://www.are.na/block/";
const reqUrl = "https://www.are.na/block/";
const rDigits = d =>
`${"x".repeat(d)}`.replace(/x/g, a => (Math.random() * 9) | 0);
let digits = rDigits(7);
let randUrl = {
request: `${baseUrl}${digits}`,
set: `${reqUrl}${digits}`
};
const checkBlock = a => {
return new Promise((resolve, reject) => {
fetch(randUrl.request, {
method: "HEAD",
headers: {
origin: "https://jpegzilla.com"
}
})
.then(resp => {
if (resp.status != 200) {
return randomArenaBlock();
} else resolve(resp);
})
.catch(err => {
return new Error(err);
});
});
};
checkBlock(randUrl).then(resp => {
let tab = window.open(randUrl.set, "_blank");
tab.focus();
return resp.url;
});
};
randomArenaBlock();