Skip to content

Instantly share code, notes, and snippets.

@Maddosaurus
Forked from kfatehi/hb_all_books_dl.js
Last active November 26, 2017 13:48
Show Gist options
  • Save Maddosaurus/9887a927d7a1d2e45d7ff6025f0dd6a8 to your computer and use it in GitHub Desktop.
Save Maddosaurus/9887a927d7a1d2e45d7ff6025f0dd6a8 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 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())) {
// changed to href - now works with current FF/Chrome
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)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment