-
Notifications
You must be signed in to change notification settings - Fork 52
/
turnstile.js
33 lines (26 loc) · 878 Bytes
/
turnstile.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
export const checkStat = ({ page }) => {
return new Promise(async (resolve, reject) => {
var st = setTimeout(() => {
clearInterval(st)
resolve(false)
}, 4000);
try {
const elements = await page.$$('.cf-turnstile-wrapper');
if (elements.length <= 0) return resolve(false);
for (const element of elements) {
try {
const box = await element.boundingBox();
const x = box.x + box.width / 2;
const y = box.y + box.height / 2;
await page.mouse.click(x, y);
} catch (err) { }
}
clearInterval(st)
resolve(true)
} catch (err) {
// console.log(err);
clearInterval(st)
resolve(false)
}
})
}