Created
August 23, 2022 12:10
-
-
Save leoli-dev/03bd9d09fce93a6e5a031462eda1ed67 to your computer and use it in GitHub Desktop.
Calcalator for Ethermine payouts page | Tampermonkey script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Ethermine total calculation | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Script for calculating the total of mined ETH | |
// @author Leo LI | |
// @match https://ethermine.org/miners/*/payouts | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=ethermine.org | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
setTimeout(() => { | |
const calculateTotal = () => { | |
let total = 0 | |
document.querySelectorAll('.number.amount') | |
.forEach((element, index) => { | |
const amount = element.innerHTML | |
if (undefined === amount) { | |
return | |
} | |
total += Number.parseFloat(amount) | |
}) | |
return total | |
} | |
const payoutsContainerDiv = document.querySelector('.payout-table-header') | |
const additionalDiv = ` | |
<div class="heading"> | |
<button class="theme-button" id="btnCalculate" style="cursor: pointer;">Calculate total</button> | |
</dvi> | |
` | |
payoutsContainerDiv.innerHTML += additionalDiv | |
const btnCalculate = document.querySelector('#btnCalculate') | |
btnCalculate.addEventListener('click', () => { | |
const total = calculateTotal() | |
btnCalculate.innerHTML = `Total: ${total.toFixed(5)} ETH` | |
}) | |
}, 2000) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment