Skip to content

Instantly share code, notes, and snippets.

@denilsonsa
Last active May 22, 2020 22:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save denilsonsa/05990db3f3d8790ec1895f34ce0d399f to your computer and use it in GitHub Desktop.
Save denilsonsa/05990db3f3d8790ec1895f34ce0d399f to your computer and use it in GitHub Desktop.
Humble Bundle downloader
// This thing can be copy-pasted into the browser devtools JavaScript console, on the following page:
// https://www.humblebundle.com/home/library
// It was written to automatically download all torrent files from my Humble Bundle library.
//
// 1. Open the page.
// 2. Filter by ebooks.
// 3. Select BitTorrent instead of direct download.
// 4. Click on the first product to start downloading.
// 5. Run the code below.
var next_product_index = Array.from(document.querySelectorAll('.subproduct-selector')).indexOf(document.querySelector('.subproduct-selector.selected'));
var buttons = [];
var STOP = false;
var delay = 3000;
function next_product() { if (STOP) return; document.querySelectorAll('.subproduct-selector')[next_product_index++].click(); setTimeout(enqueue_buttons, delay);}
function enqueue_buttons() { buttons = Array.from(document.querySelectorAll('.js-download-button')); download_it(); }
function download_it() { if (STOP) return; if (buttons.length > 0) { buttons.pop().click(); setTimeout(download_it, delay); } else { next_btn_index = 0; next_product(); } }
// Then call this to start downloading:
next_product();
// To abort, set STOP to true:
STOP = true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment