Last active
September 29, 2018 13:22
-
-
Save YarnSeemannsgarn/8d0f58d2a4c79363ce8b95ac9666d302 to your computer and use it in GitHub Desktop.
Toggles my cryptos on https://coinmarketcap.com/all/views/all/#EUR
This file contains 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
javascript: | |
var my_cryptos = { | |
"id-bitcoin": 0, | |
"id-ethereum": 9.5572051, | |
"id-ripple": 0, | |
"id-bitcoin-cash": 0, | |
"id-eos": 0, | |
"id-stellar": 0, | |
"id-litecoin": 0, | |
"id-monero": 0, | |
"id-cardano": 0, | |
"id-dash": 4.93979, | |
/*"id-iota": 0,*/ | |
/*"id-tron": 0,*/ | |
"id-neo": 0, | |
"id-ethereum-classic": 0, | |
"id-nem": 0, | |
/*"id-vechain": 0,*/ | |
"id-zcash": 0, | |
"id-qtum": 0, | |
"id-augur": 0, | |
"id-gnosis-gno": 0 | |
}; | |
var euros = {}; | |
var sum = 0.0; | |
var addContent = true; | |
if ($(".removable").length) { | |
addContent = false; | |
$(".removable").remove(); | |
} else { | |
$("thead tr").append('<th id="th-name" class="sortable sorting removable" tabindex="0" aria-controls="currencies-all" rowspan="1" colspan="1" aria-label="Euro: activate to sort column ascending" style="width: 124px;">Euro</th>'); | |
$("thead tr").append('<th id="th-name" class="sortable sorting removable" tabindex="0" aria-controls="currencies-all" rowspan="1" colspan="1" aria-label="Percentage: activate to sort column ascending" style="width: 124px;">Percentage</th>'); | |
} | |
$('#currencies-all').find('tbody tr').each(function( index ) { | |
var crypto_id = ($( this ).attr('id') ); | |
if(crypto_id in my_cryptos) { | |
if (addContent) { | |
var price = parseFloat($( this ).find("a[class='price']").text().substring(1).replace(",", "")); | |
var euro = price * my_cryptos[crypto_id]; | |
euros[crypto_id] = euro; | |
sum = sum + euro; | |
$( this ).append("<td class='removable'>" + euro.toFixed(2) + "€</td>"); | |
} | |
} else { | |
$( this ).toggle(); | |
} | |
}); | |
$('#currencies-all').find('tbody tr').each(function( index ) { | |
var crypto_id = ($( this ).attr('id') ); | |
if(crypto_id in my_cryptos) { | |
if (addContent) { | |
$( this ).append("<td class='removable'>" + (euros[crypto_id] / sum * 100).toFixed(2) + "%</td>"); | |
} | |
} | |
}); | |
if (addContent) { | |
$('h1').append(" <span class='removable'>" + sum.toFixed(2) + "€</span>"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment