Created
November 4, 2015 14:08
-
-
Save adammw/10a438f93d96e9ac31df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Downloads unwatermarked invidiual pages of books from EBSCOhost | |
var data = /\/ebook\/(.+?)\?sid=(.+?)&/.exec(location.href); | |
$.getJSON(`/ehost/ebookViewer/DigitalObject/${data[1]}?sid=${data[2]}&vid=0&theFormat=EB`).then(function(json) { | |
var pages = json.pageData.map(function(page) { | |
return { | |
filename: `${json.title.replace(/\s/,'_')}_${page.id}`, | |
url: `${location.origin}/ehost/ebookviewer/artifact/${data[1]}/EB/${data[2]}/0/${page.artifactId}` | |
}; | |
}); | |
// this fails for >~ 40 pages due to too many simultaneous downloads | |
// consider logging the file urls and downloading separately | |
pages.forEach(function(page) { | |
var a = document.createElement('a'); | |
a.download = page.filename; | |
a.href = page.url; | |
a.click(); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment