I cant figure out why this wont return the highest target. The variable highest_target is placed outside the for loop.
Code:var highest_target; var inputs = divs[i].getElementsByTagName('INPUT'); var bounty_target = 'http://apps.facebook.com/mobwars/fight/do.php?'; var target_id = ''; var bounty_id = ''; var bounty = parseInt(dollars_to_int(divs[i].parentNode.parentNode.getElementsByTagName('TD')[2].innerHTML)); for (var j = 0; j < inputs.length; j++) { bounty_target += inputs[j].name + "=" + inputs[j].value + "&"; if (inputs[j].name == "target_id") target_id = inputs[j].value; if (inputs[j].name == "bounty_id") bounty_id = inputs[j].value; } var highest_target_id; //for debug message only var bounty = parseInt(dollars_to_int(divs[i].parentNode.parentNode.getElementsByTagName('TD')[2].innerHTML)); debug_msg += '<font color=red>' + bounty + '</font><br />'; GM_log(bounty); if ((bounty < boss.preferences.bounty_max || boss.preferences.bounty_max == 0) && bounty > boss.preferences.bounty_min && bounty > highest) { target_acquired++; highest = bounty; debug_msg += '<font color=red>' + highest + '</font><br />'; GM_log("highest " + highest); highest_target = bounty_target; highest_target_id = target_id; //for debug message only }



Reply With Quote

Bookmarks