Search code examples
javascripthtmlnode.jshtml-input

Input stops working when I change value (Node.js)


I just want to insert value in text input on https://hordes.io/clans website.

When you natively enter there characters, all elements load automatically. But when I do this: document.getElementsByClassName("navbtn")[0].value += "d" It neither loads new results nor works at all when you try to do anything manually afterwards.

In case with document.getElementsByClassName("navbtn")[0].value += "" it continues working.

I tried another method to enter values there: clicking input field - returns undefined.

Is there any way I can search on this page? By the way I did it just in chrome snippet


Solution

  • I think I've found a decent solution. Their website makes a post request to their api --> https://hordes.io/api/claninfo/list.

    You can pass json to specify which clan you want! Like this:

    POST: https://hordes.io/api/claninfo/list PAYLOAD: {"name":"dmdw","order":1}

    RESPONSE:

    {"clans":[{"name":"Darkmetal Dwarfs","tag":"DmDw","level":9,"gold":"42141","faction":0,"members":"2","prestige":"9446"}]}
    

    You can try the request on reqbin.com following this link with already filled in params: https://reqbin.com/oieogjuu

    Generated code from reqbin.com:

    var url = "https://hordes.io/api/claninfo/list";
    
    var xhr = new XMLHttpRequest();
    xhr.open("POST", url);
    
    xhr.setRequestHeader("Content-Type", "application/json");
    
    xhr.onreadystatechange = function () {
       if (xhr.readyState === 4) {
          console.log(xhr.status);
          console.log(xhr.responseText);
       }};
    
    var data = '{"name":"dmdw","order":1}';
    
    xhr.send(data);