Update plugins/cloudflare-bypass.js
Browse files- plugins/cloudflare-bypass.js +30 -4
plugins/cloudflare-bypass.js
CHANGED
|
@@ -2,8 +2,21 @@ const BASE_URL = 'https://herzaj-turnstile-solver.hf.space';
|
|
| 2 |
|
| 3 |
async function callBypassAPI(url, sitekey) {
|
| 4 |
try {
|
| 5 |
-
const submitResponse = await fetch(`${BASE_URL}/turnstile?url=${encodeURIComponent(url)}&sitekey=${encodeURIComponent(sitekey)}
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
if (!submitData.task_id) {
|
| 9 |
throw new Error('Failed to get task_id from API');
|
|
@@ -17,8 +30,21 @@ async function callBypassAPI(url, sitekey) {
|
|
| 17 |
while (attempts < maxAttempts) {
|
| 18 |
await new Promise(resolve => setTimeout(resolve, 2000));
|
| 19 |
|
| 20 |
-
const resultResponse = await fetch(`${BASE_URL}/result/${taskId}
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
if (resultData.value) {
|
| 24 |
return {
|
|
|
|
| 2 |
|
| 3 |
async function callBypassAPI(url, sitekey) {
|
| 4 |
try {
|
| 5 |
+
const submitResponse = await fetch(`${BASE_URL}/turnstile?url=${encodeURIComponent(url)}&sitekey=${encodeURIComponent(sitekey)}`, {
|
| 6 |
+
headers: {
|
| 7 |
+
'Accept': 'application/json',
|
| 8 |
+
'Content-Type': 'application/json'
|
| 9 |
+
}
|
| 10 |
+
});
|
| 11 |
+
|
| 12 |
+
const submitText = await submitResponse.text();
|
| 13 |
+
let submitData;
|
| 14 |
+
|
| 15 |
+
try {
|
| 16 |
+
submitData = JSON.parse(submitText);
|
| 17 |
+
} catch (e) {
|
| 18 |
+
throw new Error(`API returned invalid response: ${submitText.substring(0, 100)}`);
|
| 19 |
+
}
|
| 20 |
|
| 21 |
if (!submitData.task_id) {
|
| 22 |
throw new Error('Failed to get task_id from API');
|
|
|
|
| 30 |
while (attempts < maxAttempts) {
|
| 31 |
await new Promise(resolve => setTimeout(resolve, 2000));
|
| 32 |
|
| 33 |
+
const resultResponse = await fetch(`${BASE_URL}/result/${taskId}`, {
|
| 34 |
+
headers: {
|
| 35 |
+
'Accept': 'application/json'
|
| 36 |
+
}
|
| 37 |
+
});
|
| 38 |
+
|
| 39 |
+
const resultText = await resultResponse.text();
|
| 40 |
+
let resultData;
|
| 41 |
+
|
| 42 |
+
try {
|
| 43 |
+
resultData = JSON.parse(resultText);
|
| 44 |
+
} catch (e) {
|
| 45 |
+
attempts++;
|
| 46 |
+
continue;
|
| 47 |
+
}
|
| 48 |
|
| 49 |
if (resultData.value) {
|
| 50 |
return {
|