NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name MiningPoolHub balance converter // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author You // @match https://miningpoolhub.com/?page=account&action=balances // @grant none // @license MIT // @copyright 2017, Tatu (https://openuserjs.org/users/Tatu) // ==/UserScript== (function() { 'use strict'; function Get(yourUrl){ var Httpreq = new XMLHttpRequest(); // a new request Httpreq.open("GET",yourUrl,false); Httpreq.send(null); return Httpreq.responseText; } var table = document.getElementById("main").getElementsByClassName("module")[0].getElementsByTagName("tbody")[0]; var total = 0; for(var i=0; i<table.getElementsByTagName("tr").length; i++) { var items = table.getElementsByTagName("tr")[i].getElementsByTagName("td"); var coin = items[0].getElementsByTagName("a")[0].innerHTML; var json; if (coin.startsWith("Digibyte")) coin = "Digibyte"; if (coin.startsWith("Myriad")) coin = "Myriad"; json = JSON.parse(Get("https://api.coinmarketcap.com/v1/ticker/"+ coin + "/?convert=EUR")); if (json.errorjson !== undefined) json = JSON.parse('[{}]'); for(var j=1; j<4; j++){ var amount = items[j].innerHTML; var price; if (amount.indexOf("</a>") !== -1) { var amounts = amount.replace('<a title="Unconfirmed">(', ''); amounts = amounts.replace(')</a>', ''); amounts = amounts.split(" "); if (parseFloat(amounts[0]) !== 0 || parseFloat(amounts[1]) !== 0) { price = [parseFloat(json[0].price_eur)*parseFloat(amounts[0]), parseFloat(json[0].price_eur)*parseFloat(amounts[1])]; items[j].innerHTML = "<span>"+amount+"</span><br><span>"+price[0].toFixed(3)+"€ ("+price[1].toFixed(3)+"€)</span>"; total += price[0] + price[1]; } } else if (parseFloat(amount) !== 0) { price = parseFloat(json[0].price_eur)*parseFloat(amount); items[j].innerHTML = "<span>"+amount+"</span><br><span>"+price.toFixed(3)+"€</span>"; total += price; } } } console.log("Total: " + total.toFixed(3) + "€"); document.getElementById("main").getElementsByClassName("module")[0].getElementsByTagName("header")[0].getElementsByTagName("h3")[0].innerHTML = document.getElementById("main").getElementsByClassName("module")[0].getElementsByTagName("header")[0].getElementsByTagName("h3")[0].innerHTML + " - Total Balance: " + total.toFixed(3) + "€"; })();