Hupu Highlight

突出今日主题;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name           Hupu Highlight
// @namespace      King(legendlee)
// @description    突出今日主题;
// @include        http://bbs.hupu.com/*
// @version        1.0
// ==/UserScript==

var all_data_td, this_td;
all_data_td = document.evaluate(
    "//table[@id='ajaxtable']//td[@class='smalltxt']",
    document,
    null,
    XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
    null);
if (all_data_td.snapshotLength == 0) { //new_style	
	all_data_td = document.evaluate(
		"//table[@id='pl']//td[@class='p_author']",
		document,
		null,
		XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
		null);
}
var date = new Date();
var year= date.getFullYear().toString();
var month = (date.getMonth()+1).toString();
var day = date.getDate().toString();
if(month.length == 1) {
	month = "0" + month;
}
if(day.length == 1) {
	day = "0" + day;
}
var today_str = year + "-" + month + "-" + day;


date.setDate(date.getDate()-1);
month = (date.getMonth()+1).toString();
day = date.getDate().toString();
if(month.length == 1) {
	month = "0" + month;
}
if(day.length == 1) {
	day = "0" + day;
}
var yesterday_str = year + "-" + month + "-" + day;

var reg_today = new RegExp(today_str);
var reg_yesterday = new RegExp(yesterday_str);
for (var i = 0; i < all_data_td.snapshotLength; i++) {
    this_td = all_data_td.snapshotItem(i);
    var html = this_td.innerHTML;
    
    if(reg_today.test(html)){
    	this_td.parentNode.style.backgroundColor = '#FFFFCC';
    	this_td.parentNode.style.fontWeight = "bold";
    }
	if(reg_yesterday.test(html)){
    	this_td.parentNode.style.backgroundColor = '#CCFFFF';
    	this_td.parentNode.style.fontWeight = "bold";
    }
}