Booth.pm Hide Out of Stock

Hide items that are "Out of Stock"

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Booth.pm Hide Out of Stock
// @namespace   https://greasyfork.org/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
    });
  }
}