From 2efd6713567e555df3ae7df89fb63d32b036cb42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C5=A9ng?= <99890979+maiminhdung@users.noreply.github.com> Date: Sun, 10 Aug 2025 21:09:49 +0700 Subject: [PATCH] Restore --- Auto-Image.js | 48 ++++++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/Auto-Image.js b/Auto-Image.js index 57cd247..d1bdca6 100644 --- a/Auto-Image.js +++ b/Auto-Image.js @@ -1,7 +1,3 @@ -const puppeteer = require('puppeteer'); -const { loadScraper } = require('cloudflare-scrape'); -const fetch = loadScraper(); - (async () => { // CONFIGURATION CONSTANTS const CONFIG = { @@ -120,28 +116,29 @@ const fetch = loadScraper(); // Global variable to store the captured CAPTCHA token. let capturedCaptchaToken = null; - // Send events - document.dispatchEvent(spaceKeyDown); - // Send your paint request here - document.dispatchEvent(spaceKeyUp); - // Intercept the original window.fetch function to "listen" for network requests. - const browser = await puppeteer.launch({headless: false}); // để xem bước giải captcha - const page = await browser.newPage(); - - // Bật Cloudflare challenge handling (pupeteer tự động giải captcha nếu có extension) - await page.goto('https://wplace.live', {waitUntil: 'networkidle2'}); - - // Thực hiện một pixel thủ công để nhận token - await page.evaluate(() => { - const payload = { coords:[0,0], colors:[1] }; // ví dụ pixel đầu tiên - fetch(`https://backend.wplace.live/s0/pixel/0/0`, { - method: 'POST', - credentials: 'include', - headers: {'Content-Type': 'text/plain;charset=UTF-8'}, - body: JSON.stringify(payload) - }); - }); + const originalFetch = window.fetch; + window.fetch = async (url, options) => { + // Check if the request is for painting a pixel on wplace. + if (typeof url === 'string' && url.includes('https://backend.wplace.live/s0/pixel/')) { + try { + const payload = JSON.parse(options.body); + // If the request body contains the 't' field, it's our CAPTCHA token. + if (payload.t) { + console.log("✅ CAPTCHA Token Captured:", payload.t); + // Store the token for our bot to use. + capturedCaptchaToken = payload.t; + // Notify the user that the token is captured and they can start the bot. + if(document.querySelector('#statusText')?.textContent.includes('CAPTCHA')){ + Utils.showAlert("Token captured successfully! You can start the bot now.", "success"); + updateUI('colorsFound', 'success', { count: state.availableColors.length }); + } + } + } catch (e) { /* Ignore errors if the request body isn't valid JSON */ } + } + // Finally, execute the original request, whether we inspected it or not. + return originalFetch(url, options); + }; async function detectLanguage() { @@ -268,7 +265,6 @@ const fetch = loadScraper(); // WPLACE API SERVICE const WPlaceService = { async paintPixelInRegion(regionX, regionY, pixelX, pixelY, color) { - try { // Construct the payload including the captured 't' token. const payload = {