Skip to content

Instantly share code, notes, and snippets.

@thunder-coding
Last active May 10, 2023 05:36
Show Gist options
  • Save thunder-coding/ff0424956bf199277cd2ac65e4a3bbff to your computer and use it in GitHub Desktop.
Save thunder-coding/ff0424956bf199277cd2ac65e4a3bbff to your computer and use it in GitHub Desktop.
Download all pdf on page
const anchors = Array.from(document.getElementsByTagName('a'));
const links = anchors.map(anchor => anchor.href.toString());
const pdfs = links.filter(link => link.endsWith('.pdf'));
let clipboardText = '';
for (const pdf of pdfs) {
clipboardText += `curl '${pdf}' -Lo '${pdf.substr(pdf.lastIndexOf('/') + 1)}'\n`
}
setTimeout(() => navigator.clipboard.writeText(clipboardText), 1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment