MozillaZine Forums - Find user posts

Add links to find user"s posts

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name            MozillaZine Forums - Find user posts
// @namespace       http://loucypher.wordpress.com/
// @description     Add links to find user"s posts
// @icon            https://raw.github.com/gist/1087992/icon.png
// @include         http://forums.mozillazine.org/viewtopic.php*
// @version 0.0.1.20140630034959
// ==/UserScript==

// Changelog:
// - 2012-07-04: Updated.
// - 2008-06-26: Updated to new forums
// - 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("//div[@class='postprofile']/dt/a",
                              document, null, 6, null);

if (!users.snapshotLength) return;

var user, userId, userName, posts;
for (var i = 0; i < users.snapshotLength; i++) {
  user = users.snapshotItem(i);
  userName = user.textContent;
  userId = user.href.match(/\d+/);
  posts = document.evaluate("./parent::dt/parent::div/dd/strong[text()='Posts:']",
                            user, null, 9, null).singleNodeValue;
  makeLink(posts.parentNode, userName, userId);
}

function makeLink(aNode, aName, aId) {
  var link = document.createElement("a");
  link.title = "Search " + aName + "'s posts";
  link.href = "./search.php?sr=posts&author_id=" + aId;
  link.style.marginLeft = ".5em";

  var img = link.appendChild(document.createElement("img"));
  img.src = "./styles/prosilver/theme/images/icon_textbox_search.gif";
  img.style.verticalAlign = "middle";

  aNode.appendChild(link);
}