Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let counter = 0;
- let maxClicks = 1000;
- function findButton(exactText) {
- const buttons = document.querySelectorAll('button');
- return Array.from(buttons).find(btn =>
- btn.textContent.replace(/\s+/g, ' ').trim() === exactText
- );
- }
- const interval = setInterval(() => {
- // Используем точный текст как он есть на странице
- let btn_buy = findButton("Купить 1 по рынку");
- let btn_sell = findButton("Продать 1 по рынку");
- console.log('Найдены кнопки:', {
- buy: btn_buy ? 'да' : 'нет',
- sell: btn_sell ? 'да' : 'нет'
- });
- if (counter % 2 === 0) {
- if (btn_buy) {
- btn_buy.click();
- console.log('Покупка');
- } else {
- console.log('Кнопка покупки не найдена');
- }
- } else {
- if (btn_sell) {
- btn_sell.click();
- console.log('Продажа');
- } else {
- console.log('Кнопка продажи не найдена');
- }
- }
- counter++;
- console.log(`${counter}/${maxClicks}`)
- if (counter >= maxClicks) {
- clearInterval(interval);
- console.log('Цикл завершен');
- }
- }, 1000);
Add Comment
Please, Sign In to add comment