I tried applying this using ChatGPT, but it didn't work for me. Can you tell me where to put this code to make my code work?
// Функция для эмуляции нажатия мыши внутри элемента <canvas data-sentry-element="Stage"> function simulateMouseClickInCanvas() { const canvas = document.querySelector('canvas[data-sentry-element="Stage"]'); if (!canvas) { console.error("Элемент <canvas> не найден."); return; } const rect = canvas.getBoundingClientRect(); // Выбираем случайные координаты внутри элемента <canvas> const randomX = Math.random() * rect.width + rect.left; const randomY = Math.random() * rect.height + rect.top; // Создаём события мыши const mouseDownEvent = new MouseEvent("mousedown", { bubbles: true, cancelable: true, clientX: randomX, clientY: randomY, }); const mouseUpEvent = new MouseEvent("mouseup", { bubbles: true, cancelable: true, clientX: randomX, clientY: randomY, }); const clickEvent = new MouseEvent("click", { bubbles: true, cancelable: true, clientX: randomX, clientY: randomY, }); // Эмулируем события canvas.dispatchEvent(mouseDownEvent); canvas.dispatchEvent(mouseUpEvent); canvas.dispatchEvent(clickEvent); } // Функция для выполнения кликов с рандомной задержкой function performRandomClicksInCanvas(maxClicks) { let clicksCount = 0; function clickWithRandomDelay() { if (clicksCount >= maxClicks) { console.log("Все клики выполнены"); return; } const delay = Math.random() * (2000 - 100) + 100; // Рандомная задержка от 0.1 до 2 секунд setTimeout(() => { simulateMouseClickInCanvas(); clicksCount++; console.log(`Клик ${clicksCount} выполнен (задержка: ${Math.round(delay)} мс)`); clickWithRandomDelay(); // Рекурсивный вызов для следующего клика }, delay); } clickWithRandomDelay(); } // Запуск выполнения 10 кликов performRandomClicksInCanvas(10);executing javascript
-
When I attempt to change the value of the token using execute javascript on element
document.getElementById("recaptcha-token").value = "new value";I get in response "Cannot set properties of null (setting 'value'):
Even though everything looks correct and it also works in the console on normal chrome browser.
Any tips? -
@hellomembersha said in executing javascript:
When I attempt to change the value of the token using execute javascript on element
document.getElementById("recaptcha-token").value = "new value";I get in response "Cannot set properties of null (setting 'value'):
Even though everything looks correct and it also works in the console on normal chrome browser.
Any tips?This means that the element cannot be found, most likely it is in the frame
-
@hellomembersha said in executing javascript:
@Fox how would you go about changing the value in that situation?
First, check in the browser that the element is really in the frame. If so, use "Execute Javascript On Element" and the selector ">FRAME>"
-
@hellomembersha said in executing javascript:
@Fox its recaptcha v3 token i am attempting to replace. It is hidden element
It doesn't matter
-
after doing more reading it seems like the sandbox attribute has something to do with the blocking of access
-
@hellomembersha said in executing javascript:
@Fox can i dm you site link so you can see what i am talking about
You can send a link and screenshots where your code works in the browser and BAS does not work
-
@hellomembersha Hey can you show me how to do this I'm currently stuck right here