Created
July 5, 2025 16:17
-
-
Save Gong-Bao-Chicken/44996a81d4603a84d5463be1aeaf5148 to your computer and use it in GitHub Desktop.
DKB Postbox click each filtered button after delay
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 clickWithDelayReverse(selector, delay, descriptionFilter) { | |
const allButtons = Array.from(document.querySelectorAll(selector)).reverse(); | |
const filteredButtons = allButtons.filter(button => { | |
const text = button.textContent || ''; | |
return text.toLowerCase().includes(descriptionFilter.toLowerCase()); | |
}); | |
for (const [index, button] of filteredButtons.entries()) { | |
console.log(`Clicking button ${filteredButtons.length - index} in reverse order); | |
button.click(); | |
await new Promise(resolve => setTimeout(resolve, delay)); | |
} | |
console.log("All filtered buttons clicked in reverse order."); | |
} | |
// Example: Only click buttons related to "Filter String" | |
clickWithDelayReverse('.{{wrapperdivname}} button', 5000, 'Filter String'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment