This commit is contained in:
Dũng committed 2025-08-10 21:09:49 +07:00
1 parent 06c530d78b
commit 2efd671356
1 file changed
+22 -26
+22 -26
View File
@@ -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 = {