Last active
May 15, 2021 16:06
-
-
Save daryledesilva/a2ba1093744f41b004c6eb2b405857f6 to your computer and use it in GitHub Desktop.
hpool daily estimation
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 hpool daily estimation | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.1 | |
| // @description tried to give a monetary value to your daily mining | |
| // @author Ruben Fernandes (Rauven) | |
| // @match https://www.hpool.com/* | |
| // @icon https://www.google.com/s2/favicons?domain=hpool.com | |
| // @grant none | |
| // @require http://code.jquery.com/jquery-3.4.1.min.js | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| $.getJSON( "https://api.exchangerate-api.com/v4/latest/USD", json => { | |
| let _conversion = json.rates.SGD, | |
| _currentPrice, _avg, _count, _mint, _maxt, _loopy, _page, _cb_final, _cb_loop, _wid, _daily, _text; | |
| function _chiaExt(){ | |
| $.getJSON( "https://api2.chiaexplorer.com/blockchainSummary", json => { | |
| _avg = 0; | |
| _count = 0; | |
| _mint = false; | |
| _maxt = false; | |
| _currentPrice = json.price; | |
| _page = 1; | |
| _cb_final = ()=>{ | |
| _text = []; | |
| _avg = (_avg / (_maxt - _mint)) * 60 * 60 * 24; | |
| _daily = _avg.toFixed(6); | |
| _wid = (0.2 / _avg).toFixed(1); | |
| _text.push(`Aprox. ${_daily} xch/day`); | |
| _avg = (_currentPrice * _avg * _conversion).toFixed(2); | |
| if(!$('._chiaExt').length){ | |
| $('<h5>',{class:'_chiaExt'}).appendTo('.h-menu-nav h4'); | |
| } | |
| _text.push(`Aprox. S$${_avg}/day`); | |
| _text.push(`Withdrawal: ${_wid} days`); | |
| $('._chiaExt').html(_text.join('<br>')); | |
| }; | |
| _cb_loop = ()=>{ | |
| $.getJSON(window.location.origin+`/api/pool/miningdetail?language=en&type=chia&count=100&page=${_page}`, json => { | |
| _loopy = false; | |
| json.data.list.forEach(ea=>{ | |
| if(!ea.status){ | |
| _loopy = true; | |
| _avg += parseFloat(ea.block_reward); | |
| _count ++; | |
| if(_mint === false || _mint > ea.record_time) _mint = ea.record_time; | |
| if(_maxt === false || _maxt < ea.record_time) _maxt = ea.record_time; | |
| } | |
| }); | |
| if(_loopy){ | |
| _page ++; | |
| _cb_loop(); | |
| }else{ | |
| _cb_final(); | |
| } | |
| }); | |
| }; | |
| _cb_loop(); | |
| }); | |
| } | |
| $(document) | |
| .on('click','._chiaExt',_chiaExt); | |
| _chiaExt(); | |
| }) | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment