Filtering Amazon Wishlist items with price drops

Amazon has recently changed their filters on wish list items so you can no longer view items with price drops (useful for books) or sort price from low to high. I wrote up some fairly crappy JavaScript that scrolls to the end of your wish list then removes all the items that don’t have  “Price dropped” in the div. I sometimes need to run the code more than once to get all items to be removed, so this is far from perfect, but works for what I was intending it to do. If you have a few hundred items on your list it will take a few seconds to run the script, but each subsequent run should run pretty quick.

Update: I added this to github.

function removeItemsWithoutPriceDrops() {
  var lowPrice = 999999;
  var anyRemoved = false;
  var listItems = document.getElementsByClassName('a-section g-item-sortable');

  for (var i = 0; i < listItems.length; i++) {
    var priceDrop = listItems[i].querySelectorAll('.itemPriceDrop');
    var price = listItems[i].querySelectorAll('span.a-offscreen');
    if (price.length) {
      price = price[0].innerHTML;
      price = price.replace('$', '');
    } else {
      price = 0;
    }
    if (priceDrop.length == 0 || price > lowPrice) {
      listItems[i].parentElement.removeChild(listItems[i]);
      anyRemoved = true;
    }
  }

  if (anyRemoved) {
    removeItemsWithoutPriceDrops();
  }
}

removeItemsWithoutPriceDrops();

You can also add the following code directly to a bookmark

javascript:(function()%7Bfunction%20removeItemsWithoutPriceDrops()%20%7Bvar%20lowPrice%20%3D%20999999%3Bvar%20anyRemoved%20%3D%20false%3Bvar%20listItems%20%3D%20document.getElementsByClassName('a-section%20g-item-sortable')%3Bfor%20(var%20i%20%3D%200%3B%20i%20%3C%20listItems.length%3B%20i%2B%2B)%20%7Bvar%20priceDrop%20%3D%20listItems%5Bi%5D.querySelectorAll('.itemPriceDrop')%3Bvar%20price%20%3D%20listItems%5Bi%5D.querySelectorAll('span.a-offscreen')%3Bif%20(price.length)%20%7Bprice%20%3D%20price%5B0%5D.innerHTML%3Bprice%20%3D%20price.replace('%24'%2C%20'')%3B%7D%20else%20%7Bprice%20%3D%200%3B%7Dif%20(priceDrop.length%20%3D%3D%200%20%7C%7C%20price%20%3E%20lowPrice)%20%7BlistItems%5Bi%5D.parentElement.removeChild(listItems%5Bi%5D)%3BanyRemoved%20%3D%20true%3B%7D%7Dif%20(anyRemoved)%20%7BremoveItemsWithoutPriceDrops()%3B%7D%7DremoveItemsWithoutPriceDrops()%7D)()