Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Lolicoknight Intended Reading
- // @namespace royalroad.com
- // @include *://*.royalroad.com/fiction/22180/the-lolicoknight/*
- // @include *://*.royalroad.com/fiction/chapter/*
- // @author Degritone
- // @description Modifies elements of the Loliconknight book text to their intended versions
- // @version 1.0.0
- // ==/UserScript==
- function removeSpaces(){
- var menus = document.getElementsByClassName("menu");
- for(var i=0; i<menus.length; i++){
- var nodes = menus[i].childNodes;
- for(var j=nodes.length-1; j>-1; j--){
- if(nodes[j].nodeName == "#text" && nodes[j].nextElementSibling != null)
- menus[i].removeChild(nodes[j]);
- }
- }
- }
- function doStatus(defaultStyle){
- var column = new Array(4);
- column[0] = document.getElementsByClassName("column-0");
- column[1] = document.getElementsByClassName("column-1");
- column[2] = document.getElementsByClassName("column-2");
- column[3] = document.getElementsByClassName("column-3");
- var resources = document.getElementsByClassName("row-1");
- for(var i=0; i<resources.length; i++){
- var width = getComputedStyle(resources[i]).width;
- for(var j=0; j<6; j++){
- var current = column[i%4][j+6*Math.floor(i/4)];
- var thisStyle = defaultStyle;
- thisStyle+=" width: ".concat(width).concat(";");
- if(j==1){
- if(i%4==1)
- thisStyle+=" background-color: #ee5555;";
- else if(i%4==2)
- thisStyle+=" background-color: #888888;";
- else if(i%4==3)
- thisStyle+=" background-color: #5555ee;";
- }
- current.style = thisStyle;
- }
- }
- }
- function doOthers(defaultStyle){
- var other = document.getElementsByClassName("other");
- for(var i=0; i<other.length; i++){
- var thisStyle = defaultStyle;
- var name = other[i].className.replace("other", "");
- if(name.length>0){
- name = name.replace(" ","");
- name = name.replace("_"," ");
- if(!name.startsWith("!"))
- thisStyle+=" "+name;
- else{
- var width = 0;
- var height = 0;
- for(var j=i; j<other.length; j++){
- var cName = other[j].className.replace("other", "");
- cName = cName.replace(" ","");
- if(!cName.startsWith("!"))
- break;
- else{
- if(parseInt(cName.split("-")[1])>=width)
- width = parseInt(cName.split("-")[1])+1;
- if(parseInt(cName.split("-")[1])==0)
- height++;
- }
- }
- var widest = new Array(width);
- for(var j=0; j<width; j++)
- widest[j] = 0;
- for(var j=i; j<i+width*height; j++){
- var thisWidth = parseFloat(getComputedStyle(other[j]).width.replace("px",""));
- if(thisWidth>widest[(j-i)%width])
- widest[(j-i)%width] = thisWidth;
- }
- for(var j=i; j<i+width*height; j++){
- other[j].className = "other width:_"+widest[(j-i)%width]+"px;";
- }
- thisStyle+=" width: "+widest[0]+"px;";
- }
- }
- other[i].style = thisStyle;
- }
- }
- function doFriends(defaultStyle){
- var friendsF = document.getElementsByClassName("friends-f");
- var friendsP = document.getElementsByClassName("friends-+");
- var friendsM = document.getElementsByClassName("friends--");
- var friendsList = document.getElementsByClassName("friends-list");
- var previousLength = 0;
- for(var i=0; i<friendsF.length; i++){
- var length = parseInt(friendsF[i].className.replace("friends-f ",""))+previousLength;
- friendsP[i].style = defaultStyle+" width: 20px;";
- friendsM[i].style = defaultStyle+" width: 20px;";
- var widest = 36+parseFloat(getComputedStyle(friendsF[i]).width.replace("px",""));
- for(var j=previousLength; j<length; j++)
- if(parseFloat(getComputedStyle(friendsList[j]).width.replace("px",""))>widest)
- widest = parseFloat(getComputedStyle(friendsList[j]).width.replace("px",""));
- friendsF[i].style = defaultStyle+" width: "+(widest-36)+"px;";
- for(var j=previousLength; j<length; j++)
- friendsList[j].style = defaultStyle+" width: "+widest+"px;";
- previousLength = length;
- }
- }
- function doBars(){
- var bars = document.getElementsByClassName("resource-bar");
- var tops = document.getElementsByClassName("topnumber");
- var bottoms = document.getElementsByClassName("bottomnumber");
- for(var i=0; i<tops.length; i++){
- tops[i].style = "display: inline-block; margin-top: -9px; vertical-align: top;";
- bottoms[i].style = "display: inline-block; margin-top: -25px; vertical-align: top;";
- }
- for(var i=0; i<bars.length; i++){
- var thisStyle = "display: inline-block; color: #030303; border: 2px solid #333333; margin-left: -2px; margin-top: -2px; width: 160px; text-align: center; height: 30px; line-height: 30px; font-family: times;";
- var color = bars[i].className.replace("resource-bar ","");
- if(color == "health")
- color = "#ee5555";
- else if(color == "mana")
- color = "#5555ee";
- else
- color = "#888888";
- var colored = Math.ceil(parseFloat(tops[i].innerHTML.replace("...",""))/parseFloat(bottoms[i].innerHTML.replace("...",""))*100);
- var background = " background-image: linear-gradient(to right,";
- for(var j=0; j<100; j++){
- if(j<colored)
- background = background.concat(" ").concat(color);
- else
- background = background.concat(" #f5f5f5");
- if(j<99)
- background = background.concat(",");
- else
- background = background.concat(");");
- }
- thisStyle = thisStyle.concat(background);
- bars[i].style = thisStyle;
- }
- }
- function modify(){
- var defaultStyle = "display: inline-block; background-color: #eeeeee; color: #030303; border: 2px solid #333333; text-align: center; height: 30px; line-height: 30px; margin-left: -2px; margin-top: -2px;";
- removeSpaces();
- doStatus(defaultStyle);
- doOthers(defaultStyle);
- doFriends(defaultStyle);
- doBars();
- }
- setTimeout(modify, 1500);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement