Last active
April 4, 2026 22:58
-
Star
(141)
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.
Removes all Amazon saved for later items on the cart page. It will only remove visible items. You might want to scroll first to make more items visible. To use paste code in developer console (Ctrl+Shift+J or Cmd+Opt+J in Chrome) then press enter.
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
| 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(); |
function deleteAllAmazonItems() {
// This query looks for Delete buttons in BOTH the active cart and saved items
// based on the specific selectors in your page source
var query = document.querySelectorAll("#sc-active-cart input[value=Delete], #sc-saved-cart input[value=Delete], input[data-action='delete-active']");
if (query.length > 0) {
console.log('Items remaining: ' + query.length);
query[0].click();
// Wait 1 second for Amazon to update the UI, then run again
setTimeout(deleteAllAmazonItems, 1000);
} else {
// If no buttons are found, try scrolling once to see if more lazy-load
window.scrollTo(0, document.body.scrollHeight);
setTimeout(function() {
var retryQuery = document.querySelectorAll("#sc-active-cart input[value=Delete], #sc-saved-cart input[value=Delete], input[data-action='delete-active']");
if (retryQuery.length > 0) {
deleteAllAmazonItems();
} else {
console.log('Finished :) All items cleared.');
}
}, 2000);
}
}
deleteAllAmazonItems();
Was able to get this to work, it is a little slow but was able to delete over 500 items without issue.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
None of the above worked for me unfortunately, but after some iteration, I was able to get it to work for me:
Maybe Amazon updated their HTML, so the other approaches didn't work.