Skip to content

Instantly share code, notes, and snippets.

@zuazo
Forked from p0kR/hb_all_books_dl.js
Last active September 10, 2022 14:36
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save zuazo/a91ecbb97b90ef3ef9ce8caf361199a2 to your computer and use it in GitHub Desktop.
Save zuazo/a91ecbb97b90ef3ef9ce8caf361199a2 to your computer and use it in GitHub Desktop.
Humble bundle book bundles - download all books at once
/*
Forked from https://gist.github.com/p0kR/95e05e689be4e59b1b8fb6e383b9e25a
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
this fork downloads all formats and does so without using jquery (since that didnt work for me)
note that if you are in chrome, chrome will not download the pdfs for you by default, to fix this
Settings (chrome://settings) --> Advanced --> Privacy and security --> Content settings --> PDF documents --> Download PDF files instead of automatically opening them in Chrome --> Turn ON
Settings (chrome://settings) --> Advanced --> Downloads --> Ask where to save each file before downloading --> Turn OFF
*/
var pattern = /(MOBI|PRC|\.zip|EPUB|PDF( ?\(H.\))?|CBZ|Download)$/i;
var nodes = document.getElementsByTagName('a');
for (i in nodes) {
var a = nodes[i];
if (a && a.text && pattern.test(a.text.trim())) {
download(a.attributes['href'].value, i);
}
}
function download(url, i) {
var iframe = document.createElement('iframe');
iframe.id = "dl_iframe_" + i;
iframe.style.display = "none";
document.getElementsByTagName('body')[0].appendChild(iframe);
iframe.src = url;
console.log('iframe set to', url)
}
@JamesSkemp
Copy link

Just ran it and it didn't download any of the zip files.

May also be easier to update the settings to point to the locations:

  • chrome://settings/downloads
  • chrome://settings/content/pdfDocuments

Finally, may want to add a second delay between triggering the downloads? I didn't run into an issue, but might make things a little less aggressive on their servers. :)

Thank you for this!

@JamesSkemp
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment