Edit 2: just fixed a bug that removed the last item of every page before calculating the page total

This means that we've spent even more than what the script said in the previous version

It hurts

Also: improved formatting of the amount in euros

Edit: added another script for Humble Monthly

---

Hi everyone!

I made this quick and dirty script to find out the all-time total amount of money spent on Humble Bundle, with support for EUR and USD.

Note: for now, any other currency will be counted as USD (for example, 5 GBP will be interpreted as 5 USD).

Instructions

Code

EUR_USD_FACTOR = 1.13

sumPage = () => +[...document.querySelectorAll('.results .total')].slice(1).map(s => {
  eur = s[0] === '€'
  s = s.textContent.replace(/,/g, '.')
  n = +s.replace(/[^0-9.]+/g, '')
  if (eur) return n * EUR_USD_FACTOR
  return n
}).reduce((a, v) => a + v, 0).toFixed(2)

goToPage = p => {
  el = document.querySelector(`.jump-to-page[data-index="${p}"]`)
  if (!el) return false
  el.click()
  return true
}

goAndSumPage = p => {
  page = goToPage(p)
  if (page) return sumPage()
  return false
}

delay = ms => new Promise(res => setTimeout(res, ms))

run = async (counter = 0, sum = 0) => {
  result = goAndSumPage(counter++)
  if (!result) return sum
  sum += result
  await delay(500)
  return run(counter, sum)
}

run().then(n => `Total spent on Humble Bundle: $${n} (${(n / EUR_USD_FACTOR).toFixed(2).replace('.', ',')}€)`).then(console.log)

For example, my total is:

Total spent on Humble Bundle: $322.94 (285,79€)

I buy pretty much every single book bundle about programming, robotics, etc and also a few games hahaha...

What's your total?

Humble Monthly script

Same as the other script, but in humblebundle.com/user/subscriptions/humble_monthly/billing (the Humble Monthly expenses are not included in the previous script)

EUR_USD_FACTOR = 1.13

run = async () => +[...document.querySelectorAll('.billing-history .amount')].map(s => {
  eur = s[0] === '€'
  s = s.textContent.replace(/,/g, '.')
  n = +s.replace(/[^0-9.]+/g, '')
  if (eur) return n * EUR_USD_FACTOR
  return n
}).reduce((a, v) => a + v, 0).toFixed(2)

run().then(n => `Total spent on Humble Monthly: $${n} (${(n / EUR_USD_FACTOR).toFixed(2).replace('.', ',')}€)`).then(console.log)