Skip to content

Instantly share code, notes, and snippets.

@barrywoolgar
Forked from graymouser/hb_all_books_dl.js
Created September 2, 2016 11:06
Show Gist options
  • Select an option

  • Save barrywoolgar/03c5cb767b670d41cfdf1fb9f4fdf9c3 to your computer and use it in GitHub Desktop.

Select an option

Save barrywoolgar/03c5cb767b670d41cfdf1fb9f4fdf9c3 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.
This will download all the books in all the formats available.
*/
$('a').each(function(i){
if (['MOBI', 'PDF', 'EPUB'].indexOf($.trim($(this).text())) >= 0) {
$('body').append('<iframe id="dl_iframe_'+i+'" style="display:none;">');
document.getElementById('dl_iframe_'+i).src = $(this).data('web');
}
});
@djw4

djw4 commented Feb 2, 2017

Copy link
Copy Markdown

This works really well, but it doesn't seem to work with PDF's. I've tested in Chrome on both MacOS and Windows.

I tried adding;
if (['MOBI', 'PDF', 'EPUB', 'PDF (HQ)'].indexOf($.trim($(this).text())) >= 0) {
But that didn't seem to make a difference.

@stefan2904

Copy link
Copy Markdown

I guess the issues with PDF is that many browsers try to open them instead of offering the download dialog ...

@pcoletsos

Copy link
Copy Markdown

For the PDF issue nvilagos provided solution that works for me.

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

@lnicola

lnicola commented Dec 1, 2017

Copy link
Copy Markdown

My version:

var s = "";
$('.js-start-download a').each(function() {
    s += $(this).attr("href") + "\n";
});
console.log(s);

@deadpahn

Copy link
Copy Markdown

This doesn't work anymore _

@hheinen

hheinen commented May 31, 2018

Copy link
Copy Markdown

As @deadphan says, it doesn't seem to work anymore.

So I used the JS-Code from @inicola to get all Links and downloaded using PowerShell:

$links = 'link1',
'lin2',
...

foreach($link in $links){
    $name =  $link.Split("?")[0].Split('/')[3]
    $path = ".\ebooksHumbleBundle\" + $name
    wget -Uri $link -OutFile $path


}

@fstarnaud

Copy link
Copy Markdown

Or simply copy/paste the links from the console log to "list.txt" and use "wget -i files.txt" ...

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