From 12c6037170c94c94bb3c167b8c7e0bd7b7d25491 Mon Sep 17 00:00:00 2001 From: jamz-uk <222520099+jamz-uk@users.noreply.github.com> Date: Wed, 13 Aug 2025 18:09:47 +0100 Subject: [PATCH] Update Auto-Farm.js --- Auto-Farm.js | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/Auto-Farm.js b/Auto-Farm.js index b07c699..7896b8b 100644 --- a/Auto-Farm.js +++ b/Auto-Farm.js @@ -173,17 +173,29 @@ await sleep(500); const canvas = await waitForSelector('canvas'); if (canvas) { + canvas.setAttribute('tabindex', '0'); + canvas.focus(); const rect = canvas.getBoundingClientRect(); const centerX = Math.round(rect.left + rect.width / 2); const centerY = Math.round(rect.top + rect.height / 2); - ['mouseover', 'mousemove', 'mousedown', 'mouseup', 'click'].forEach(type => { - const evt = new MouseEvent(type, { - clientX: centerX, - clientY: centerY, - bubbles: true - }); - canvas.dispatchEvent(evt); + const moveEvt = new MouseEvent('mousemove', { + clientX: centerX, + clientY: centerY, + bubbles: true }); + canvas.dispatchEvent(moveEvt); + const keyDown = new KeyboardEvent('keydown', { + key: ' ', + code: 'Space', + bubbles: true + }); + const keyUp = new KeyboardEvent('keyup', { + key: ' ', + code: 'Space', + bubbles: true + }); + canvas.dispatchEvent(keyDown); + canvas.dispatchEvent(keyUp); } await sleep(500); updateUI(