Last active
December 21, 2019 04:30
-
-
Save justin-lyon/f134e6b72f3eb468f96228deec9f7762 to your computer and use it in GitHub Desktop.
Scrape steam transaction history table to get total $$$ spent
This file contains hidden or 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
/** | |
* 1. Login to Steam and browse your history here: | |
* https://store.steampowered.com/account/history/ | |
* | |
* 2. Make sure to "Load More" at the bottom so you get'em all | |
* | |
* 3. Add this script in chrome console to see your total paid | |
* (F12 to open console in Chrome, Click on the "console" tab, paste this in, hit enter) | |
* | |
* I'm over 1800... :< | |
*/ | |
const getColContent = (row, colClass) => { | |
const col = row.querySelector(colClass) | |
const div = col.querySelector('div') | |
return (!!div ? div.textContent : col.textContent).trim() | |
} | |
const parseAmount = amtText => { | |
return parseFloat(amtText.slice(1)) | |
} | |
const rows = [...document.querySelectorAll('.wallet_table_row')] | |
.map(r => { | |
return { | |
type: getColContent(r, '.wht_type'), | |
amount: parseAmount(getColContent(r, '.wht_total')) | |
} | |
}) | |
const purchases = rows.filter(r => !r.type.includes('Market Transaction')) | |
const totalPaid = purchases.reduce((acc, r) => acc + r.amount, 0) | |
console.log('rows', rows) | |
console.log('totalPaid', totalPaid.toFixed(2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment