Keep code sequence after refresh

0

I would like to know how to keep my script after updating the page, since my javascript as soon as it is loaded acts as if it were the first time. The idea is to check a condition (Hp), refresh the page and click a button. Something similar to what imacros does.

var energy  =   Number(document.getElementById("infobar_energy").getElementsByClassName("infobar_line_value")[0].innerHTML.replace(" ","").replace("/ ","/").slice(0,document.getElementById("infobar_energy").getElementsByClassName("infobar_line_value")[0].innerHTML.replace(" ","").replace("/ ","/").indexOf('/')));
var server = 'https://s103-br.bitefight.gameforge.com';
if (energy > 0 ){
    if (window.location.href.includes("/humanhunt/humanHunt/2?__token=")){
        window.location.href = server + "/robbery/index"; 
    }
    if (window.location.href.includes("/humanhunt/index")){
        document.getElementsByClassName("btn-right")[3].getElementsByTagName('button')[0].click();
    }else{
        window.location.href = server + "/humanHunt/index"; 
    }
}
    
asked by anonymous 02.09.2018 / 22:06

0 answers