Skip to content

Instantly share code, notes, and snippets.

@Qalthos
Last active January 24, 2023 15:29
Show Gist options
  • Save Qalthos/6fab912eec9576aa1157e4327c5b137d to your computer and use it in GitHub Desktop.
Save Qalthos/6fab912eec9576aa1157e4327c5b137d to your computer and use it in GitHub Desktop.
Blaseball Hexdecimal Innings
// ==UserScript==
// @name Blaseball Hex Innings
// @namespace http://linkybook.com
// @version 0.3
// @description Rewrite extra innings in hexdecimal
// @author Qalthos
// @match https://blaseball.com/*
// @match https://www.blaseball.com/*
// ==/UserScript==
(function() {
"use strict";
const NAMESPACE = "Blaseball Hex Innings";
function hexamatize(match, p1, p2) {
p1 = parseInt(p1).toString(16);
return [p1, p2].join("");
};
const callback = function(mutationsList) {
// Every time there's an update in the DOM (yuck)...
const innings = document.getElementsByClassName("game-widget__inning");
// The extra space means we haven't hit it yet
const regex = /^(\d+)(\w\w) $/;
for (const widget of innings) {
const textNode = widget.childNodes[1];
debugger;
textNode.textContent = textNode.textContent.replace(regex, hexamatize);
}
};
if (document.hasOwnProperty("_BLASEBALL_USERSCRIPT_REGISTER")) {
document._BLASEBALL_USERSCRIPT_REGISTER(NAMESPACE, callback, (mutations) => (document.querySelector(".game-widget__inning")));
} 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);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment