Scrypt.cc BTCUSD / Income

Adds USD values to every btc info on the dashboard.

目前為 2015-07-20 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Scrypt.cc BTCUSD / Income
// @version      1.0.2
// @description  Adds USD values to every btc info on the dashboard.
// @author       Glitch
// @match        https://scrypt.cc/users/index.php
// @grant        none
// @namespace https://greasyfork.org/users/13326
// ==/UserScript==


function httpGet(theUrl)
{
    var xmlHttp = null;

    xmlHttp = new XMLHttpRequest();
    xmlHttp.open( "GET", theUrl, false );
    xmlHttp.send( null );
    return xmlHttp.responseText;
}

var btcusd = Number(httpGet("https://api.bitcoinaverage.com/ticker/global/USD/24h_avg"));
var daily = Number(httpGet("https://scrypt.cc/users/calculator.php").match(/calculateIncome\(([^)]+)\)/gi)[0].replace(/[^\d.-]/g,''));

var balance = Number(document.getElementById('idblc_2').getElementsByTagName('div')[1].textContent);
var order = Number(document.getElementById('idblc_2').getElementsByTagName('div')[2].textContent);
var total = Number(document.getElementById('idblc_2').getElementsByTagName('div')[3].textContent);

document.getElementById('idblc_2').getElementsByTagName('div')[1].textContent = balance + ", $" + (balance * btcusd).toFixed(4);
document.getElementById('idblc_2').getElementsByTagName('div')[2].textContent = order + ", $" + (order * btcusd).toFixed(4);
document.getElementById('idblc_2').getElementsByTagName('div')[3].textContent = total + ", $" + (total * btcusd).toFixed(4);

// var daily = (Number(document.getElementById('tralist').children[2].textContent.replace(/[^\d.-]/g,'')) * 6 * 24).toFixed(8);

document.getElementById('idblc_13').getElementsByTagName('div')[6].textContent = "BTC: " + daily + ", $" + (btcusd * daily).toFixed(4);
document.getElementById('idblc_13').getElementsByTagName('div')[7].textContent = "BTC: " + (daily * 30).toFixed(8) + ", $" + (btcusd * daily * 30).toFixed(4);