// ==UserScript== // @name Fanfiction.net - Beautify Status Scrolling For Dark Reader // @namespace http://tampermonkey.net/ // @version 1.61 // @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:#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'; // 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 rep(pattern, text, replace){ let re = new RegExp(pattern); return text.replace(re, replace); } function mat(pattern, text){ let re = new RegExp(pattern) return re.exec(text)[1]; } // Short-form for replacematch function repmat(pattern, text, replace){ let re = new RegExp(pattern); let num = re.exec(text)[1]; if (replace.startsWith(" "); }else{ return text.replace(re, replace + num + " "); } } function cList(story, status){ let n_sub = status.innerHTML; let ahref if (isReadingPage){ ahref = mat(/Reviews:\s.*?>(.*?)<.*?>/g, n_sub); } else { ahref = mat(//g, story.innerHTML); } // Removes the original Review Link if (!isReadingPage){ let review = story.getElementsByClassName("reviews")[0] review.parentNode.removeChild(review); } let nStoryName; if(isReadingPage){ nStoryName = document.getElementsByClassName("xcontrast_txt")[3]; nStoryName.innerHTML = "" + nStoryName.innerHTML + ""; } else { nStoryName = mat(/(.*?)\s-\sRated:/g, n_sub); n_sub = "" + nStoryName + rep(/(.*?)\s-\sRated:/g, n_sub, " - Rated:"); } n_sub = repmat(/Chapters:\s(.*?)\s/g, n_sub, "
Ch: "); n_sub = repmat(/Words:\s(.*?)\s/g, n_sub, "W: "); if (isReadingPage){ n_sub = repmat(/Reviews:\s.*?>(.*?)<.*?>/g, n_sub, "
Reviews: "); } else { n_sub = repmat(/Reviews:\s(.*?)\s/g, n_sub, "Reviews: ");} n_sub = repmat(/Favs:\s(.*?)\s/g, n_sub, "Favs: "); n_sub = repmat(/Follows:\s(.*?)\s/g, n_sub, "Follows: "); if (n_sub.search(/Updated:\s.*?>(.*?)<.*?\>/) != -1){ n_sub = repmat(/Updated:\s.*?>(.*?)<.*?\>/g, n_sub, "Updated: "); } // 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: n_sub = rep(/
/, n_sub, t + "
"); status.innerHTML = n_sub; status.getElementsByClassName("reviews")[0].setAttribute("href", ahref); } window.addEventListener("load", function() { let stories = document.getElementsByClassName("z-list") 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 stat = document.getElementsByClassName("z-padtop2") for (let i = 0; i < stories.length; i++){ cList(stories[i], stat[i]); } stories = document.getElementsByClassName("profile_top"); stat = document.getElementsByClassName("xgray")[0]; cList(stories, stat); }); })();