Forked from jonathonlui/get-humble-bundle-library-keys.js
Created
December 21, 2023 23:19
-
-
Save husjon/2851d9c2cb0fd4f90c9949eb481b4e29 to your computer and use it in GitHub Desktop.
Get list of keys from Humble Bundle Library page
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
/* | |
* Run on https://www.humblebundle.com/home/library | |
* Global variable `gamekeys` is available on the Library page | |
* | |
*/ | |
Promise.all(gamekeys.map(key => { | |
return new Promise((resolve, reject) => { | |
$.ajax({ | |
url: `https://www.humblebundle.com/api/v1/order/${key}?all_tpkds=true` | |
}).done(data => resolve(data)) | |
}) | |
})) | |
.then(results => { | |
let keys = [] | |
results.forEach(result => { | |
keys = keys.concat(result.tpkd_dict.all_tpks.map(tpk => { | |
return { | |
name: tpk.human_name, | |
key_type: tpk.key_type_human_name, | |
redeemed: tpk.redeemed_key_val | |
} | |
})) | |
}) | |
return keys | |
}) | |
.then(keys => keys.sort((a ,b) => (a.name < b.name) ? -1 : 1)) | |
.then(keys => { | |
keys.forEach(key => { | |
console.log(`"${key.name}", ${key.key_type}, ${key.redeemed}`) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment