Script only runs once
<p>This is a script that [should] refresh a page, find the price, and if the price is lower than what the user specifies, buys it. If the price is higher, it refreshes the page and does it again until the price is found:</p>

<pre><code>var tags = document.getElementsByTagName('b');
var price;
var lp;
var sp;
var setSnipe = false;
var loaded = false;
for (i = 0; i &lt; tags.length; i++) {
    console.log(tags[i].innerHTML);
    if( tags[i].innerHTML.indexOf('R$') !== -1) {
        if (i==5){
            var price = tags[i].innerHTML.match(/\d+/)[0];
            setSnipe = confirm("Lowest price: R$" + price +". Set a sniper?");
        } else {
        }
    } else {
    }
}
if (setSnipe == true) {
    lp = prompt("Snipe Price?");
    refresh();
}

function refresh() {
    location.reload(true);
    setTimeout('checkSnipe()', 3000);
}

function checkSnipe() {
    var tagss = document.getElementsByTagName('b');
    for (i = 0; i &lt; 6; i++) {
        console.log(tagss[i].innerHTML);
        if( tagss[i].innerHTML.indexOf('R$') !== -1) {
            if (i==5){
                var price = tagss[i].innerHTML.match(/\d+/)[0];
                price = Number(price);
                if (price&lt;=lp){
                    alert("Snipe Found!");
                } else {
                    alert("No snipe");
                    refresh();
                }
            }
        }
    }
}
</code></pre>

<p>For some reason, it only runs once then stops. Any advice/help?</p>

<p>Thanks,
Alex</p>
