Created
August 1, 2018 22:23
-
-
Save vjk2005/b6aeb408c26816e505f7306ecca2388f to your computer and use it in GitHub Desktop.
De-paginates a blog or image gallery by fetching multiple pages and attaching them to the current page for easy archival. (NO JQUERY REQUIRED.)
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
/* | |
Similar to: | |
• https://gist.github.com/vjk2005/3331714 (ajax-page-loader.js) | |
• https://gist.github.com/vjk2005/3812832 (deepload.js) | |
*/ | |
let start = 2, | |
end = 8, | |
url = '' | |
let loadPage = async page => { | |
let response = await fetch(url + page) | |
let data = await response.text() | |
let html = new DOMParser().parseFromString(data, 'text/html') | |
document.body.insertAdjacentHTML('beforeend', html.body.innerHTML) | |
if(page <= total) loadPage(++page) | |
} | |
// begin | |
loadPage(start) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment