S1论坛已阅提示

S1论坛已阅提示,ignore old thread on saraba1st

当前为 2019-12-28 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         S1论坛已阅提示
// @namespace    http://www.saraba1st.com/
// @version      0.3
// @description  S1论坛已阅提示,ignore old thread on saraba1st
// @author       不能放过孩子
// @match        *.saraba1st.com/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';
    var ignoreIdList = localStorage.getItem("ignoreIdList");
    if (ignoreIdList && ignoreIdList.length / 1024 > 20) {//限制最大20kb后重置
        ignoreIdList = '';
    }
    ignoreIdList = ignoreIdList.replace(/\"/g, '');
    ignoreIdList = ignoreIdList.replace(/\\/g, '');
    if (ignoreIdList) {
        var ignore = ignoreIdList.split(',');
        if (typeof (ignore) !== 'object' || ignore.length <= 0) {
            ignore = [];
        }
    } else {
        var ignore = [];
    }
    var pushList = [];
    var threadlist = document.getElementsByClassName('xst');
    for (var index in threadlist) {
        var href = threadlist[index].href;
        if (href) {
            var threadMatch = href.match(/thread\-[0-9]+\-/g);
            var threadStr = threadMatch && threadMatch.length > 0 ? threadMatch[0] : '';
            var treadIdMatch = threadStr.match(/[0-9]+/g);
            var idStr = threadStr && threadStr.length > 0 ? treadIdMatch[0] : '';
            if (idStr) {
                var patt = null;
                var exist = false;
                for (var i in ignore) {
                    if (typeof (ignore[i]) === 'string') {
                        var ignoreId = ignore[i];
                        patt = new RegExp(ignoreId, "g");
                        if (patt.test(idStr)) {
                            exist = true;
                        }
                    }
                }
                if (exist) {
                    threadlist[index].style.color = 'gray';
                } else {
                   pushList.push(idStr);
                }
            }
        }
    }
    var newIgnore = ignore.concat(pushList);
    var ignoreIdList = newIgnore.join(',');
    localStorage.setItem("ignoreIdList", JSON.stringify(ignoreIdList));
})();