Last active
April 14, 2019 02:22
-
-
Save kicktraq/efe182e0c44f4f80ae6db59c01bbb537 to your computer and use it in GitHub Desktop.
Ever wonder how much you've spent on KS? Yeah, don't do this on purpose if you are a KS addict.
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
// login, and visit this page: https://www.kickstarter.com/profile/backings | |
// keep clicking "show more pledges" in the "successfully pledged" section until the button disappears | |
// paste the following in your console | |
// build a quick and dirty currency echange index | |
var exchangeArray = { | |
"$": 1, | |
"£": 1.31, | |
"€": 1.17, | |
"AU$": .74, | |
"CA$": .76, | |
"NZ$": .68, | |
"S$": .73, | |
"Fr": 1.01, | |
"¥": .009, | |
"NOK": .12 | |
}; | |
// setup clean placeholders | |
var paidTotal = 0; | |
var paidIndex = 0; | |
var skippedIndex = 0; | |
var totalIndex = 0; | |
// itterate each of our money spans | |
$("[data-collection_state='collected'] span.money").each(function(){ | |
// get the internal value of each money span | |
var tmpValue = $(this).text(); | |
// find out where our currency value starts so we can trim off the currency | |
var currencyPointer = tmpValue.search(/\d/); | |
var tmpCurrency = tmpValue.substring(0,currencyPointer).trim(); | |
// ensure we have an exchange translation for our currency | |
if(!(tmpCurrency in exchangeArray)) { | |
// get our project name | |
var projectName = $(this).parent().parent().find(".flag-body strong").text(); | |
// explain why we're skipping | |
console.log("- skipping '" + projectName + "' with currency of " + tmpCurrency); | |
// probably a wonky currency, so skip but increment so we can show that later | |
skippedIndex++; | |
} else { | |
// ensure we don't have a blank currency, this is | |
// a quirk from kickstarter with certain currencies like NOK | |
if(tmpCurrency !== "") { | |
// ensure we only have the currency portion | |
tmpValue = tmpValue.replace(/[^0-9\.]/g, ''); | |
// float that bad boy | |
var tmpTotal = parseFloat(tmpValue); | |
// convert using our exchange rate lookup | |
tmpTotal = tmpTotal * exchangeArray[tmpCurrency]; | |
// cumulate our paid placeholder | |
paidTotal = paidTotal + tmpTotal; | |
// increment our index of paid projects | |
paidIndex++; | |
} else { | |
// probably a wonky currency, so skip but increment so we can show that later | |
skippedIndex++; | |
} | |
} | |
// increment our total | |
totalIndex++; | |
}); | |
// round for display purposes | |
paidTotal = paidTotal.toLocaleString('en-US', {style: 'currency', currency: 'USD'});; | |
// hit us with the damage captain | |
console.log("\n\n----------\nYou've paid " + paidTotal + " from " + totalIndex + " projects (" + skippedIndex + " skipped)"); | |
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
// login, and visit this page: https://www.kickstarter.com/profile/backings | |
// keep clicking "show more pledges" in both sections until the button disappears | |
// paste the following in your console | |
// build a quick and dirty currency echange index | |
var exchangeArray = { | |
"$": 1, | |
"£": 1.31, | |
"€": 1.17, | |
"AU$": .74, | |
"CA$": .76, | |
"NZ$": .68, | |
"S$": .73, | |
"Fr": 1.01, | |
"¥": .009, | |
"NOK": .12 | |
}; | |
// setup clean placeholders | |
var paidTotal = 0; | |
var paidIndex = 0; | |
var skippedIndex = 0; | |
var totalIndex = 0; | |
// itterate each of our money spans | |
$("span.money").each(function(){ | |
// get the internal value of each money span | |
var tmpValue = $(this).text(); | |
// find out where our currency value starts so we can trim off the currency | |
var currencyPointer = tmpValue.search(/\d/); | |
var tmpCurrency = tmpValue.substring(0,currencyPointer).trim(); | |
// ensure we have an exchange translation for our currency | |
if(!(tmpCurrency in exchangeArray)) { | |
// get our project name | |
var projectName = $(this).parent().parent().find(".flag-body strong").text(); | |
// explain why we're skipping | |
console.log("- skipping '" + projectName + "' with currency of " + tmpCurrency); | |
// probably a wonky currency, so skip but increment so we can show that later | |
skippedIndex++; | |
} else { | |
// ensure we don't have a blank currency, this is | |
// a quirk from kickstarter with certain currencies like NOK | |
if(tmpCurrency !== "") { | |
// ensure we only have the currency portion | |
tmpValue = tmpValue.replace(/[^0-9\.]/g, ''); | |
// float that bad boy | |
var tmpTotal = parseFloat(tmpValue); | |
// convert using our exchange rate lookup | |
tmpTotal = tmpTotal * exchangeArray[tmpCurrency]; | |
// cumulate our paid placeholder | |
paidTotal = paidTotal + tmpTotal; | |
// increment our index of paid projects | |
paidIndex++; | |
} else { | |
// probably a wonky currency, so skip but increment so we can show that later | |
skippedIndex++; | |
} | |
} | |
// increment our total | |
totalIndex++; | |
}); | |
// round for display purposes | |
paidTotal = paidTotal.toLocaleString('en-US', {style: 'currency', currency: 'USD'});; | |
// hit us with the damage captain | |
console.log("\n\n----------\nYou've paid " + paidTotal + " from " + totalIndex + " projects (" + skippedIndex + " skipped)"); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment