Skip to content

Instantly share code, notes, and snippets.

@vjk2005
Created August 1, 2018 22:23
Show Gist options
  • Save vjk2005/b6aeb408c26816e505f7306ecca2388f to your computer and use it in GitHub Desktop.
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.)
/*
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