mirror of
https://github.com/tiennm99/WPlace-AutoBOT.git
synced 2026-10-14 10:18:02 +00:00
Update Auto-Farm.js
This commit is contained in:
1 parent
44e64f6451
commit
78c7e9b767
1 file changed
+23
-9
+23
-9
@@ -27,6 +27,16 @@
|
||||
};
|
||||
|
||||
const sleep = ms => new Promise(r => setTimeout(r, ms));
|
||||
// Utility to wait for a selector to appear in the DOM
|
||||
const waitForSelector = async (selector, interval = 200, timeout = 5000) => {
|
||||
const start = Date.now();
|
||||
while (Date.now() - start < timeout) {
|
||||
const el = document.querySelector(selector);
|
||||
if (el) return el;
|
||||
await sleep(interval);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const originalFetch = window.fetch;
|
||||
let capturedCaptchaToken = null;
|
||||
@@ -152,15 +162,19 @@
|
||||
'error'
|
||||
);
|
||||
// Auto-click sequence to trigger CAPTCHA refresh
|
||||
document.querySelector('div.flex.items-center.gap-2')?.click();
|
||||
document.querySelector('#color-0')?.click();
|
||||
// Click center of viewport
|
||||
const cx = window.innerWidth / 2;
|
||||
const cy = window.innerHeight / 2;
|
||||
document.elementFromPoint(cx, cy)?.click();
|
||||
// Click confirm paint button
|
||||
document.querySelector('div.absolute.bottom-0.left-1\\/2 button.btn.btn-primary')?.click();
|
||||
continue;
|
||||
// Auto-click sequence with waits for element availability
|
||||
const paintBtn = await waitForSelector('div.flex.items-center.gap-2');
|
||||
paintBtn?.click();
|
||||
const transBtn = await waitForSelector('#color-0');
|
||||
transBtn?.click();
|
||||
await sleep(500);
|
||||
const cx = window.innerWidth / 2;
|
||||
const cy = window.innerHeight / 2;
|
||||
const centerEl = document.elementFromPoint(cx, cy);
|
||||
centerEl?.click();
|
||||
const confirmBtn = await waitForSelector('div.absolute.bottom-0.left-1\\/2 button.btn.btn-primary');
|
||||
confirmBtn?.click();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (paintResult?.painted === 1) {
|
||||
|
||||
Reference in new issue
Block a user