[HF] Colored thread reply numbers

Color the thread reply number based on the post count.

目前为 2016-05-01 提交的版本,查看 最新版本

// ==UserScript==
// @name         [HF] Colored thread reply numbers
// @namespace    @iNeo19
// @version      0.1
// @description  Color the thread reply number based on the post count.
// @author       You
// @match        http://hackforums.net/search.php?action=results&sid=*
// @grant        none
// ==/UserScript==

function getElementByXpath(path) {
  return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
}

(function() {
    'use strict';
    var threadList = getElementByXpath('//*[@id="content"]/div[2]/table[2]/tbody');
    var threads = threadList.getElementsByTagName("tr");
    for(var threadIndex=0;threadIndex<threads.length;threadIndex++) {
        var threadData = threads[threadIndex].getElementsByClassName("forumdisplay_regular");
        var postCountRow = threadData[2];
        if (postCountRow) {
            var postCountRaw = postCountRow.getElementsByTagName("a");
            var postCountElement = postCountRaw[0];
            var postCount = postCountElement.innerHTML;
            if (postCount <= 0) {
                postCountElement.style.color = "#33accc";
            }
            else if (postCount <= 10) {
                postCountElement.style.color = "#329C32";
            }
            else if (postCount > 100) {
                postCountElement.style.color = "#ff0000";
             }
            else if (postCount > 10) {
                postCountElement.style.color = "#cc8f33";
             }
            else if (postCount.indexOf(',') >= 0) {
                postCountElement.style.color = "cyan";
            }

        }
    }
})();

QingJ © 2025

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