Skip to content

Instantly share code, notes, and snippets.

@qwo
Forked from graymouser/hb_all_books_dl.js
Last active August 19, 2018 19:36
Show Gist options
  • Save qwo/d733e71b6b278724422f5c575dffea2e to your computer and use it in GitHub Desktop.
Save qwo/d733e71b6b278724422f5c575dffea2e to your computer and use it in GitHub Desktop.
Humble bundle book bundles - download all books at once
/*
After purchasing a humble book bundle, go to your download page for that bundle.
Open a console window for the page and paste in the below javascript
Updated: Credit @jmerle
*/
const commands = [];
document.querySelectorAll('.row').forEach(row => {
const bookTitle = row.dataset.humanName;
[...row.querySelectorAll('.downloads .flexbtn a')].forEach(el => {
const downloadLink = el.href;
const fileName = /\.com\/([^?]+)/.exec(downloadLink)[1];
commands.push(`curl --create-dirs -o "${bookTitle}/${fileName}" "${downloadLink}"`);
});
});
console.log(commands.join('; '));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment