How do I programmatically push this damn div?

  • 0
    Hello. There is a big problem with the gaming site. It has arrows that move the character in one of 8 directions on the map. Programmatically, you need to click on the button, but methods like .click (), .RaiseEvent ("click") do not work. I am looking for a solution for the 7th hour. My head hurts because of this small game, which prevents me from making a bot. Are there people who understand this?
    JavaScript Anonymous, Feb 9, 2019

  • 1 Answers
  • 0
    What if so? It's all in the console (to check).

    function simulateClick(node) {
    function trigger(node, event_name) {
    var ev = document.createEvent('MouseEvents');
    ev.initEvent(event_name, true, true);
    node.dispatchEvent(ev);
    }
    trigger(node, "mouseover");
    trigger(node, "mousedown");
    trigger(node, "mouseup");
    trigger(node, "click");
    }

    var div = document.getElementById("dbut8"); //Ищем нужный див.
    simulateClick(div); //Полноценно кликаем по нему.


    P.S. I did not open the site by reference.
    Hudson Sellers

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!