Booth.pm Hide Out of Stock

Hide items that are "Out of Stock"

  1. // ==UserScript==
  2. // @name Booth.pm Hide Out of Stock
  3. // @namespace https://greasyfork.org/en/users/76021-bootresha
  4. // @description Hide items that are "Out of Stock"
  5. // @icon https://booth.pm/favicon.ico
  6. // @include https://booth.pm/*
  7. // @include https://*.booth.pm/*
  8. // @version 1.0
  9. // @grant none
  10. // ==/UserScript==
  11. $(document).ready(function () {
  12. if (document.location.href.indexOf('booth.pm') == 8) {
  13. var hideShowButton = '<div><button class="showHideOOS">Hide out of stock</div>';
  14. $('.global-nav').append(hideShowButton);
  15. $('.showHideOOS').click(function(){
  16. if ($('.showHideOOS').text() == "Hide out of stock"){
  17. $('.showHideOOS').text('Show out of stock');
  18. hideOOS(true);
  19. } else {
  20. $('.showHideOOS').text('Hide out of stock');
  21. hideOOS(false);
  22. }
  23. });
  24. numItems = $('.item-wrap').length;
  25. for (i = 0; i <= numItems; i++) {
  26. currentItem = $('.item-wrap').eq(i);
  27. handlerBooth(currentItem);
  28. // if (currentItem.ready) {
  29. // handlerBooth(currentItem);
  30. // } else {
  31. // currentItem.load(handlerBooth(currentItem));
  32. // }
  33. }
  34. hideOOS(false);
  35. } else {
  36. var hideShowButton = '<div><button class="showHideOOS">Hide out of stock</div>';
  37. $('.ctrl-nav.shop').append(hideShowButton);
  38. $('.showHideOOS').click(function(){
  39. if ($('.showHideOOS').text() == "Hide out of stock"){
  40. $('.showHideOOS').text('Show out of stock');
  41. hideOOS(true);
  42. } else {
  43. $('.showHideOOS').text('Hide out of stock');
  44. hideOOS(false);
  45. }
  46. });
  47. numItems = $('.thumb').length;
  48. for (i = 0; i <= numItems; i++) {
  49. currentItem = $('.thumb').eq(i);
  50. handlerStoreBooth(currentItem);
  51. // if (currentItem.ready) {
  52. // handlerStoreBooth(currentItem);
  53. // } else {
  54. // currentItem.load(handlerStoreBooth(currentItem));
  55. // }
  56. }
  57. hideOOS(false);
  58. }
  59. })
  60. function handlerBooth(input) {
  61. if (input.children('.empty-stock').length > 0) {
  62. input.parent().addClass('OOS');
  63. }
  64. }
  65. function handlerStoreBooth(input) {
  66. if (input.children('.badges').children('.empty-stock').length > 0) {
  67. input.parent().addClass('OOS');
  68. }
  69. }
  70. function hideOOS(inputBoolean) {
  71. if (inputBoolean) {
  72. $('.OOS').hide();
  73. } else {
  74. $('.OOS').show();
  75. $('.OOS').css({
  76. 'opacity': 0.25
  77. });
  78. }
  79. }