Created
May 13, 2024 12:11
-
-
Save melardev/48cbda23b6746f1d879d9737147d6883 to your computer and use it in GitHub Desktop.
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 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