Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Net Won Chips
- // @namespace https://beefox.xyz/
- // @version 1
- // @description Shows net winnings for completed games, replacing staked amount
- // @author Clair Mcrlwain and Beefox
- // @match https://www.blaseball.com/
- // @icon https://www.google.com/s2/favicons?sz=64&domain=blaseball.com
- // ==/UserScript==
- (function() {
- 'use strict';
- const callback = function(mutationsList, observer) {
- mutationsList.forEach((mutation) => {
- if (mutation.type == "childList") {
- mutation.addedNodes.forEach((node) => {
- if(node.classList && node.classList.contains("bet-widget__bet-info-lockup")){
- let parent = node.parentElement.parentElement
- if(parent.querySelectorAll(".bet-widget__info--finished").length == 0) return;
- let total = 0;
- parent.querySelectorAll(".bet-widget__payout").forEach(el=>{
- if(parseInt(el.childNodes[2].textContent) != NaN){
- total += parseInt(el.childNodes[2].textContent);
- }
- })
- let stakes = parseInt(node.childNodes[1].textContent);
- if(total>=stakes) {
- node.querySelector(".bet-widget__bet-info:last-child").childNodes[1].textContent = total - stakes;
- node.querySelector(".bet-widget__bet-info:last-child").childNodes[2].textContent = " chips won";
- } else {
- node.querySelector(".bet-widget__bet-info:last-child").childNodes[1].textContent = stakes - total;
- node.querySelector(".bet-widget__bet-info:last-child").childNodes[2].textContent = " chips lost";
- }
- }
- });
- }
- });
- };
- if (document.hasOwnProperty("_BLASEBALL_USERSCRIPT_REGISTER")) {
- document._BLASEBALL_USERSCRIPT_REGISTER("Total Coins Won", callback, (mutations) => (document.querySelector(".bet-widget__bet-info-lockup")));
- } else {
- const main = document.getElementsByTagName("body")[0];
- const config = { childList: true, subtree: true };
- const mutationCallback = function(mutationsList, observer) {
- callback(mutationsList);
- observer.disconnect();
- observer.observe(main, config);
- };
- const observer = new MutationObserver(mutationCallback);
- observer.observe(main, config);
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement