Wikipedia:WikiProject User scripts/Scripts/Show recent comments

This will eventually allow people to hide discussions on talk pages (or the VP) that occurred before a given date. It is in semi-complete form below.

  • It needs:
    • An interface to set the uptodate.
    • A way to identify sections, rather than just paragraphs, so whole sections that have been updated can be shown, rather than just the paragraphs that have been updated.
    • A option to show, rather than hide, childNodes that have no dates in them.
    • Bells, whistles and gongs, of course!

Please improve, modify, suggest, critique, etc. Thanks! JesseW 09:09, 31 August 2005 (UTC)


uptodate=new Date("Aug 26 2005"); //This is the date which things need to be after to show up.
tokeep=new Array(); //The array that stores the info about which pieces to keep.
bc=document.getElementById("bodyContent"); //Shorthand
z=bc.childNodes; //Shorthand
for (x=0;x<z.length;x++) { //Go through each childNode of bodyContent
  tokeep[x]=z[x]; //Put the node into tokeep (if kept, this will be later be replaced by true.)
  if (z[x].textContent) { //Some things don't have textContent
    //This matches the signature date format. (Odd other formats are not yet handled.)
    q=z[x].textContent.match(/[0-9]+:[0-9]+, [0-9]+ [A-Z][a-z]+ [0-9]+ [(]UTC[)]/);
   if (q) { //Some things don't have any dates in them
      //This turns it into a Date object(it needs to be reformatted for the sake of the parser)
      q=new Date(String(q).replace(/(.+), (.+) [(]UTC[)]/, "$2 $1 GMT"));
     if (q>uptodate) { //Is it after uptodate?
        tokeep[x]=true  //Then keep it.
      }}}};
for (x=0;x<tokeep.length;x++) { //Go through tokeep and do the removals.
  if (tokeep[x]!=true) {
   bc.removeChild(tokeep[x])
 }}


Colorized with http://blogs.applibase.net/prasad/downloads/jscolorizer/jscolorizer.html, pre tags removed, spaces added at the beginning of every line.