The3vilM0nk3y

Exile

Dec 25th, 2021 (edited)
571
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let ships;
  2. let counts, maxes, buildAmount, buildCost, incomes, nextMultiplier, incEach, incomeChange, buildEfficency = [];
  3. let removeStrings = ["Build +", "/", ",", "x "];
  4. let newCount, newIncome;
  5.  
  6. ele = document.createElement('div');
  7. ele.id = "myInfo";
  8.  
  9. document.getElementById("__nuxt").appendChild(ele);
  10.  
  11. function cleanUp(str){
  12.     removeStrings.forEach(rString => {
  13.         str = str.replace(rString, "");
  14.     });
  15.     return str;
  16. }
  17. function round(n) {
  18.     n = Math.floor(n*1000)/1000;
  19.     return n;
  20. }
  21. function formatSeconds(n){
  22.     rawminutes = Math.floor(n/60);
  23.     hours = Math.floor(n/3600);
  24.     minutes = Math.floor(n%3600/60);
  25.     seconds = Math.floor(n%3600%60);
  26.     return hours + ":" + minutes + ":" + seconds;
  27. }
  28. function updateStats(){
  29.     currentIncome = document.getElementById("wrapper").children[0].children[0].children[0].children[2].children[0].children[1].children[1].innerText.replace("e","").split(" ");
  30.     currentCredits = document.getElementById("wrapper").children[0].children[0].children[0].children[2].children[0].children[0].children[1].innerText.replace("e","").split(" ");
  31.     //console.log(currentIncome);
  32.     //console.log(currentCredits);
  33.     shipData = [];
  34.     str = '<div style="position:fixed; right: 5px; top: 35px; background-color: black; width: 15%;"><table><tr> <td>SHIP</td> <td>CHANGE</td> <td>EFFICIENCY</td> <td>~NEW INC</td> </tr>';
  35.     for (i=0; i <= 9; i++) {
  36.         obj = {}
  37.         obj.name = ships.children[i].children[0].children[0].children[1].children[0].children[0].children[0].children[0].innerText;
  38.         obj.count = Number(cleanUp(ships.children[i].children[0].children[0].children[1].children[0].children[0].children[1].children[1].innerText));
  39.         obj.max = Number(cleanUp(ships.children[i].children[0].children[0].children[1].children[0].children[0].children[1].children[2].innerText));
  40.         obj.buildAmount = Number(cleanUp(ships.children[i].children[0].children[0].children[2].children[0].children[0].innerText));
  41.         obj.buildCost = (ships.children[i].children[0].children[0].children[2].children[0].children[1].children[1].innerText.replace("e","").split(" "));
  42.         obj.income = (ships.children[i].children[0].children[0].children[1].children[1].children[0].children[0].children[1].innerText.replace("e","").split(" "));
  43.         obj.nextMultiplier = Number(cleanUp(ships.children[i].children[0].children[0].children[0].children[1].children[0].children[2].children[0].innerText));
  44.         newCount = obj.buildAmount + obj.count;
  45.         obj.incEach = [];
  46.         obj.incEach[0] = obj.income[0]/obj.count;
  47.         if (newCount >= obj.max) {
  48.             obj.incEach[1] = obj.incEach[0] * obj.nextMultiplier;
  49.             //console.log("Multiplier applied for " + obj.name);
  50.         } else {
  51.             obj.incEach[1] = obj.incEach[0];
  52.         }
  53.         //calculate change
  54.         obj.incomeChange = ((obj.incEach[1] - obj.incEach[0]) * obj.count) + (obj.buildAmount * obj.incEach[1]);
  55.         //normalize to same exponential
  56.         while (obj.buildCost[1] > obj.income[1]) {
  57.             obj.buildCost[1] -= 3;
  58.             obj.buildCost[0] = obj.buildCost[0]*1000;
  59.         }
  60.         while (obj.buildCost[1] < obj.income[1]){
  61.             obj.buildCost[1] += 3;
  62.             obj.buildCost[0] = obj.buildCost[0]/1000;
  63.         }
  64.         obj.buildEfficency = obj.incomeChange / obj.buildCost[0];
  65.         obj.buildEfficencyE = 0;
  66.         while (obj.buildEfficency >= 1000) {
  67.       obj.buildEfficencyE += 3;
  68.       obj.buildEfficency = obj.buildEfficency/1000;
  69.     }
  70.     while (obj.buildEfficency < 1){
  71.       obj.buildEfficencyE -= 3;
  72.       obj.buildEfficency = obj.buildEfficency*1000;
  73.     }
  74.  
  75.         while (currentCredits[1] > obj.income[1]) {
  76.             currentCredits[1] -= 3;
  77.             currentCredits[0] = currentCredits[0]*1000;
  78.         }
  79.         while (currentCredits[1] < obj.income[1]){
  80.             currentCredits[1] += 3;
  81.             currentCredits[0] = currentCredits[0]/1000;
  82.         }
  83.  
  84.         while (currentIncome[1] > obj.income[1]) {
  85.             currentIncome[1] -= 3;
  86.             currentIncome[0] = currentIncome[0]*1000;
  87.         }
  88.         while (currentIncome[1] < obj.income[1]){
  89.             currentIncome[1] += 3;
  90.             currentIncome[0] = currentIncome[0]/1000;
  91.         }
  92.         neededCreds = obj.buildCost[0] - currentCredits[0];
  93.         if (neededCreds > 0) {
  94.             obj.neededCreds = neededCreds;
  95.             obj.eta = (neededCreds[0]/currentIncome[0]) / 5;
  96.         } else {
  97.             obj.neededCreds = 0;
  98.             obj.eta = 0;
  99.         }
  100.         shipData.push(obj);
  101.         //console.log(obj.name + " Increase: " + round(obj.incomeChange) + " E" +obj.income[1] + "  Efficiency: " + round(obj.buildEfficency) + " New Value: " + round(newCount * obj.incEach[1]) + " E" + obj.income[1]);
  102.  
  103.         tstring = "<tr> <td>%1</td> <td>%2</td> <td>%3</td> <td>%4</td> <td>%5</td> </tr>";
  104.         tstring = tstring.replace("%1",obj.name).replace("%2",round(obj.incomeChange) + " E" +obj.income[1]).replace("%3",round(obj.buildEfficency) + " E" + obj.buildEfficencyE).replace("%4",round(newCount * obj.incEach[1]) + " E" + obj.income[1]).replace("%5",formatSeconds(obj.eta));
  105.         str += tstring;
  106.     }
  107.     str += "</table></div>";
  108.     ele.innerHTML = str;
  109.     console.log(shipData);
  110. }
  111. var loaded = false;
  112. var autoClickerLoop = setInterval(function () {
  113.     element = document.getElementById("ships");
  114.     if(typeof(element) != 'undefined' && element != null){
  115.         if (loaded != true) {
  116.              ships = document.getElementById("ships").children[0].children[2].children[0];
  117.              loaded = true;
  118.         }
  119.         updateStats();
  120.     }
  121. }, 1000);
  122.  
Advertisement
Add Comment
Please, Sign In to add comment