Amazon in-stock only

Conceal 'out of stock' items from Amazon search results

  1. // ==UserScript==
  2. // @name Amazon in-stock only
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Conceal 'out of stock' items from Amazon search results
  6. // @author Matt Miller
  7. // @match http*://www.amazon.com/*
  8. // @grant none
  9. // @require http://code.jquery.com/jquery-latest.min.js
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14. var $ = window.jQuery;
  15. var phantomKiller = function() {
  16. var items = $('div.a-row.a-size-base.a-color-secondary:contains("Out of Stock")');
  17. var hiddenItems = 0;
  18. items.each(function(index, element){
  19. var itemContainer = $(this).parent().parent().parent().parent().parent().parent();
  20. if ( $(itemContainer).is( ":visible" ) ) {
  21. itemContainer.hide();
  22. hiddenItems = hiddenItems + 1;
  23. //console.log("out of stock item concealed");
  24. }
  25. });
  26. if (hiddenItems > 0) {
  27. console.log("" + hiddenItems + " out of stock items concealed");
  28. }
  29. setTimeout(phantomKiller, 1000);
  30. };
  31. setTimeout(phantomKiller, 100);
  32. })();