HerzaJ commited on
Commit
731c18f
·
verified ·
1 Parent(s): 677923a

Update solver.js

Browse files
Files changed (1) hide show
  1. solver.js +52 -1
solver.js CHANGED
@@ -322,5 +322,56 @@ export async function solve(page, { delay = 64, wait = 5000, retry = 3, ffmpeg =
322
 
323
  page.off("response", listener);
324
 
325
- return true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
326
  }
 
322
 
323
  page.off("response", listener);
324
 
325
+ await sleep(1000);
326
+
327
+ let token = null;
328
+
329
+ try {
330
+ const iframe = await page.$(MAIN_FRAME);
331
+ if (iframe) {
332
+ const box_page = await iframe.contentFrame();
333
+ if (box_page) {
334
+ const textarea = await box_page.$('#g-recaptcha-response');
335
+ if (textarea) {
336
+ token = await textarea.evaluate(el => el.value);
337
+ console.log("Token found in textarea:", token?.substring(0, 50) + "...");
338
+ }
339
+ }
340
+ }
341
+ } catch (error) {
342
+ console.log("Error extracting token from iframe:", error.message);
343
+ }
344
+
345
+ if (!token) {
346
+ try {
347
+ const textarea = await page.$('#g-recaptcha-response');
348
+ if (textarea) {
349
+ token = await textarea.evaluate(el => el.value);
350
+ console.log("Token found in main page:", token?.substring(0, 50) + "...");
351
+ }
352
+ } catch (error) {
353
+ console.log("Error extracting token from main page:", error.message);
354
+ }
355
+ }
356
+
357
+ if (!token) {
358
+ try {
359
+ const allTextareas = await page.$('textarea');
360
+ for (const textarea of allTextareas) {
361
+ const name = await textarea.getAttribute('name');
362
+ const id = await textarea.getAttribute('id');
363
+ if (name === 'g-recaptcha-response' || id === 'g-recaptcha-response') {
364
+ token = await textarea.evaluate(el => el.value);
365
+ console.log("Token found in textarea by attribute:", token?.substring(0, 50) + "...");
366
+ break;
367
+ }
368
+ }
369
+ } catch (error) {
370
+ console.log("Error searching all textareas:", error.message);
371
+ }
372
+ }
373
+
374
+ console.log("Final token:", token ? `${token.substring(0, 50)}... (length: ${token.length})` : "not found");
375
+
376
+ return { success: true, token };
377
  }