Skip to content

Instantly share code, notes, and snippets.

@blaxpot
Last active August 11, 2023 01:55
Show Gist options
  • Save blaxpot/6c65b64fef863def3e14750153e7a8f4 to your computer and use it in GitHub Desktop.
Save blaxpot/6c65b64fef863def3e14750153e7a8f4 to your computer and use it in GitHub Desktop.
Download all books from Humble Bundle library
let nextClicks = 0;
function clickButtons(text, done) {
let delay = 0;
if (!done) {
$(`.download-button:contains('${text}')`).each(function () {
done = true;
setTimeout(() => {
$(this).click();
}, delay);
delay += 1000;
});
}
return done;
}
$(".subproduct-selector").each(function () {
setTimeout(() => {
let done = false;
$(this).click();
done = clickButtons("CBZ", done);
done = clickButtons("CBR", done);
done = clickButtons("EPUB", done);
done = clickButtons("PDF", done);
done = clickButtons("MOBI", done);
}, nextClicks);
nextClicks += 5000;
});

Download Humble Bundle Library

This JS can be executed in your browser console to download all books from the Humble Library page.

It's currently set up for books, but could probably be tweaked to grab other stuff too.

It works by clicking each product in the library, then searching for elements with the class download-button which contain certain strings. Since I only want one copy of each book, it looks for buttons corresponding to formats in order of preference. Once it finds a button for a format, it will stop looking and click the next product in the list.

How to use:

  1. (optional) Paste the JS snippet into a text editor, edit the lines containg callse to clickButtons() according to your preference. This function just looks for text inside the button element, so you can pass in any string you want. If it appears on the download button you want, it should work.
  2. Browse to https://www.humblebundle.com/home/library and optionally select "eBooks" from the Platform dropdown to filter out products that aren't books.
  3. Set your browser to save downloads to a folder without prompting you. You could temporarily choose a folder called something like "HumbleLibrary" to keep things organised, rather than just dumping everything in your Downloads folder.
  4. Open the console in your browser's devtools, e.g. https://developer.chrome.com/docs/devtools/ or https://developer.mozilla.org/en-US/docs/Learn/Common_questions/Tools_and_setup/What_are_browser_developer_tools
  5. Paste in the JS snippet and hit enter. You should see products being clicked in your browser window and downloads starting within a few seconds.
  6. Wait for everything to finish downloading. This could take some time if you have a lot of stuff in your library.
  7. Set your browser download prefernces back to what they were before if you changed them.

Notes

  • This snippet works by just waiting 5 seconds between clicks for products, and clicking download buttons every 1 second. This works well enough for my purposes, but it will probably break if it tries to click a lot of download buttons for a product.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment