UNPKG

clicks-recaptcha-solver

Version:

A powerful automation tool for solving Google reCAPTCHA challenges using Playwright and Puppeteer. This package intelligently detects and simulates human-like interactions, including mouse movements and precise clicks, to bypass reCAPTCHA v2 and other sim

49 lines (48 loc) 2.44 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.clickRecaptchaVerifyButton = void 0; const getRandomNumber_1 = require("./getRandomNumber"); const showClickInfo_1 = require("./showClickInfo"); /** * Clicks the reCAPTCHA verify button on the page. * * This function calculates the coordinates of the "Verify" button within the reCAPTCHA iframe * and performs a mouse click at the specified location. If `highlightClicks` is set to true, * it also visually highlights the click on the page. * * @param {Object} page - The Puppeteer page object containing the reCAPTCHA iframe. * @param {boolean} [highlightClicks=false] - Determines whether clicks should be visually highlighted on the page. */ const clickRecaptchaVerifyButton = async (page, highlightClicks = false) => { let w = 340; // the distance from the left border of the frame to the approximate location of the button click let h = 540; // the distance from the upper border of the frame to the approximate location of the button click const element = await page.$('iframe[src*="https://www.google.com/recaptcha/api2/bframe"]'); if (!element) { throw new Error('Element not found'); } const boundingBox = await element.boundingBox(); if (!boundingBox) { throw new Error('Bounding box not found'); } let x = boundingBox.x + w + (0, getRandomNumber_1.getRandomNumber)(1, 35); let y = boundingBox.y + h + (0, getRandomNumber_1.getRandomNumber)(1, 5); // console.log(`Click on coordinates x:${x},y:${y}`); // console.log('Click Verify/Skip'); // Click on the specified coordinates await page.mouse.click(x, y); // Visualization of clicks when highlightClicks mode is enabled if (highlightClicks) { let clickCoordinatesToShow = { x: x, y: y }; // Passing the showClickInfo function and coordinates await page.evaluate(({ click, showClickInfoFunc }) => { // Restoring the function via eval eval(showClickInfoFunc); // Calling the showClickInfo function with the passed coordinates (0, showClickInfo_1.showClickInfo)(click.x, click.y); }, { click: clickCoordinatesToShow, showClickInfoFunc: showClickInfo_1.showClickInfo.toString() // Passing the function as a string }); } }; exports.clickRecaptchaVerifyButton = clickRecaptchaVerifyButton;