NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Yata Totalizador plushie/flower // @namespace torn.tauame // @version 0.1 // @description Exibe valor total dos Plushies e Flowers no YATA // @author tauame // @match https://yata.alwaysdata.net/bazaar/* // @grant none // @license GPL-3.0-or-later // @updateURL https://openuserjs.org/meta/tauame/Yata_Totalizador_plushieflower.meta.js // @downloadURL https://openuserjs.org/install/tauame/Yata_Totalizador_plushieflower.user.js // ==/UserScript== function updateItems(category){ //find category header tag var aTags = document.getElementsByTagName("h2"); var searchText = category; var found; for (var i = 0; i < aTags.length; i++) { if (aTags[i].innerText.indexOf(searchText) >= 0) { found = aTags[i]; break; } } var categoryHeaderNode = found; if(categoryHeaderNode == null)return; //loop thought items var itemTables = $("#loop-over-item-sell-table-"+category)[0].children; var totalValue = 0; for (i =0; i < itemTables.length; i++){ var pTable = itemTables[i]; var cheapestItem = pTable.children[1].rows[0].cells[1].innerText; totalValue += parseInt(cheapestItem.replace("$","").replace(",","")); } var re = new RegExp(searchText+"\ -\ Total\ value:\ \\$\\d*","g"); if(categoryHeaderNode.childNodes[1].nodeValue.search(""+totalValue)==-1){ if(categoryHeaderNode.childNodes[1].nodeValue.search(re)==-1){ categoryHeaderNode.childNodes[1].nodeValue = categoryHeaderNode.childNodes[1].nodeValue.replace(searchText, searchText + " - Total value: $"+totalValue); }else{ categoryHeaderNode.childNodes[1].nodeValue = categoryHeaderNode.childNodes[1].nodeValue.replace(re, searchText + " - Total value: $"+totalValue); } } } var observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { updateItems("Plushie"); updateItems("Flower"); }); }); (function() { 'use strict'; updateItems("Plushie"); updateItems("Flower"); observer.observe(document,{ childList: true, attributes: true, characterData: true, subtree: true, attributeOldValue: true, characterDataOldValue: true }); })();