Right now I'm having a major brain fart. I have this function:
function uplodeVirus(){
  console.log('working')
  console.log('uplodeVirus')
  var form = document.getElementsByTagName('form')[1]
  console.log(form)
  var select = form.children[0]
  console.log(select)
  for (x in select) {
    var lN = select[x].innerHTML // var linkName
    if (lN == "vspam 0.3 [OpenRelay-backdoor.vspam ] (0.003 Gb)"){
      value = select[x].value
      select[x].setAttribute("selected", "selected");
      form.submit()
      break
    }  
  }
}
Don't worry its not a real Virus!!! This is a bot for a game called slave hack - for learning purposes
Anyways, when I call the function:
var ip = '2.2.2.2'
var uplodeVirus = 'http://www.slavehack.com/index2.php?page=internet&var2=' + ip + '&var3=files&aktie=upload'
var currentUrl = window.location.href
console.log(currentUrl)
console.log(uplodeVirus)
if (currentUrl == uplodeVirus) { //Yes, I made sure that currentUrl = uplodeVirus
  uplodeVirus()
}
Nothing happens... but if I take the code out of the function and do this:
if (currentUrl == uplodeVirus){ 
  console.log('working')
  console.log('uplodeVirus')
  var form = document.getElementsByTagName('form')[1]
  console.log(form)
  var select = form.children[0]
  console.log(select)
  for (x in select) {
    var lN = select[x].innerHTML // var linkName
    if (lN == "vspam 0.3 [OpenRelay-backdoor.vspam ] (0.003 Gb)"){
      value = select[x].value
      select[x].setAttribute("selected", "selected");
      form.submit()
      break
    }  
  }
}
It works!!! Now, I could go with option B, but I really want to figure out what i did wrong.
Thanks in advance!
 
     
    