Advertisement
Degritone

Intended Reading Script

Dec 21st, 2018
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name     Lolicoknight Intended Reading
  3. // @namespace        royalroad.com
  4. // @include          *://*.royalroad.com/fiction/22180/the-lolicoknight/*
  5. // @include          *://*.royalroad.com/fiction/chapter/*
  6. // @author           Degritone
  7. // @description      Modifies elements of the Loliconknight book text to their intended versions
  8. // @version          1.0.0
  9. // ==/UserScript==
  10.  
  11. function removeSpaces(){
  12.   var menus = document.getElementsByClassName("menu");
  13.   for(var i=0; i<menus.length; i++){
  14.     var nodes = menus[i].childNodes;
  15.     for(var j=nodes.length-1; j>-1; j--){
  16.       if(nodes[j].nodeName == "#text" && nodes[j].nextElementSibling != null)
  17.         menus[i].removeChild(nodes[j]);
  18.     }
  19.   }
  20. }
  21.  
  22. function doStatus(defaultStyle){
  23.   var column = new Array(4);
  24.   column[0] = document.getElementsByClassName("column-0");
  25.   column[1] = document.getElementsByClassName("column-1");
  26.   column[2] = document.getElementsByClassName("column-2");
  27.   column[3] = document.getElementsByClassName("column-3");
  28.   var resources = document.getElementsByClassName("row-1");
  29.   for(var i=0; i<resources.length; i++){
  30.     var width = getComputedStyle(resources[i]).width;
  31.     for(var j=0; j<6; j++){
  32.       var current = column[i%4][j+6*Math.floor(i/4)];
  33.       var thisStyle = defaultStyle;
  34.       thisStyle+=" width: ".concat(width).concat(";");
  35.       if(j==1){
  36.         if(i%4==1)
  37.           thisStyle+=" background-color: #ee5555;";
  38.         else if(i%4==2)
  39.           thisStyle+=" background-color: #888888;";
  40.         else if(i%4==3)
  41.           thisStyle+=" background-color: #5555ee;";
  42.       }
  43.       current.style = thisStyle;
  44.     }
  45.   }
  46. }
  47.  
  48. function doOthers(defaultStyle){
  49.   var other = document.getElementsByClassName("other");
  50.   for(var i=0; i<other.length; i++){
  51.     var thisStyle = defaultStyle;
  52.     var name = other[i].className.replace("other", "");
  53.     if(name.length>0){
  54.       name = name.replace(" ","");
  55.       name = name.replace("_"," ");
  56.       if(!name.startsWith("!"))
  57.         thisStyle+=" "+name;
  58.       else{
  59.         var width = 0;
  60.         var height = 0;
  61.         for(var j=i; j<other.length; j++){
  62.           var cName = other[j].className.replace("other", "");
  63.           cName = cName.replace(" ","");
  64.           if(!cName.startsWith("!"))
  65.             break;
  66.           else{
  67.             if(parseInt(cName.split("-")[1])>=width)
  68.               width = parseInt(cName.split("-")[1])+1;
  69.             if(parseInt(cName.split("-")[1])==0)
  70.               height++;
  71.           }
  72.         }
  73.         var widest = new Array(width);
  74.         for(var j=0; j<width; j++)
  75.           widest[j] = 0;
  76.         for(var j=i; j<i+width*height; j++){
  77.           var thisWidth = parseFloat(getComputedStyle(other[j]).width.replace("px",""));
  78.           if(thisWidth>widest[(j-i)%width])
  79.             widest[(j-i)%width] = thisWidth;
  80.         }
  81.         for(var j=i; j<i+width*height; j++){
  82.           other[j].className = "other width:_"+widest[(j-i)%width]+"px;";
  83.         }
  84.         thisStyle+=" width: "+widest[0]+"px;";
  85.       }
  86.     }
  87.     other[i].style = thisStyle;
  88.   }
  89. }
  90.  
  91. function doFriends(defaultStyle){
  92.   var friendsF = document.getElementsByClassName("friends-f");
  93.   var friendsP = document.getElementsByClassName("friends-+");
  94.   var friendsM = document.getElementsByClassName("friends--");
  95.   var friendsList = document.getElementsByClassName("friends-list");
  96.   var previousLength = 0;
  97.   for(var i=0; i<friendsF.length; i++){
  98.     var length = parseInt(friendsF[i].className.replace("friends-f ",""))+previousLength;
  99.     friendsP[i].style = defaultStyle+" width: 20px;";
  100.     friendsM[i].style = defaultStyle+" width: 20px;";
  101.     var widest = 36+parseFloat(getComputedStyle(friendsF[i]).width.replace("px",""));
  102.     for(var j=previousLength; j<length; j++)
  103.       if(parseFloat(getComputedStyle(friendsList[j]).width.replace("px",""))>widest)
  104.         widest = parseFloat(getComputedStyle(friendsList[j]).width.replace("px",""));
  105.     friendsF[i].style = defaultStyle+" width: "+(widest-36)+"px;";
  106.     for(var j=previousLength; j<length; j++)
  107.       friendsList[j].style = defaultStyle+" width: "+widest+"px;";
  108.     previousLength = length;
  109.   }
  110. }
  111.  
  112. function doBars(){
  113.   var bars = document.getElementsByClassName("resource-bar");
  114.   var tops = document.getElementsByClassName("topnumber");
  115.   var bottoms = document.getElementsByClassName("bottomnumber");
  116.   for(var i=0; i<tops.length; i++){
  117.     tops[i].style = "display: inline-block; margin-top: -9px; vertical-align: top;";
  118.     bottoms[i].style = "display: inline-block; margin-top: -25px; vertical-align: top;";
  119.   }
  120.   for(var i=0; i<bars.length; i++){
  121.     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;";
  122.     var color = bars[i].className.replace("resource-bar ","");
  123.     if(color == "health")
  124.       color = "#ee5555";
  125.     else if(color == "mana")
  126.       color = "#5555ee";
  127.     else
  128.       color = "#888888";
  129.     var colored = Math.ceil(parseFloat(tops[i].innerHTML.replace("...",""))/parseFloat(bottoms[i].innerHTML.replace("...",""))*100);
  130.     var background = " background-image: linear-gradient(to right,";
  131.     for(var j=0; j<100; j++){
  132.       if(j<colored)
  133.         background = background.concat(" ").concat(color);
  134.       else
  135.         background = background.concat(" #f5f5f5");
  136.       if(j<99)
  137.         background = background.concat(",");
  138.       else
  139.         background = background.concat(");");
  140.     }
  141.     thisStyle = thisStyle.concat(background);
  142.     bars[i].style = thisStyle;
  143.   }
  144. }
  145.  
  146. function modify(){
  147.   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;";
  148.   removeSpaces();
  149.   doStatus(defaultStyle);
  150.   doOthers(defaultStyle);
  151.   doFriends(defaultStyle);
  152.   doBars();
  153. }
  154.  
  155. setTimeout(modify, 1500);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement