Skip to content

Instantly share code, notes, and snippets.

@Azd325
Created February 23, 2025 13:07
Show Gist options
  • Save Azd325/2c625c02fa7fe82fb735675a0ea202a9 to your computer and use it in GitHub Desktop.
Save Azd325/2c625c02fa7fe82fb735675a0ea202a9 to your computer and use it in GitHub Desktop.
Helper to download documents from DKB
async function clickWithDelayReverse(selector, delay) {
const buttons = Array.from(document.querySelectorAll(selector)).reverse(); // Convert to array & reverse
for (const [index, button] of buttons.entries()) {
console.log(`Clicking button ${buttons.length - index} in reverse order`);
button.click();
await new Promise(resolve => setTimeout(resolve, delay)); // Wait before next click
}
console.log("All downloads triggered in reverse order.");
}
// Clicks each button inside '.sc-cFTihx.bHGjRu' in reverse order with a 5-second delay
clickWithDelayReverse('.sc-cFTihx.bHGjRu button', 5000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment