Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

necro weed posting considered harmful

Name: Anonymous 2010-06-02 13:12

on the other hand /prog/ actually was good once

Name: Anonymous 2010-06-02 16:07

>>5
Yeah, thanks bro. I am well aware that we have an anti-necrobump script already, I do remember last year. I was writing the script for a reason, in this instance to try and reacquaint myself with Javascript and the DOM. But assuming that I hadn't heard of it, and was new here, it's not like we've advertised the anti-necro script much this year, as there has been less need for it. How would a newbie know?

For those that care, the problem was retardedly simple. I forgot that when the child was removed from the DOM, it was also removed from the threads array. And therefore, the call to threads.length was different every time. The solution is below
var dateregex = /^2010/;
var threads = document.getElementsByClassName('thread');
var len = threads.length
for (i=0; i < len;) {
  var thread = threads[i];
  var opdate =  thread.getElementsByClassName('posterdate')[0].firstChild.nodeValue;
  if (!dateregex.test(opdate)) {
    var parent = thread.parentNode;
    var grandparent = parent.parentNode;
    grandparent.removeChild(parent);
  } else {
  i++;
  }
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List