Greasy Fork is available in English.
Changes colors and formats stats to make it easier to read while scrolling, with Fandom blacklist included in the script.
当前为
// ==UserScript==
// @name Fanfiction.net - Beautify Status Scrolling
// @namespace http://tampermonkey.net/
// @version 1.42
// @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:#006400;}");
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 a_remover(text){
return text.replace(/\<\/a\>/, "");
}
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) +
"<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:
.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);
}
});
})();