Greasy Fork is available in English.
Visual larp: Changes ARS to $ but keeps the number exactly the same
// ==UserScript==
// @name xd2shuffle
// @namespace http://tampermonkey.net/
// @version 7.7.8.0
// @description Visual larp: Changes ARS to $ but keeps the number exactly the same
// @author fusi | @loficat on tg | codedfusi on github
// @match *://*.shuffle.com/*
// @grant none
// @run-at document-start
// @license MIT
// ==/UserScript==
(function () {
const processedTextNodes = new WeakSet();
const processedImages = new WeakSet();
function processTextNode(node) {
if (node.nodeType === 3 && node.nodeValue && !processedTextNodes.has(node)) {
let newValue = node.nodeValue;
let modified = false;
// ONLY replace "ARS" with "$" - leave numbers completely alone
if (newValue.includes("ARS")) {
newValue = newValue.replace(/ARS/g, "$");
modified = true;
}
// Remove any space that appears between the new "$" and the number
if (modified) {
newValue = newValue.replace(/\$\s+/g, '$');
}
if (modified) {
node.nodeValue = newValue;
processedTextNodes.add(node);
}
}
}
function processImageElement(el) {
if (el.nodeType === 1 && el.hasAttribute("src") && !processedImages.has(el)) {
const src = el.getAttribute("src");
if (src && src.includes("/icons/fiat/ARS.svg")) {
el.setAttribute("src", src.replace("/icons/fiat/ARS.svg", "/icons/fiat/USD.svg"));
processedImages.add(el);
}
}
}
function walkAndProcess(root) {
if (!root) return;
const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, null, false);
let node;
while ((node = walker.nextNode())) {
processTextNode(node);
}
const images = root.querySelectorAll('img[src*="/icons/fiat/ARS.svg"]');
images.forEach(img => processImageElement(img));
}
function onMutation(mutations) {
for (const mutation of mutations) {
if (mutation.type === 'childList') {
for (const addedNode of mutation.addedNodes) {
if (addedNode.nodeType === 1) {
walkAndProcess(addedNode);
} else if (addedNode.nodeType === 3) {
processTextNode(addedNode);
}
}
}
}
}
document.addEventListener("DOMContentLoaded", () => {
walkAndProcess(document.body);
const observer = new MutationObserver(onMutation);
observer.observe(document.body, {
childList: true,
subtree: true
});
});
})();