🐭️ MouseHunt - Item Quantity Fix

Fixes the "You Own: 0" bug when viewing an item info page.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         🐭️ MouseHunt - Item Quantity Fix
// @version      1.1.0
// @description  Fixes the "You Own: 0" bug when viewing an item info page.
// @license      MIT
// @author       bradp
// @namespace    bradp
// @match        https://www.mousehuntgame.com/i.php
// @icon         https://brrad.com/mouse.png
// @grant        none
// @run-at       document-end
// ==/UserScript==

((function () {
  'use strict';

  // Make sure we have the ID parameter.
  if (window.location.href.indexOf('i.php?id=') === -1) {
    return;
  }

  // Grab the item ID.
  const itemID = window.location.href.split('i.php?id=')[ 1 ];
  if (! itemID) {
    return;
  }

  // Make sure the quantity shown is 0.
  const qty = document.querySelector('.itemView-sidebar-quantity');
  if (! (qty && qty.textContent.indexOf('You Own:') !== -1)) {
    return;
  }

  // Grab the item slug.
  const itemName = document.querySelector('.itemViewContainer').getAttribute('data-item-type');
  if (! itemName) {
    return;
  }

  // redirect to item.php?item_type=itemName
  const newLocation = window.location.href.replaceAll(`i.php?id=${itemID}`, `item.php?item_type=${itemName}`);
  if (newLocation !== window.location.href) {
    window.location.href = newLocation;
  }
})());