Created
March 17, 2025 03:33
-
-
Save SahilMahadwar/3ba2f85fcceb28e62b1352822be3c8c7 to your computer and use it in GitHub Desktop.
fullstack.cafe download all pdfs
This file contains hidden or 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
(async function automateDownload() { | |
const batchSize = 20; | |
let index = 0; | |
function delay(ms) { | |
return new Promise(resolve => setTimeout(resolve, ms)); | |
} | |
while (true) { | |
const items = document.querySelectorAll(".badge-add-to-pdf"); // Update this selector to match your items | |
if (index >= items.length) break; | |
console.log(`Selecting items ${index + 1} to ${index + batchSize}`); | |
// Select 20 items | |
for (let i = index; i < index + batchSize && i < items.length; i++) { | |
items[i].click(); | |
await delay(100); // Adjust delay if needed | |
} | |
// Click Download PDF button | |
const downloadButton = document.querySelector('.mdc-button--outlined'); | |
if (downloadButton) { | |
downloadButton.click(); | |
console.log("Download button clicked, waiting for 5 seconds..."); | |
await delay(8000); // Wait for 5 seconds after clicking download | |
} else { | |
console.warn("Download button not found!"); | |
} | |
// Deselect previous 20 | |
console.log("Deselecting previous items..."); | |
for (let i = index; i < index + batchSize && i < items.length; i++) { | |
items[i].click(); | |
await delay(100); | |
} | |
index += batchSize; | |
await delay(2000); // Pause before processing the next batch | |
} | |
console.log("Automation complete."); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment