// ==UserScript==
// @name          MozillaZine Forums - Find user posts
// @namespace     http://loucypher.wordpress.com/
// @include       http://forums.mozillazine.org/viewtopic.php*
// @description	  Add links to find user"s posts
// ==/UserScript==

// Changelog:
// - 2006-12-30: Fixed conflict with Force Wrap user script
// - 2006-09-26: Fixed error if the top poster on the page is guest
// - 2006-07-12: Fixed username with spaces

var users = document.evaluate("//span[@class='name']/b",
            document, null, 6, null);

var aftersig = document.evaluate("//td[@class='gensmallbold' and position()=1]",
               document, null, 6, null);

for(var i = 0; i < aftersig.snapshotLength; i++) {
  var username = '';
  if(users.snapshotItem(i).firstChild.nodeName != "SPAN")
    //username = users.snapshotItem(i).firstChild.nodeValue;
    username = users.snapshotItem(i).textContent;
  var findpost = document.createElement("a");
  findpost.href = "http://forums.mozillazine.org/search.php?search_author=" +
                    username.replace(/\s/g, "+");
  findpost.innerHTML = "[Find all posts by " + username + "]";
  if(aftersig.snapshotItem(i).firstChild.nodeName == "A")
    aftersig.snapshotItem(i).appendChild(findpost);
}

