// ==UserScript== // @name Better BP rates // @namespace http://tampermonkey.net/ // @version 0.6 // @description Display more meaningful information in the "Your Bonus Points Rate" page // @author ryden // @match https://orpheus.network/bonus.php?action=bprates* // @icon https://www.google.com/s2/favicons?sz=64&domain=orpheus.network // @grant none // @downloadURL https://update.greasyfork.cloud/scripts/459490/Better%20BP%20rates.user.js // @updateURL https://update.greasyfork.cloud/scripts/459490/Better%20BP%20rates.meta.js // ==/UserScript== /** * @param {String} HTML representing a single element * @return {Element} */ function htmlToElement(html) { var template = document.createElement('template'); html = html.trim(); // Never return a text node of whitespace as the result template.innerHTML = html; return template.content.firstChild; } (function() { 'use strict'; const parseNumber = (x) => +x.replaceAll(',', ''); const formatNumber = (x, precision) => x.toLocaleString('en', { minimumFractionDigits: precision, maximumFractionDigits: precision }); const timeframes = [ 1, 24, 24*7, 24*365.256363004/12, 24*365.256363004 ]; //----------------------------------------------------------------------------------------- const makeRateUpdater = (row, decimals) => (when) => { row.fields.each(function(i) { this.innerText = formatNumber(timeframes[i] * row.rates[when], decimals[i]); }); row.fields.gbYear.innerText = formatNumber(row.values.gbYear * row.rates[when] / row.rates[4], decimals[5]); }; //----------------------------------------------------------------------------------------- const processHeader = (table) => { const header = table.find('thead tr.colhead').eq(0); if (header.length === 0) return; const body = table.find('tbody tr').eq(0); if (body.length === 0) return; header.prepend(htmlToElement(`