Last active
June 5, 2024 02:26
-
-
Save doceazedo/2cef493054b286c04ad7ed90b2e4fc78 to your computer and use it in GitHub Desktop.
quanto gastei no fortnite
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
// 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.29; | |
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