Skip to content

Instantly share code, notes, and snippets.

@melardev
Created May 13, 2024 12:11
Show Gist options
  • Save melardev/48cbda23b6746f1d879d9737147d6883 to your computer and use it in GitHub Desktop.
Save melardev/48cbda23b6746f1d879d9737147d6883 to your computer and use it in GitHub Desktop.
// Javascript to run in a dev console
// to see the value of the tokens
// I use this to get the value of the tokens dispersed in a presale
const elements = document.querySelectorAll('span.text-muted');
let total = 0;
function parseValue(str) {
// Remove commas and the dollar sign
let cleanedStr = str.replace(/[,()$]/g, '');
// Convert to a floating-point number
return parseFloat(cleanedStr);
}
for(let i = 0; i < elements.length; i++) {
try{
value = elements[i].innerText;
value = parseValue(value);
if(!isNaN(value)){
total += value;
}
}catch(e) {
}
}
console.log(`Total Value ${total}`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment