Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name MtGoxFeeCalculator
- // @description Shows final Mt.Gox value (including fee) as you type.
- // @screenshot http://img707.imageshack.us/img707/4795/screenshot2012010614181.png
- // @namespace http://pastebin.com/Zzqncbrb
- // @version 1.0.1
- // @include https://mtgox.com/*
- // @installation chrome-compatible (just open *.user.js in a browser)
- // ==/UserScript==
- (function(window, undefined ) {
- var w;
- if (typeof unsafeWindow != undefined) {
- w = unsafeWindow
- } else {
- w = window;
- }
- if (w.self != w.top) {
- return;
- }
- function getElementsByClassName(classname, node) {
- if(!node) node = document.getElementsByTagName("body")[0];
- var a = [];
- var re = new RegExp('\\b' + classname + '\\b');
- var els = node.getElementsByTagName("*");
- for(var i=0,j=els.length; i<j; i++)
- if(re.test(els[i].className))a.push(els[i]);
- return a;
- }
- function update_fee(edit, label, fee) {
- var amount = parseFloat(document.getElementById(edit).value);
- if (isNaN(amount))
- amount = 0.0;
- result = amount * (1 - fee * 0.01);
- result = Math.round(result * 100000000) / 100000000;
- document.getElementById(label).innerHTML = 'Total (-' + fee + '%): ' + result;
- }
- function update() {
- var elements = document.getElementsByClassName('progressStart');
- var fee = parseFloat(elements[0].innerHTML);
- update_fee('buyAmount','totalBuyAmount', fee);
- update_fee('sellCost','totalSellCost', fee);
- }
- function add_label(parent, id) {
- var div = document.createElement('div');
- div.setAttribute('id', id);
- div.style.position = 'relative';
- div.style.lineHeight = '0';
- div.style.color = '#aaa';
- div.style.top = '10px';
- div.style.fontSize = '11px';
- document.getElementById(parent).parentNode.appendChild(div);
- }
- if (/https:\/\/mtgox.com/.test(w.location.href)) {
- add_label('buyAmount', 'totalBuyAmount');
- add_label('sellCost', 'totalSellCost');
- window.setInterval(update, 1000);
- update();
- }
- })(window);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement