GC - Max Interest Rate

Calculates and displays how much NP you need in the bank to reach max interest rate (with Ultimate Riches! Interest Rate), and if you have already reached max interest rate, how much NP you are able to withdraw without going below max interest rate.

  1. // ==UserScript==
  2. // @name GC - Max Interest Rate
  3. // @namespace https://greasyfork.org/en/users/1202961-twiggies
  4. // @version 1.01
  5. // @description Calculates and displays how much NP you need in the bank to reach max interest rate (with Ultimate Riches! Interest Rate), and if you have already reached max interest rate, how much NP you are able to withdraw without going below max interest rate.
  6. // @author Twiggies
  7. // @match https://www.grundos.cafe/bank/
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=grundos.cafe
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. var maxInterestAmount = 145997081;
  14.  
  15. var currentBalanceXML = document.evaluate("//strong[text()='Current Balance']", document, null, XPathResult.ANY_TYPE, null );
  16. //This gets the element of the current balance strong.
  17. var currentBalance = currentBalanceXML.iterateNext();
  18.  
  19. //console.log(currentBalance);
  20. var balanceElement = currentBalance.nextSibling;
  21. //Gets the text...
  22. var balanceText = balanceElement.textContent;
  23.  
  24. //Remove the ':' and the 'NP' and the ,. Trim and then parse.
  25. var balance = parseInt(balanceText.replaceAll(':','').replaceAll('NP','').replaceAll(',','').trim());
  26.  
  27. var differenceAmount = balance - maxInterestAmount;
  28.  
  29. var interestBalText = "";
  30.  
  31. if (differenceAmount < 0) {
  32. interestBalText = `<b>Needed for Max Interest:</b> ${(-differenceAmount).toLocaleString()} NP<br>`
  33. }
  34. else {
  35. interestBalText = `<b>Max Interest Balance:</b> ${differenceAmount.toLocaleString()} NP<br>`
  36. }
  37. currentBalance.nextElementSibling.insertAdjacentHTML('afterend',interestBalText);
  38. })();