Inactivity Reminder for E-Hentai Forum

Change the color of your ID to red if the last post you made was more than 24 hours ago

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Inactivity Reminder for E-Hentai Forum
// @include     http://forums.e-hentai.org/*
// @version 0.0.1.20151024050011
// @namespace https://greasyfork.org/users/2233
// @description Change the color of your ID to red if the last post you made was more than 24 hours ago
// ==/UserScript==

/*** Setting ***/
var time_difference = 604800 // when the difference btwn current time and the time last post was made is greater than this, ID becomes red. in seconds.

/*** End of Setting ***/

var wnd = window
var doc = wnd.document
var loc = location
var href = loc.href

var $  = function(e, css) { if(!css) { css=e; e=doc }; return e.querySelector(css) }
var $$ = function(e, css) { if(!css) { css=e; e=doc }; return e.querySelectorAll(css) }

var get_cookie = function(k) {
    var nameEQ = k + '='
    var ca = doc.cookie.split(';')
    for(var i=0, len=ca.length; i<len; i++) {
        var c = ca[i]
        while(c.charAt(0)==' ') { c = c.substring(1, c.length) }
        if(c.indexOf(nameEQ) == 0) { return c.substring(nameEQ.length, c.length) }
    }
    return null
}
var set_cookie = function(k, v) { doc.cookie = k + '=' + escape(v) + '; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/' }
var del_cookie = function(k) { doc.cookie = k + '=; expires=Fri, 31 Dec 1999 23:59:59 GMT; path=/' }

var btn_add_reply = $('input[value="Add Reply"]')
if(btn_add_reply) {
    btn_add_reply.addEventListener('click', function() {
        var now = Math.floor(new Date().getTime()/1000)
        set_cookie('last_topic', now)
    }, false)
}

var update_timer = function() {
    var is_active = false
    var last_topic = unescape(get_cookie('last_topic'))
    if(last_topic) {
        var now = Math.floor(new Date().getTime()/1000)
        if(now - last_topic <= time_difference) { is_active = true } else { del_cookie('last_topic') }
    }
    if(!is_active) { $('#userlinks a[href^="http://forums.e-hentai.org/index.php?showuser="]').style.color = 'red' }
    setTimeout(update_timer, 60000)
}
update_timer()