Created
February 22, 2014 13:32
-
-
Save keslerm/9154854 to your computer and use it in GitHub Desktop.
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 CoinMine.pw Enhancements | |
// @namespace http://www.dasbiersec.com | |
// @version 0.1 | |
// @description Add some enhancements to CoinMine.pw | |
// @match http://coinmine.pw/account.php | |
// @copyright 2012+, You | |
// ==/UserScript== | |
// a function that loads jQuery and calls a callback function when jQuery has finished loading | |
function addJQuery(callback) { | |
var script = document.createElement("script"); | |
script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"); | |
script.addEventListener('load', function() { | |
var script = document.createElement("script"); | |
script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();"; | |
document.body.appendChild(script); | |
}, false); | |
document.body.appendChild(script); | |
} | |
// the guts of this userscript | |
function main() { | |
// get BTC/LTC conversion rate (LTC/BTC) | |
var cryptsyPrice = null; | |
jQ.get('http://jsonp.jit.su/?url=http%3A%2F%2Fpubapi.cryptsy.com%2Fapi.php%3Fmethod%3Dsinglemarketdata%26marketid%3D3', function (data) { | |
console.log(data.return.markets.LTC.lasttradeprice); | |
cryptsyPrice = data.return.markets.LTC.lasttradeprice; | |
// Resize account list page to be wider | |
jQ('body div:nth-child(3) div').first().css('width', '1200px'); | |
// Move LTC/USD estimates out from tooltip | |
jQ('input[value=payaccounts]').parent().find('table').each(function (index, element) { | |
jQ(this).attr('width', '99%'); | |
var details = jQ(this).find('td:nth-child(2)').find("b > a").attr('title').split("\n"); | |
var html = '<td style="width: 440px" valign="top">'; | |
for (var i = 0; i < details.length; i++) | |
{ | |
html = html + details[i] + "<br />"; | |
// BTC price | |
if (i == details.length - 1) | |
{ | |
var data = details[i].split(" "); | |
var price = 0; | |
if (parseFloat(data[1]) > 0) | |
{ | |
price = (parseFloat(data[1]) * cryptsyPrice).toFixed(8); | |
} | |
html = html + "BTC: " + price + "<br />"; | |
} | |
} | |
jQ(this).find('tr').append(html); | |
}); | |
// Find any payouts that are active and set color to red to be more apparent | |
jQ('.coinpayout').each(function (index, element) { | |
if (jQ(this).val() > 0) | |
{ | |
jQ(this).css("background-color", "green"); | |
} | |
}); | |
}) | |
.fail(function () { | |
alert("Problem loading cryptsy data... (shocker)"); | |
}); | |
} | |
// load jQuery and execute the main function | |
addJQuery(main); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment