Greasy Fork

来自缓存

Greasy Fork is available in English.

ResetEra Remove Unread from URL - Unread link in the line under

Removes /unread from the threads' links and adds a "unread" button underneath

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         ResetEra Remove Unread from URL - Unread link in the line under
// @version      1.0
// @description  Removes /unread from the threads' links and adds a "unread" button underneath
// @author       Lordmau5
// @match        https://*.resetera.com/forums/*
// @grant        none
// @license      MIT
// @namespace http://greasyfork.icu/users/1117666
// ==/UserScript==

(function() {
    'use strict';

    let attempts = 0;

    function tryBustUnread() {
        let cells = document.querySelectorAll('.structItem-cell.structItem-cell--main');
        if (cells.length > 0) {
            cells.forEach(e => {
                let title = e.querySelector('.structItem-title > a:not(.labelLink)');
                let minor = e.querySelector('.structItem-minor > .structItem-parts');

                let url = title.href;
                if (url.includes('/unread')) {
                    title.href = url.replace('/unread', '/');

                    let node = document.createElement('li');
                    let link_node = document.createElement('a');
                    let link_text = document.createTextNode('Unread');
                    link_node.appendChild(link_text);
                    link_node.title = 'Unread';
                    link_node.href = url;
                    node.appendChild(link_node);
                    minor.appendChild(node);
                }
            });
        } else {
            if (attempts++ < 10) {
                setTimeout(tryBustUnread, 250);
            }
        }
    }

    setTimeout(tryBustUnread, 250);
})();