Greasy Fork

Greasy Fork is available in English.

Beautify Story List fanfiction.net

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         Beautify Story List fanfiction.net
// @namespace    http://tampermonkey.net/
// @version      1.1
// @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(".greenHighlight {color:#C4FFCA;}");
GM_addStyle(".redHighlight {color:#CC5500;}");
GM_addStyle(".yellowHighlight {color:#FFC300;}");
GM_addStyle(".pinkHighlight {color:#FFC0CB;}");
GM_addStyle(".z-indent {padding-left: 60px;}");

(function() {
    'use strict';

    // Remove fandoms from view page
    // const blacklist_fandoms = ["Harry", "Doctor Who", "Crossover - Star Wars", "Yu-Gi-Oh"]
    const blacklist_fandoms = [];

    function customList(story, stat){
        let n_sub = stat.innerHTML
        if (!document.URL.startsWith("https://www.fanfiction.net/s/")) {
            // Moves reviews link to stat
            let review = story.getElementsByClassName("reviews")[0]
            // This removes </a> and places it to "</a> - <span class='greenHighlight'>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);
        }

        // Places the start span at Chapters; ends span at Words
        n_sub = n_sub.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='greenHighlight'>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")

        // Apply n_sub to stat.innerHTML
        stat.innerHTML = n_sub;
        // The summary color in Grey
        story.style.color = "#131E3A";
    }
    window.addEventListener("load", function() {
        // The rows of stories
        let stories = document.getElementsByClassName("z-list")
        for (let i = stories.length - 1; i > -1; i--){
            let storyContent = stories[i].getElementsByClassName("z-padtop2")
            let text = storyContent[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]);
        }

        // For viewing inside stories
        if (document.URL.startsWith("https://www.fanfiction.net/s")) {
            status = document.getElementsByClassName("xgray")[0];
            customList(stories[0], status);
        }
    });
})();