Skip to content

Instantly share code, notes, and snippets.

@sehrgut
Last active August 29, 2015 14:03
Show Gist options
  • Save sehrgut/ccfdff139d08a288a5eb to your computer and use it in GitHub Desktop.
Save sehrgut/ccfdff139d08a288a5eb to your computer and use it in GitHub Desktop.
Kickstarter Spending Report

I wanted a quick way to see how much I'd spent on Kickstarter. These browser console scripts will convert all Kickstarter pledges to your home currency and add them up.

  1. Set homeCurr in xe.com.js and kickstarter.com.js to the same value.
  2. Run xe.com.js in a console window on http://xe.com.
  3. Set exchg in kickstarter.com.js to the output of step 2.
  4. Run kickstarter.com.js in a console window on https://www.kickstarter.com/profile/backings?ref=nav.

You should see something like:

You have spent 1711.63976 USD on Kickstarter. 
/*
file: kickstarter.com.js
license: GPLv3
## USAGE
1. Update the exchange rates object using xe.com.js.
2. Update home currency to the home currency used in xe.com.js.
3. Paste and run this entire script into a console window on:
https://www.kickstarter.com/profile/backings?ref=nav
*/
var homeCurr = 'usd';
var exchg = {"gbp":1.71194,"aud":0.93841,"cad":0.93808,"eur":1.36015,"nzd":0.88145,"usd":1} ;
function mapPledge () {
return {
curr: (this.innerHTML)[0] == '£' ? 'gbp' : this.className.replace(/^.* /, ''),
amount: this.innerHTML.substring(1)
};
}
function reduceCurrency (a, v, i, arr) {
var amt = Number(v.amount) * exchg[v.curr];
return a + amt;
}
function waitForBackings() {
if ($('section#collected a.show_more_backings:visible').length == 0) {
var spending = $('section#collected table td:nth-child(2) span.money').map(mapPledge).toArray().reduce(reduceCurrency, 0);
console.log("You have spent " + spending + " " + homeCurr.toUpperCase() + " on Kickstarter.");
} else {
setTimeout(waitForBackings, 500);
}
}
$('section#collected a.show_more_backings:visible').click();
waitForBackings();
/*
file: xe.com.js
license: GPLv3
## USAGE
1. Set home currency to desired currency.
2. Copy and run this entire script in a console window on:
http://xe.com/.
3. Copy the output and paste it into kickstarter.com.js.
*/
var homeCurr = 'usd';
var currs = [ 'gbp', 'aud', 'cad', 'eur', 'nzd', 'usd' ];
function getExchange(a, b) {
return Number($("[rel^='" + a.toUpperCase() + "," + b.toUpperCase() + "']")[0].innerHTML);
}
var exchg = {};
for (var i=0, n=currs.length; i<n; i++) {
exchg[currs[i]] = getExchange(homeCurr, currs[i]);
}
console.log(JSON.stringify(exchg));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment