MozillaZine Forums - Find user posts

Add links to find user"s posts

  1. // ==UserScript==
  2. // @name MozillaZine Forums - Find user posts
  3. // @namespace http://loucypher.wordpress.com/
  4. // @description Add links to find user"s posts
  5. // @icon https://raw.github.com/gist/1087992/icon.png
  6. // @include http://forums.mozillazine.org/viewtopic.php*
  7. // @version 0.0.1.20140630034959
  8. // ==/UserScript==
  9.  
  10. // Changelog:
  11. // - 2012-07-04: Updated.
  12. // - 2008-06-26: Updated to new forums
  13. // - 2006-12-30: Fixed conflict with Force Wrap user script
  14. // - 2006-09-26: Fixed error if the top poster on the page is guest
  15. // - 2006-07-12: Fixed username with spaces
  16.  
  17.  
  18. var users = document.evaluate("//div[@class='postprofile']/dt/a",
  19. document, null, 6, null);
  20.  
  21. if (!users.snapshotLength) return;
  22.  
  23. var user, userId, userName, posts;
  24. for (var i = 0; i < users.snapshotLength; i++) {
  25. user = users.snapshotItem(i);
  26. userName = user.textContent;
  27. userId = user.href.match(/\d+/);
  28. posts = document.evaluate("./parent::dt/parent::div/dd/strong[text()='Posts:']",
  29. user, null, 9, null).singleNodeValue;
  30. makeLink(posts.parentNode, userName, userId);
  31. }
  32.  
  33. function makeLink(aNode, aName, aId) {
  34. var link = document.createElement("a");
  35. link.title = "Search " + aName + "'s posts";
  36. link.href = "./search.php?sr=posts&author_id=" + aId;
  37. link.style.marginLeft = ".5em";
  38.  
  39. var img = link.appendChild(document.createElement("img"));
  40. img.src = "./styles/prosilver/theme/images/icon_textbox_search.gif";
  41. img.style.verticalAlign = "middle";
  42.  
  43. aNode.appendChild(link);
  44. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址