Fixes the "You Own: 0" bug when viewing an item info page.
当前为
// ==UserScript==
// @name 🐭️ Mousehunt - Item Quantity Fix
// @version 1.0.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
// ==/UserScript==
/**
* On load, check to see if we hit the bug and if so, redirect correctly.
*/
$(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;
}
window.location.replace( window.location.href.replace(urlParam + id, `i.php?item_type=${ itemName }`) );
});