Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
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
type “about:plugins” in the address bar and disable chrome's pdf viewer
*/
var pattern = /(MOBI|EPUB|PDF)$/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['data-web'].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)
}
@chazzam
Copy link

chazzam commented Jan 12, 2017

Updated Pattern to get PDF (HQ), PDF (HD), CBZ files, and the Downloads of .zip's

var pattern = /(MOBI|EPUB|PDF( ?\(H.\))?|CBZ|Download)$/i;

@nvilagos
Copy link

nvilagos commented Aug 25, 2017

For Chrome users:

The location of the plugins have changed, you can set the required field here:
Settings (chrome://settings) --> Advanced --> Privacy and security --> Content settings --> PDF documents --> Download PDF files instead of automatically opening them in Chrome --> Turn ON

Moreover, I recommend turning off for asking download location:
Settings (chrome://settings) --> Advanced --> Downloads --> Ask where to save each file before downloading --> Turn OFF

@4mp3d
Copy link

4mp3d commented Sep 27, 2017

Doesn't like: download(a.attributes['data-web'].value, i);

Uncaught TypeError: Cannot read property 'value' of undefined at <anonymous>:6:42

@Oskube
Copy link

Oskube commented Oct 17, 2017

On my Firefox I got an error: TypeError: a.attributes['data-web'] is undefined
So I changed the line 15:

download(a.attributes['data-web'].value, i);

To:

download(a.attributes['href'].value, i);

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