// ==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 // @downloadURL none // ==/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 and places it to " - Fa:" var text = review.outerHTML.replace(/>reviewsReviews: <").replace(/\<\/a\>/, ""); // Removes // 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.replace(/\s\-\sRated:/, " - Rated:"); } n_sub = n_sub // Places the start span at Chapters; ends span at Words .replace(/Chapters:/, "Ch:") .replace(/\s\-\sWords:/, " - W:") // Ends span before - from "Reviews: ..." and Starts span before "Favs:" .replace(/\s\-\sFavs:/, " - Favs:") // Ends before "Published:" .replace(/\s\-\sPublished:/, " - Published:"); // Moves the "Publish: ... Characters:" before "
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
before W: .replace(/\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); } }); })();