HerzaJ commited on
Commit
8c7fbd6
·
verified ·
1 Parent(s): 95e0eeb

Update plugins/cloudflare-bypass.js

Browse files
Files changed (1) hide show
  1. plugins/cloudflare-bypass.js +15 -27
plugins/cloudflare-bypass.js CHANGED
@@ -25,37 +25,25 @@ async function callBypassAPI(url, sitekey) {
25
 
26
  await new Promise(resolve => setTimeout(resolve, 5000));
27
 
28
- let attempts = 0;
29
- const maxAttempts = 30;
30
-
31
- while (attempts < maxAttempts) {
32
- try {
33
- const resultResponse = await axios.get(`${BASE_URL}/result/${taskId}`, {
34
- headers: {
35
- 'Accept': 'application/json'
36
- }
37
- });
38
-
39
- const resultData = resultResponse.data;
40
-
41
- if (resultData.value) {
42
- return {
43
- token: resultData.value,
44
- solved_time: resultData.elapsed_time
45
- };
46
- }
47
-
48
- } catch (error) {
49
- if (error.response && error.response.status !== 404) {
50
- console.error(error.message);
51
- }
52
  }
 
 
 
53
 
54
- await new Promise(resolve => setTimeout(resolve, 2000));
55
- attempts++;
 
 
 
56
  }
57
 
58
- throw new Error('Timeout: Could not solve turnstile within time limit');
59
 
60
  } catch (error) {
61
  throw error;
 
25
 
26
  await new Promise(resolve => setTimeout(resolve, 5000));
27
 
28
+ const resultResponse = await axios.get(`${BASE_URL}/result`, {
29
+ params: {
30
+ id: taskId
31
+ },
32
+ headers: {
33
+ 'Accept': 'application/json'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  }
35
+ });
36
+
37
+ const resultData = resultResponse.data;
38
 
39
+ if (resultData.value) {
40
+ return {
41
+ token: resultData.value,
42
+ solved_time: resultData.elapsed_time
43
+ };
44
  }
45
 
46
+ throw new Error('Failed to get token from result');
47
 
48
  } catch (error) {
49
  throw error;