Skip to content

Instantly share code, notes, and snippets.

@im-noob
Last active August 7, 2025 05:52
Show Gist options
  • Save im-noob/865b27920217fb9371c147274ca962b3 to your computer and use it in GitHub Desktop.
Save im-noob/865b27920217fb9371c147274ca962b3 to your computer and use it in GitHub Desktop.
Clear Amazon/Flipcart Save for Later
// amzon
function clickNextDeleteButton() {
const btn = document.querySelector('input[data-action="delete-saved"]');
if (btn) {
btn.click();
setTimeout(clickNextDeleteButton, 500); // wait for DOM to update
} else {
console.log("✅ All delete buttons clicked.");
}
}
clickNextDeleteButton();
function deleteAllSavedButtons() {
const button = document.querySelector('input[data-action="delete-saved"]');
if (button) {
console.log("Clicking delete button...");
button.click();
setTimeout(deleteAllSavedButtons, 1000); // Adjust delay if needed
} else {
console.log("✅ No more delete buttons found.");
}
}
deleteAllSavedButtons();
// flipcart
async function removeAllItemsByQuerySelector() {
const removeButtons = Array.from(document.querySelectorAll('div'))
.filter(el => el.textContent.trim() === "Remove");
if (removeButtons.length === 0) {
console.log("✅ No more 'Remove' buttons found.");
return;
}
const mainButton = removeButtons.find(el => el.offsetParent !== null); // visible one
if (!mainButton) {
console.warn("❌ No visible 'Remove' button found.");
return;
}
console.log("🔘 Clicking main 'Remove' button...");
mainButton.click();
// Wait for popup to show
let confirmBtn = null;
for (let i = 0; i < 10; i++) {
await new Promise(resolve => setTimeout(resolve, 300));
confirmBtn = Array.from(document.querySelectorAll('div'))
.filter(el =>
el.textContent.trim() === "Remove" &&
el !== mainButton &&
el.offsetParent !== null
)[0];
if (confirmBtn) break;
}
if (confirmBtn) {
console.log("⚠️ Clicking confirmation 'Remove'...");
confirmBtn.click();
await new Promise(resolve => setTimeout(resolve, 1000));
await removeAllItemsByQuerySelector();
} else {
console.warn("❌ Confirm popup button not found.");
}
}
removeAllItemsByQuerySelector();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment