[HF] Colored thread reply numbers

Color the thread reply number based on the post count.

La data de 01-05-2016. Vezi ultima versiune.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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";
                postCountElement.style.fontWeight = "bold";
            }
            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";
            }

        }
    }
})();