Guest User

Untitled

a guest
Oct 28th, 2025
1,198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. let counter = 0;
  2. let maxClicks = 1000;
  3.  
  4. function findButton(exactText) {
  5. const buttons = document.querySelectorAll('button');
  6. return Array.from(buttons).find(btn =>
  7. btn.textContent.replace(/\s+/g, ' ').trim() === exactText
  8. );
  9. }
  10.  
  11. const interval = setInterval(() => {
  12. // Используем точный текст как он есть на странице
  13. let btn_buy = findButton("Купить 1 по рынку");
  14. let btn_sell = findButton("Продать 1 по рынку");
  15.  
  16. console.log('Найдены кнопки:', {
  17. buy: btn_buy ? 'да' : 'нет',
  18. sell: btn_sell ? 'да' : 'нет'
  19. });
  20.  
  21. if (counter % 2 === 0) {
  22. if (btn_buy) {
  23. btn_buy.click();
  24. console.log('Покупка');
  25. } else {
  26. console.log('Кнопка покупки не найдена');
  27. }
  28. } else {
  29. if (btn_sell) {
  30. btn_sell.click();
  31. console.log('Продажа');
  32. } else {
  33. console.log('Кнопка продажи не найдена');
  34. }
  35. }
  36.  
  37. counter++;
  38. console.log(`${counter}/${maxClicks}`)
  39.  
  40. if (counter >= maxClicks) {
  41. clearInterval(interval);
  42. console.log('Цикл завершен');
  43. }
  44. }, 1000);
Add Comment
Please, Sign In to add comment