0

I want to try make a script that auto-clicks a button, but I can't find what to put in the class name. How do I find it?

window.onload=function(){
    setInterval(autoClick,100);
  }
  function autoClick(){
    if(document.getElementsByClassName("???").length>0){
    document.getElementsByClassName("???")[0].click();
  }
}

I don't know how to get the element by class name.

Jared Farrish
  • 48,585
  • 17
  • 95
  • 104

1 Answers1

0

If you're trying to click with coordinates use document.elementFromPoint(x, y).click();

https://codepen.io/niko8888/pen/aryoMb?editors=0010

If you are using Chrome, open up the inspector, inspect the element you want to click. Right click over the element in the Elements panel and then scroll down to Copy > Copy JS Path and then paste the result. It should be a querySelector for that specific element.

Squirrl
  • 4,909
  • 9
  • 47
  • 85