I'm making a script that gets a button from a webpage and then send it through discord using a webhook. My problem is that the script is a loop that it is checking all the time if the buttons exits. So, when the button exits it spams a lot the discord webhook. Is there is any way to stop spamming?

```js
myFunction()

function myFunction() {
  var button = document.getElementsByClassName("button");
  var min = 30,
    max = 50;
  var rand = Math.floor(Math.random() * (max - min + 1) + min)

  if (button[0]) {
    console.log("%c Button!", "color: green;")

    //here will go the webhook to send the discord message
  }

  console.log('Waiting ' + rand + ' secs');
  setTimeout(myFunction, rand * 1000);
}

```