Skip to content

Instantly share code, notes, and snippets.

@doceazedo
Last active April 13, 2024 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doceazedo/2cef493054b286c04ad7ed90b2e4fc78 to your computer and use it in GitHub Desktop.
Save doceazedo/2cef493054b286c04ad7ed90b2e4fc78 to your computer and use it in GitHub Desktop.
quanto gastei no fortnite
// https://www.epicgames.com/account/transactions
let timeout;
let tries = 0;
let showMore = () => {
if (tries >= 15) return sum();
timeout = setTimeout(showMore, 300);
tries = tries + 1;
const btn = document.getElementById('payment-history-show-more-button');
// if show more btn isnt found on first try
if (!btn && tries <= 1) {
clearTimeout(timeout);
sum();
return;
}
if (!btn) return;
console.log('Loading more transactions...');
btn.click();
}
let sum = () => {
let dollarExchangeRate = 5.08;
let total = [...document.querySelectorAll('table tbody td:nth-child(2)')]
.filter(el => {
const desc = el.innerText.toLowerCase()
return desc.includes('v-bucks') || desc.includes('fortnite')
})
.map(el => {
const priceStr = el.parentElement.querySelector('td:nth-child(3)').innerText;
const price = parseFloat(priceStr.split('$')[1].replace(',', '.'));
const isDollar = priceStr.startsWith('- US$');
return isDollar ? price * dollarExchangeRate : price;
})
.reduce((a, b) => (a + b), 0)
let msg = `Você gastou R$ ${total.toFixed(2).replace('.', ',')} no Fortnite! :)`;
console.log(`%c${msg}`, "color:blue;font-size:24px;font-weight:bold;");
}
showMore();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment