Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

const button = document.querySelector(".main-btn");

if (button) { const clickButtonMultipleTimes = async () => { while (true) { const userInput = prompt("Enter the number of times to click the button (or type 'exit' to stop):");

      if (userInput === null || userInput.toLowerCase() === 'exit') {
        alert("Exiting the click process.");
        break;
      }

      const clicks = parseInt(userInput, 10);

      if (isNaN(clicks) || clicks < 0) {
        alert("Please enter a valid non-negative number.");
        continue;
      }

      for (let i = 0; i < clicks; i++) {
        button.click();
      }

      alert(`Clicked the button ${clicks} time(s)!`);
    }
  };

  clickButtonMultipleTimes();
} else { alert("The button with class 'main-btn' was not found on this page."); }


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: