Greasy Fork

Greasy Fork is available in English.

饭否-免刷新显示无限多新消息

免刷新饭否首页, 去掉显示多于19条新消息需要刷新的限制

当前为 2014-06-16 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name  饭否-免刷新显示无限多新消息
// @author HackMyBrain
// @version 1.0.1
// @description 免刷新饭否首页, 去掉显示多于19条新消息需要刷新的限制
// @create 2013-07-21
// @include http://fanfou.com/home
// @namespace http://greasyfork.icu/users/2844
// ==/UserScript==


(function (){
    var original_title = document.title;
    var count = document.getElementById("timeline-count");
    var noti = document.getElementById("timeline-notification");
    var buffereds = document.getElementsByClassName("buffered");

    function updateTime(){
        var time = new Date().getTime();
        var gap_s, gap_m, gap_h;
        var datestring;
        var stime_list = document.querySelectorAll("[stime]");
        for(var i = 0, l = stime_list.length; i < l; i++){
            if (stime_list[i].innerHTML != stime_list[i].title){
                datestring = stime_list[i].getAttribute("stime");
                gap_s = (time - Date.parse(datestring)) / 1000;
                if (gap_s < 60){
                    stime_list[i].innerHTML = gap_s.toFixed() + " 秒前";
                } else if (60 <= gap_s && gap_s < 3600){
                    gap_m = gap_s / 60;
                    stime_list[i].innerHTML = gap_m.toFixed() + " 分钟前";
                } else if (3600 <= gap_s && gap_s < 86400){
                    gap_h = gap_s / 3600;
                    stime_list[i].innerHTML = "约 " + gap_h.toFixed() + " 小时前";
                } else {
                    stime_list[i].innerHTML = stime_list[i].title;
                }
            }
            else return;
        }
    }

    function showBuffered(e){
        updateTime();
        while(buffereds.length > 0){
            buffereds[0].removeAttribute("class");
        }
        e.stopPropagation();
        e.preventDefault();
        noti.style.display = "none";
        document.title = original_title;
        count.innerHTML = 0;
    }

    noti.addEventListener('click', showBuffered, true);
})()