GC - Games Points til Max NP

Adds to games a quick reference of how many points you'll need to max out your remaining NP.

当前为 2023-11-20 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name GC - Games Points til Max NP
  3. // @namespace https://greasyfork.org/en/users/1202961-13ulbasaur
  4. // @version 0.1
  5. // @description Adds to games a quick reference of how many points you'll need to max out your remaining NP.
  6. // @author You
  7. // @match https://www.grundos.cafe/games/html5/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=grundos.cafe
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. // Your code here...
  14. const gameInfo = document.querySelector('div.games-info div.bg-action')
  15. //Get the np per points info
  16. const npPerPoints = Number(gameInfo.querySelector('div:first-child span:first-child strong:nth-child(2)').textContent.replaceAll(/(?=NP).*/gi,'').replaceAll(',','').trim());
  17. //Get max NP
  18. const maxNP = Number(gameInfo.querySelector('div:nth-child(2) span:first-child strong:nth-child(2)').textContent.replaceAll(',','').trim());
  19. //Get the remaining NP to obtain
  20. const npRemaining = maxNP-Number(document.getElementById('np_earned').textContent.replaceAll('NP','').replaceAll(',','').trim());
  21. let pointsToEarn;
  22.  
  23. if (npRemaining > 0) {
  24. //Points to get calculation:
  25. //Rounded up since I dont think any games have decimal point points.
  26. pointsToEarn = Math.ceil(npRemaining/npPerPoints)
  27. }
  28. else {
  29. pointsToEarn = 'All Done!'
  30. }
  31. gameInfo.querySelector('div:nth-child(2)').insertAdjacentHTML('beforebegin',`<span style='text-align:center'>Points to Max:<br><strong>${pointsToEarn}</strong></span>`)