Color the thread reply number based on the post count.
Verzia zo dňa
// ==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";
}
}
}
})();