Advertisement
Guest User

Net Chips (Unscuffed)

a guest
Jan 23rd, 2023
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Net Won Chips
  3. // @namespace https://beefox.xyz/
  4. // @version 1
  5. // @description Shows net winnings for completed games, replacing staked amount
  6. // @author Clair Mcrlwain and Beefox
  7. // @match https://www.blaseball.com/
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=blaseball.com
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. const callback = function(mutationsList, observer) {
  15. mutationsList.forEach((mutation) => {
  16. if (mutation.type == "childList") {
  17. mutation.addedNodes.forEach((node) => {
  18. if(node.classList && node.classList.contains("bet-widget__bet-info-lockup")){
  19. let parent = node.parentElement.parentElement
  20. if(parent.querySelectorAll(".bet-widget__info--finished").length == 0) return;
  21. let total = 0;
  22. parent.querySelectorAll(".bet-widget__payout").forEach(el=>{
  23. if(parseInt(el.childNodes[2].textContent) != NaN){
  24. total += parseInt(el.childNodes[2].textContent);
  25. }
  26. })
  27. let stakes = parseInt(node.childNodes[1].textContent);
  28. if(total>=stakes) {
  29. node.querySelector(".bet-widget__bet-info:last-child").childNodes[1].textContent = total - stakes;
  30. node.querySelector(".bet-widget__bet-info:last-child").childNodes[2].textContent = " chips won";
  31. } else {
  32. node.querySelector(".bet-widget__bet-info:last-child").childNodes[1].textContent = stakes - total;
  33. node.querySelector(".bet-widget__bet-info:last-child").childNodes[2].textContent = " chips lost";
  34. }
  35. }
  36. });
  37. }
  38. });
  39. };
  40.  
  41. if (document.hasOwnProperty("_BLASEBALL_USERSCRIPT_REGISTER")) {
  42. document._BLASEBALL_USERSCRIPT_REGISTER("Total Coins Won", callback, (mutations) => (document.querySelector(".bet-widget__bet-info-lockup")));
  43. } else {
  44. const main = document.getElementsByTagName("body")[0];
  45. const config = { childList: true, subtree: true };
  46. const mutationCallback = function(mutationsList, observer) {
  47. callback(mutationsList);
  48.  
  49. observer.disconnect();
  50. observer.observe(main, config);
  51. };
  52.  
  53. const observer = new MutationObserver(mutationCallback);
  54. observer.observe(main, config);
  55. }
  56. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement