Skip to content

Instantly share code, notes, and snippets.

@Gong-Bao-Chicken
Created July 5, 2025 16:17
Show Gist options
  • Save Gong-Bao-Chicken/44996a81d4603a84d5463be1aeaf5148 to your computer and use it in GitHub Desktop.
Save Gong-Bao-Chicken/44996a81d4603a84d5463be1aeaf5148 to your computer and use it in GitHub Desktop.
DKB Postbox click each filtered button after delay
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