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);After updating actions in script editor all the Node.js code deleted
-
Sometimes I face the problem that after updating a script to a newer version of BAS all the Node.js code from the cubes is gone.
Is there any workaround for this or setting that prevents that behaviour?
-
Updating from which version and to which version did the problem occur? What code was contained in the action?
-
@m4zuper I updated from 26.8.1 to 27.0.0. The node code was just for removing and adding dots from and to a gmail address.
function generateDotVariants(email, numberOfVariants = 1) { const [localPart, domainPart] = email.split('@'); const variants = new Set(); while (variants.size < numberOfVariants) { let dotsCount = Math.floor(Math.random() * 3) + 2; let variantArray = localPart.split(''); let positions = []; for (let i = 1; i < variantArray.length - 1; i++) { if (variantArray[i - 1] !== '.' && variantArray[i] !== '.' && variantArray[i + 1] !== '.') { positions.push(i); } } for (let i = 0; i < dotsCount; i++) { if (positions.length === 0) break; const randomIndex = Math.floor(Math.random() * positions.length); const dotPosition = positions[randomIndex]; variantArray.splice(dotPosition, 0, '.'); positions = positions.filter(pos => Math.abs(pos - dotPosition) > 1); } const variant = variantArray.join(''); variants.add(variant + '@' + domainPart); } return Array.from(variants); } const email = [[FW_ADDRESS]] ; const variants = generateDotVariants(email); [[FW_ADDRESS_DOT]] = variants; [[FW_ADDRESS_DOT]] = [[FW_ADDRESS_DOT]][0] -
@morpheus93
Can't replicate your problem. Perhaps there are some details? What version of node.js are you using? -
Can't replicate your problem, are you sure the project wasn't opened simultaneously in multiple copies of BAS?
-
@m4zuper Could be possible that it was opened multiple times but I can't say for sure.
Btw. what is the recommended way to open a project mulitple times, for copying over cubes? I read to use a copy of the original xml project-file.
But how to open BAS mulitple times, should be used a separate installation or just open the same BAS (e.g. from the desktop link) 2 or more times? -
@morpheus93 said in After updating actions in script editor all the Node.js code deleted:
I read to use a copy of the original xml project-file.
I can't say for sure, but as an option to re-insure you can do it this way.
But how to open BAS mulitple times, should be used a separate installation or just open the same BAS (e.g. from the desktop link) 2 or more times?
You can open the same BAS.