Skip to content

Instantly share code, notes, and snippets.

@kakaroto
Last active May 29, 2024 13:07
Show Gist options
  • Save kakaroto/8b395b520c2731e31f1643b4b473c013 to your computer and use it in GitHub Desktop.
Save kakaroto/8b395b520c2731e31f1643b4b473c013 to your computer and use it in GitHub Desktop.
Script to extract list of games in Humble Bundle Library
/*
* Taken from https://www.reddit.com/r/GarlicMarket/comments/7sjcja/meta_how_to_easily_pull_a_list_of_all_your/
* Modified by KaKaRoTo
*/
//if you're not on the first page navigate to the first page
if($('.js-jump-to-page:first').text() != "1"){
$('.js-jump-to-page:nth-child(2)').click()
}
// Find how many pages of games you have by getting the text inside the last page button
var loop = $('.js-jump-to-page:nth-last-child(2)').html()*1
// array to store all games found
var x = [];
// loop through each page
for(i=0;i<loop;i++){
// for each game on the page add an entry into the array
$('tbody tr').each(function(){
var redeemed = $(this).children('td.redeemer-cell').children().children().children('div.redeemed').length > 0 ? 'Redeemed' : ''
var giftable = $(this).children('td.redeemer-cell').children().children().children('div.giftfield').length > 0 ? '' : 'Not Giftable'
var availability = redeemed == '' ? giftable : redeemed
x.push('\n'+$(this).children('td.game-name').children('h4').attr('title')+ '|'+$(this).children('td.game-name').children('p').attr('title')+' | '+$(this).children('td.platform').children('i').attr('title')+' | '+ availability)
})
// click next page button
$('.js-jump-to-page:last').click()
}
// sort game list
x.sort()
// string variable for game list
var gamelist = ''
// transfer gamelist from array into string
x.forEach(function(x){gamelist += x})
// Output games with header needed for Reddit formatted table
console.log('Game | Bundle | Platform | Availability\n---|---|---|---'+gamelist)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment