title: Loops in GreaseMonkey
body: <p>I'm developing my first greasemonkey script (trying to edit and add page content to a particular website) and for some reason, it refuses to work beyond one <code>while</code> loop.. Eg :</p>
  
  <pre><code>var anchorTag = window.document.getElementsByTagName('a');
  var anchorTagNumber = window.document.getElementsByTagName('a').length;
  ..
  ..
  i = 0
  j = 0;
  function collectId(i,link) {
      linkArray[j] = new Array(2);
      linkArray[j][0] = i;
      linkArray[j][1] = link;
      j++;
  }
  
  
  while(i &lt;= anchorTagNumber)
  {
      testHref = anchorTag[i].href;
      testHTML = anchorTag[i].innerHTML;
      patHref = /some regex/;
      patCaptureId = /some regex/;
      testId = patCaptureId.exec(testHref);
      patHTML = /some regex/;
      patHTML2 = /some regex/;
      patHTML3 = /some regex/;
      if(patHref.test(testHref) &amp;&amp; !patHTML.test(testHTML) &amp;&amp; !patHTML2.test(testHTML))
      {
          linkId = testId[1];
          collectId(i,linkId);
      }
      i++;
  }
  </code></pre>
  
  <p>Anything after this while loop ends, refuses to work. Even a simple <code>alert</code> doesn't seem to execute. I have another <code>while</code> loop with a similar structure, and if I put that one first, it executes and this one doesn't. Any Ideas ? Thanks in advance !</p>