MouseHunt - Hide max owned items

Hides max owned items in shop

目前為 2021-03-17 提交的版本,檢視 最新版本

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

You will need to install an extension such as Tampermonkey to install this script.

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         MouseHunt - Hide max owned items
// @author       Hazado
// @namespace    https://greasyfork.org/en/scripts/423438
// @version      1.0
// @description  Hides max owned items in shop
// @include      https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js
// @match        http://www.mousehuntgame.com/*
// @match        https://www.mousehuntgame.com/*
// ==/UserScript==

if (!localStorage.getItem("maxOwnedItems")) {
  localStorage.setItem("maxOwnedItems", "Y");
}

$(document).ready(function () {
  var observerMaxItem = new MutationObserver(callback);
  var observerOptionsMaxItem = {
    childList: true,
    attributes: true,
    subtree: true
  };
  if ($('.mousehuntHud-page-tabHeader.cheese_shoppe').get(0)) {
    hideMaxOwned();
    observerMaxItem.observe($('.mousehuntHud-page-tabContentContainer').get(0), observerOptionsMaxItem);
  } else if ($('.mousehuntHud-page-tabContent.game_settings').get(0)) {
    addSetting();
    observerMaxItem.observe($('.mousehuntHud-page-tabContentContainer').get(0), observerOptionsMaxItem);
  } else if ($('.mousehuntHud-page-tabContentContainer').get(0)) {
    //not on profile at all. probably at camp.
    observerMaxItem.observe($('.mousehuntHud-page-tabContentContainer').get(0), observerOptionsMaxItem);
  } else {
    return false
  }
});

function callback(mutationList, observer) {
  mutationList.forEach(mutation => {
    if (mutation.type == 'attributes') {
      let $nodes = $(mutation.target);
      if ($nodes.hasClass('mousehuntHud-page-tabHeader cheese_shoppe')) {
        hideMaxOwned();
      } else if ($nodes.hasClass('mousehuntHud-page-tabContent cheese_shoppe')) {
        hideMaxOwned();
      } else if ($nodes.hasClass('mousehuntHud-page-tabContent game_settings')) {
        if (!$('div:contains("Hide Max Owned Items in Shop")').get(0)) {
          addSetting()
        }
      }
    }
  })
};

function hideMaxOwned() {
  if (localStorage.getItem("maxOwnedItems") == "Y") {
    $('[class*="own_max"]').css('visibility', "collapse");
    $('[class*="own_max"]').css('margin-bottom', "-2px");
  }
}

function addSetting() {
  if (localStorage.getItem("maxOwnedItems") == "Y") {
    $('.settingRowTable').slice(-1).append('<div class="settingRow"><div class="settingRow-label"><div class="name">Hide Max Owned Items in Shop</div><div class="defaultSettingText">Enabled</div><div class="description">Setting provided by "MouseHunt - Hide max owned items" script</br>It hides all items you own the max of when enabled.</div></div><div class="settingRow-action"><div class="SettingRow-action-inputContainer"><div class="mousehuntSettingSlider active" onclick=\'if (localStorage.getItem("maxOwnedItems") =="Y"){localStorage.setItem("maxOwnedItems", "N");}else{localStorage.setItem("maxOwnedItems", "Y");};app.pages.PreferencesPage.toggleGameSetting(this);\'></div></div></div></div>')
  } else {
    $('.settingRowTable').slice(-1).append('<div class="settingRow"><div class="settingRow-label"><div class="name">Hide Max Owned Items in Shop</div><div class="defaultSettingText">Enabled</div><div class="description">Setting provided by "MouseHunt - Hide max owned items" script</br>It hides all items you own the max of when enabled.</div></div><div class="settingRow-action"><div class="SettingRow-action-inputContainer"><div class="mousehuntSettingSlider" onclick=\'if (localStorage.getItem("maxOwnedItems") =="Y"){localStorage.setItem("maxOwnedItems", "N");}else{localStorage.setItem("maxOwnedItems", "Y");};app.pages.PreferencesPage.toggleGameSetting(this);\'></div></div></div></div>')
  }
}