Booth.pm Hide Out of Stock

Hide items that are "Out of Stock"

// ==UserScript==
// @name        Booth.pm Hide Out of Stock
// @namespace   https://gf.qytechs.cn/en/users/76021-bootresha
// @description Hide items that are "Out of Stock"
// @icon        https://booth.pm/favicon.ico
// @include     https://booth.pm/*
// @include     https://*.booth.pm/*
// @version     1.0
// @grant       none
// ==/UserScript==
$(document).ready(function () {
  if (document.location.href.indexOf('booth.pm') == 8) {
    var hideShowButton = '<div><button class="showHideOOS">Hide out of stock</div>';
    $('.global-nav').append(hideShowButton);
    $('.showHideOOS').click(function(){
      if ($('.showHideOOS').text() == "Hide out of stock"){
        $('.showHideOOS').text('Show out of stock');
        hideOOS(true);
      } else {
        $('.showHideOOS').text('Hide out of stock');
        hideOOS(false);
      }
    });
    numItems = $('.item-wrap').length;
    for (i = 0; i <= numItems; i++) {
      currentItem = $('.item-wrap').eq(i);
      handlerBooth(currentItem);
      //       if (currentItem.ready) {
      //         handlerBooth(currentItem);
      //       } else {
      //         currentItem.load(handlerBooth(currentItem));
      //       }
    }
    hideOOS(false);
  } else {
    var hideShowButton = '<div><button class="showHideOOS">Hide out of stock</div>';
    $('.ctrl-nav.shop').append(hideShowButton);
    $('.showHideOOS').click(function(){
      if ($('.showHideOOS').text() == "Hide out of stock"){
        $('.showHideOOS').text('Show out of stock');
        hideOOS(true);
      } else {
        $('.showHideOOS').text('Hide out of stock');
        hideOOS(false);
      }
    });
    numItems = $('.thumb').length;
    for (i = 0; i <= numItems; i++) {
      currentItem = $('.thumb').eq(i);
      handlerStoreBooth(currentItem);
      //       if (currentItem.ready) {
      //         handlerStoreBooth(currentItem);
      //       } else {
      //         currentItem.load(handlerStoreBooth(currentItem));
      //       }
    }
    hideOOS(false);
  }
})
function handlerBooth(input) {
  if (input.children('.empty-stock').length > 0) {
    input.parent().addClass('OOS');
  }
}
function handlerStoreBooth(input) {
  if (input.children('.badges').children('.empty-stock').length > 0) {
    input.parent().addClass('OOS');
  }
}
function hideOOS(inputBoolean) {
  if (inputBoolean) {
    $('.OOS').hide();
  } else {
    $('.OOS').show();
    $('.OOS').css({
      'opacity': 0.25
    });
  }
}

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址