Greasy Fork

Greasy Fork is available in English.

Fanfiction.net - Beautify Status Scrolling For Dark Reader

Changes colors and formats stats to make it easier to read while scrolling, with Fandom blacklist included in the script.

当前为 2022-07-19 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Fanfiction.net - Beautify Status Scrolling For Dark Reader
// @namespace    http://tampermonkey.net/
// @version      1.51
// @description  Changes colors and formats stats to make it easier to read while scrolling, with Fandom blacklist included in the script.
// @author       バカなやつ
// @license      MIT
// @match        https://www.fanfiction.net/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=fanfiction.net
// @grant        GM_addStyle
// ==/UserScript==
GM_addStyle(".lightGreenHighlight {color:#C4FFCA;}");
GM_addStyle(".greenHighlight {color:#04AD5C;}");
GM_addStyle(".redHighlight {color:#CC5500;}");
GM_addStyle(".yellowHighlight {color:#FFC300;}");
GM_addStyle(".pinkHighlight {color:#FFC0CB;}");
GM_addStyle(".z-indent {padding-left: 60px;}");
GM_addStyle(".reviews {color: rgb(255, 102, 26); text-decoration-color: initial;}");
(function() {
    'use strict';

    // Remove fandoms from view page
    // const blacklist_fandoms = ["Harry", "Doctor Who", "Crossover - Star Wars", "Yu-Gi-Oh"]
    const blacklist_fandoms = [];
    let isReadingPage = document.URL.startsWith("https://www.fanfiction.net/s/")

    function customList(story, stat){
        let n_sub = stat.innerHTML
        if (!isReadingPage) {
            // Moves reviews link to stat
            let review = story.getElementsByClassName("reviews")[0]
            // This removes </a> and places it to "</a> - <span class='lightGreenHighlight'>Fa:"
            var text = review.outerHTML.replace(/>reviews</, ">Reviews: <").replace(/\<\/a\>/, ""); // Removes </a>
            // Removes the original Reviews Link
            review.parentNode.removeChild(review);
            // Places the variable text to subContent[i] and replaces "Reviews:"
            n_sub = n_sub.replace(/Reviews:/, text);
            n_sub ="<span class='greenHighlight'>" + n_sub.replace(/\s\-\sRated:/, "</span> - Rated:");
        }

        n_sub = n_sub
            // Places the start span at Chapters; ends span at Words
            .replace(/Chapters:/, "<span class='yellowHighlight'>Ch:")
            .replace(/\s\-\sWords:/, " - </span><span class='pinkHighlight'>W:")
            // Ends span before <a
            .replace(/\s\-\s\<a/, "</span> - <a")
            // Closes <a> from "Reviews: ..." and Starts span before "Favs:"
            .replace(/\s\-\sFavs:/, "</a> - <span class='lightGreenHighlight'>Favs:")
            // Ends <span> before "Published:"
            .replace(/\s\-\sPublished:/, "</span> - Published:");

        // Moves the "Publish: ... Characters:" before "<br>Chapters:"
        let t = n_sub.slice(n_sub.search(/Published:/))
        // Remove previous "Publish: ... Characters:"
        n_sub = n_sub.slice(0, n_sub.search(/\s\-\sPublished:/));
            // puts <br> before <span class='yellowHighlight'>W:
        n_sub = n_sub.replace(/\<span class='yell/, t + "<br><span class='yell")

        // Fix for missing .review css in story reading  page
        if (isReadingPage) {
            let a = stat.getElementsByTagName("a")[1]
            n_sub = n_sub.replace(/\s-\sReviews:/, " - </span><a class='reviews' href="+ a.href +">Reviews: " + a.innerHTML);
        }

        // Apply n_sub to stat.innerHTML
        stat.innerHTML = n_sub;

        // Fix for duplicate review link
        if (isReadingPage) {
            let a = stat.getElementsByTagName("a")[2];
            a.parentNode.removeChild(a);
        }
        // The summary color in Grey
        story.style.color = "#131E3A";
    }
    window.addEventListener("load", function() {
        let stories = document.getElementsByClassName("z-list")
        // Removes divs that contain blacklisted fandom inside the stats.
        for (let i = stories.length - 1; i > -1; i--){
            let stat = stories[i].getElementsByClassName("z-padtop2")
            let text = stat[0].innerHTML
            if (blacklist_fandoms.some(v => text.includes(v))) {
                stories[i].parentNode.removeChild(stories[i]);
            }
        }
        let status = document.getElementsByClassName("z-padtop2")
        for (let i = 0; i < stories.length; i++){
            customList(stories[i], status[i]);
        }

        if (isReadingPage) {
            status = document.getElementsByClassName("xgray")[0];
            customList(stories[0], status);
        }
    });
})();