-
Star
(137)
You must be signed in to star a gist -
Fork
(31)
You must be signed in to fork a gist
-
-
Save MichaelLawton/ec73c321d62d1b4eaf0f51ca478ccd92 to your computer and use it in GitHub Desktop.
function deleteSavedItems() { | |
var query = document.querySelectorAll("#sc-saved-cart input[value=Delete]") | |
if (query.length) { | |
query[0].click(); | |
} | |
if (query.length > 1) { | |
setTimeout(deleteSavedItems,100); | |
} | |
else { | |
console.log('Finished'); | |
} | |
} | |
deleteSavedItems(); |
I got a little frustrated last night with some of the query limit errors and having to restart the script (my soon to be ex-wife had over 750 items saved), so I rewrote the script, though I think the setInterval in the above script would have handled it just fine.
Looks like others also added similar checks to restart the script automatically when you get the quota limit errors. Here's a link to the version that I wrote last night which worked well the first time without any further intervention (super fun to watch the count go down in real time). Fingers cross it continues to work, works great in Oct 2024. https://github.com/mittingphx/WebsiteAutomation
None of the above worked for me unfortunately, but after some iteration, I was able to get it to work for me:
async function deleteAllSavedItems() {
while (true) {
const deleteButtons = document.querySelectorAll('input[data-action="delete-saved"]');
if (deleteButtons.length === 0) {
console.log("No more saved items to delete.");
break;
}
deleteButtons[0].click();
console.log("Deleted one saved item, remaining:", deleteButtons.length - 1);
await new Promise(resolve => setTimeout(resolve, 2000));
}
}
deleteAllSavedItems();
Maybe Amazon updated their HTML, so the other approaches didn't work.
Addition to above solution
Working Chrome 08-2024
Just zoom out Chrome window to 25% (or minimum)
Paste this in the dev console
Later you can close the tab or you can paste the following code to stop the loop
clearInterval(intervalId)