Update endpoints/recaptchav3.js
Browse files- endpoints/recaptchav3.js +1 -19
endpoints/recaptchav3.js
CHANGED
|
@@ -2,14 +2,12 @@ const delay = ms => new Promise(res => setTimeout(res, ms));
|
|
| 2 |
|
| 3 |
module.exports = async function(page, url, siteKey, action = 'submit') {
|
| 4 |
return new Promise(async (resolve, reject) => {
|
| 5 |
-
// Perpanjang timeout global sedikit untuk kompensasi loading berat
|
| 6 |
const timeoutTimer = setTimeout(() =>
|
| 7 |
reject(new Error("Timeout Global (40s)")), 40000);
|
| 8 |
|
| 9 |
try {
|
| 10 |
console.log(`[RV3] Target: ${url} | Key: ${siteKey}`);
|
| 11 |
|
| 12 |
-
// 1. Setup browser
|
| 13 |
await page.setExtraHTTPHeaders({
|
| 14 |
'Accept-Language': 'id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7',
|
| 15 |
'Sec-Fetch-Site': 'cross-site',
|
|
@@ -18,8 +16,6 @@ module.exports = async function(page, url, siteKey, action = 'submit') {
|
|
| 18 |
'Upgrade-Insecure-Requests': '1'
|
| 19 |
});
|
| 20 |
|
| 21 |
-
// 2. Navigasi ke URL target
|
| 22 |
-
// UBAH: Gunakan domcontentloaded karena networkidle0 sering timeout di situs faucet
|
| 23 |
try {
|
| 24 |
await page.goto(url, {
|
| 25 |
waitUntil: 'domcontentloaded',
|
|
@@ -29,20 +25,15 @@ module.exports = async function(page, url, siteKey, action = 'submit') {
|
|
| 29 |
console.log('[RV3] Navigation warning (ignorable):', e.message);
|
| 30 |
}
|
| 31 |
|
| 32 |
-
// TAMBAHAN: Mouse wiggle untuk mentrigger script lazy-load
|
| 33 |
try {
|
| 34 |
await page.mouse.move(100, 100);
|
| 35 |
await page.mouse.move(200, 200);
|
| 36 |
await delay(1000);
|
| 37 |
} catch (e) {}
|
| 38 |
|
| 39 |
-
// 3. Tunggu iframe reCAPTCHA load
|
| 40 |
-
// Beri waktu script loading setelah domcontentloaded
|
| 41 |
await delay(5000);
|
| 42 |
|
| 43 |
-
// 4. Cari token di elemen/iframe (Cara Pasif)
|
| 44 |
const token = await page.evaluate(() => {
|
| 45 |
-
// Cara 1: Iframe
|
| 46 |
const iframes = document.querySelectorAll('iframe');
|
| 47 |
for (let iframe of iframes) {
|
| 48 |
if (iframe.src && iframe.src.includes('recaptcha')) {
|
|
@@ -54,9 +45,7 @@ module.exports = async function(page, url, siteKey, action = 'submit') {
|
|
| 54 |
} catch (e) {}
|
| 55 |
}
|
| 56 |
}
|
| 57 |
-
// Cara 2: Global
|
| 58 |
if (window.recaptchaToken) return window.recaptchaToken;
|
| 59 |
-
// Cara 3: Hidden Input
|
| 60 |
const inputs = document.querySelectorAll('input[id*="recaptcha"], input[name*="recaptcha"]');
|
| 61 |
for (let input of inputs) {
|
| 62 |
if (input.value && input.value.length > 100) return input.value;
|
|
@@ -71,18 +60,12 @@ module.exports = async function(page, url, siteKey, action = 'submit') {
|
|
| 71 |
return;
|
| 72 |
}
|
| 73 |
|
| 74 |
-
// 5. Network Interception (Opsional, seringkali v3 tidak muncul di network body response secara jelas)
|
| 75 |
-
// Skip langkah ini jika ingin mempercepat, atau biarkan sebagai cadangan.
|
| 76 |
-
// (Kode intercept Anda sudah oke, tapi kadang memakan waktu jika reload diperlukan)
|
| 77 |
-
|
| 78 |
-
// 6. Fallback: Eksekusi grecaptcha.execute secara paksa
|
| 79 |
console.log('[RV3] Trying grecaptcha.execute fallback...');
|
| 80 |
|
| 81 |
const executeToken = await page.evaluate(async (siteKey, action) => {
|
| 82 |
return new Promise((resolve, reject) => {
|
| 83 |
const timeout = setTimeout(() => reject('Timeout inside evaluate'), 15000);
|
| 84 |
-
|
| 85 |
-
// Fungsi helper untuk menunggu grecaptcha siap
|
| 86 |
const waitForGrecaptcha = (interval = 500, maxAttempts = 20) => {
|
| 87 |
return new Promise(res => {
|
| 88 |
let attempts = 0;
|
|
@@ -99,7 +82,6 @@ module.exports = async function(page, url, siteKey, action = 'submit') {
|
|
| 99 |
});
|
| 100 |
};
|
| 101 |
|
| 102 |
-
// Load script manual jika belum ada
|
| 103 |
if (!window.grecaptcha || !window.grecaptcha.execute) {
|
| 104 |
const script = document.createElement('script');
|
| 105 |
script.src = `https://www.google.com/recaptcha/api.js?render=${siteKey}`;
|
|
|
|
| 2 |
|
| 3 |
module.exports = async function(page, url, siteKey, action = 'submit') {
|
| 4 |
return new Promise(async (resolve, reject) => {
|
|
|
|
| 5 |
const timeoutTimer = setTimeout(() =>
|
| 6 |
reject(new Error("Timeout Global (40s)")), 40000);
|
| 7 |
|
| 8 |
try {
|
| 9 |
console.log(`[RV3] Target: ${url} | Key: ${siteKey}`);
|
| 10 |
|
|
|
|
| 11 |
await page.setExtraHTTPHeaders({
|
| 12 |
'Accept-Language': 'id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7',
|
| 13 |
'Sec-Fetch-Site': 'cross-site',
|
|
|
|
| 16 |
'Upgrade-Insecure-Requests': '1'
|
| 17 |
});
|
| 18 |
|
|
|
|
|
|
|
| 19 |
try {
|
| 20 |
await page.goto(url, {
|
| 21 |
waitUntil: 'domcontentloaded',
|
|
|
|
| 25 |
console.log('[RV3] Navigation warning (ignorable):', e.message);
|
| 26 |
}
|
| 27 |
|
|
|
|
| 28 |
try {
|
| 29 |
await page.mouse.move(100, 100);
|
| 30 |
await page.mouse.move(200, 200);
|
| 31 |
await delay(1000);
|
| 32 |
} catch (e) {}
|
| 33 |
|
|
|
|
|
|
|
| 34 |
await delay(5000);
|
| 35 |
|
|
|
|
| 36 |
const token = await page.evaluate(() => {
|
|
|
|
| 37 |
const iframes = document.querySelectorAll('iframe');
|
| 38 |
for (let iframe of iframes) {
|
| 39 |
if (iframe.src && iframe.src.includes('recaptcha')) {
|
|
|
|
| 45 |
} catch (e) {}
|
| 46 |
}
|
| 47 |
}
|
|
|
|
| 48 |
if (window.recaptchaToken) return window.recaptchaToken;
|
|
|
|
| 49 |
const inputs = document.querySelectorAll('input[id*="recaptcha"], input[name*="recaptcha"]');
|
| 50 |
for (let input of inputs) {
|
| 51 |
if (input.value && input.value.length > 100) return input.value;
|
|
|
|
| 60 |
return;
|
| 61 |
}
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
console.log('[RV3] Trying grecaptcha.execute fallback...');
|
| 64 |
|
| 65 |
const executeToken = await page.evaluate(async (siteKey, action) => {
|
| 66 |
return new Promise((resolve, reject) => {
|
| 67 |
const timeout = setTimeout(() => reject('Timeout inside evaluate'), 15000);
|
| 68 |
+
|
|
|
|
| 69 |
const waitForGrecaptcha = (interval = 500, maxAttempts = 20) => {
|
| 70 |
return new Promise(res => {
|
| 71 |
let attempts = 0;
|
|
|
|
| 82 |
});
|
| 83 |
};
|
| 84 |
|
|
|
|
| 85 |
if (!window.grecaptcha || !window.grecaptcha.execute) {
|
| 86 |
const script = document.createElement('script');
|
| 87 |
script.src = `https://www.google.com/recaptcha/api.js?render=${siteKey}`;
|