Skip to content

Instantly share code, notes, and snippets.

@falfox
Last active October 23, 2023 17:20
Show Gist options
  • Select an option

  • Save falfox/1c8c815489aade5458f890cb6b87712a to your computer and use it in GitHub Desktop.

Select an option

Save falfox/1c8c815489aade5458f890cb6b87712a to your computer and use it in GitHub Desktop.
Find out how much I spent on Destiny 2 by checking the Steam transaction history page at https://store.steampowered.com/account/history/
let tb = document.querySelector('table.wallet_history_table')
let tx = [...tb.querySelectorAll('tbody tr')].map(tr => {
let totalRaw = tr.querySelector('.wht_total')?.textContent?? ""
let total = totalRaw.replace("Credit", '').trim().substring(3).replace(/\s/g,"")
let items = tr.querySelector('.wht_items > div')?.textContent.trim() ?? ""
let isGift = tr.querySelector('.help_purchase_img') !== null
return {
total,
items,
isGift
}
})
let destiny2 = tx.filter(t => {
return t.items.startsWith('Destiny 2') && !t.isGift
})
let sum = destiny2.reduce((acc, cur) => acc + parseInt(cur.total), 0)
const numberFormat = new Intl.NumberFormat("id-ID", {
style: "currency",
currency: "IDR"
});
console.log({
sum,
inRupiah: numberFormat.format(sum)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment