Greasy Fork

🐭️ MouseHunt - Item Quantity Fix

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

目前为 2022-07-04 提交的版本。查看 最新版本

// ==UserScript==
// @name         🐭️ MouseHunt - Item Quantity Fix
// @version      1.0.1
// @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
// ==/UserScript==

/**
 * On load check for the item quantity and url param.
 */
 $(document).ready(function () { // eslint-disable-line no-undef
	const urlParam = 'i.php?id=';

	if (window.location.href.indexOf(urlParam) === -1) {
		return;
	}

	const id = window.location.href.split(urlParam)[1];

	const qty = document.querySelector('.itemView-sidebar-quantity');
	if (! (qty && qty.textContent.indexOf('You Own:') !== -1)) {
		return;
	}

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

	hg.views.ItemView.show(itemName);
});