您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
This script allows you to record your inventory and catch stats to be able to compare them over time.
当前为
// ==UserScript== // @name MH: Inventory History // @author Warden Slayer - Warden Slayer#2302 // @namespace http://greasyfork.icu/en/users/227259-wardenslayer // @version 1.0.3 // @description This script allows you to record your inventory and catch stats to be able to compare them over time. // @resource YOUR_CSS https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.2/jquery-confirm.min.css // @require https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/js/all.js // @require https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.2/jquery-confirm.min.js // @include https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js // @include http://www.mousehuntgame.com/* // @include https://www.mousehuntgame.com/* // @grant GM_setClipboard // @grant GM_xmlhttpRequest // @grant GM_getResourceText // @connect self // @connect script.google.com // @connect script.googleusercontent.com // // ==/UserScript== $(document).ready(function() { addTouchPoint(); }); function addTouchPoint() { if ($('.invHix').length == 0) { const invPages = $('.inventory .torn_pages'); //Inventory History Button const invHix = document.createElement('li'); invHix.classList.add('invHix'); const invHixBtn = document.createElement('a'); invHixBtn.href = "#"; invHixBtn.innerText = "Inventory History"; invHixBtn.onclick = function () { onInvHXOnClick(); }; const icon = document.createElement("div"); icon.className = "icon"; invHixBtn.appendChild(icon); invHix.appendChild(invHixBtn); $(invHix).insertAfter(invPages); } } function getInvNow() { localStorage.setItem('ws.mh.invHx',""); localStorage.setItem('ws.mh.invHx.mice',""); fetchInventory(); getMice(); setTimeout(publishResults,5000); } function fetchInventory() { const itemsToGet = ['weapon','base', 'trinket', 'bait', 'skin', 'crafting_item','convertible', 'potion', 'stat','collectible','map_piece','adventure']; //future proof this to allow for exclusions let itemsArray = []; hg.utils.UserInventory.getItemsByClass(itemsToGet,true,function(data) { data.forEach(function(arrayItem, index) { itemsArray[index] = [arrayItem.name,arrayItem.quantity]; }) //hunter stats itemsArray.push(['Rank Percent',user.title_percent_accurate],['Points',user.points],['Gold',user.gold]); getHunts(itemsArray); }) //console.log('items done') return itemsArray } function getHunts(itemsArray) { let hunts = []; hg.utils.User.getUserData([user.sn_user_id],['num_active_turns','num_passive_turns','num_link_turns','num_total_turns','map_num_clues_found','map_num_maps_dusted','wisdom','not_actually_real_field'],function(data) { const numClues = ['Map Clues',data[0].map_num_clues_found]; const numDust = ['Maps Dusted',data[0].map_num_maps_dusted]; const numHorns = ['Horn Calls',data[0].num_active_turns]; const numTrapChecks = ['Trap Checks',data[0].num_passive_turns]; const wisdom = ['Wisdom',data[0].wisdom]; let numFriendHorns = []; if(data[0].num_link_turns) { numFriendHorns = ['Friend Horns',data[0].num_link_turns]; } else { numFriendHorns = ['Friend Horns',data[0].num_total_turns-data[0].num_active_turns-data[0].num_passive_turns]; } const numHunts = ['Total Hunts',data[0].num_total_turns]; itemsArray.push(numHorns,numTrapChecks,numFriendHorns,numHunts,numClues,numDust,wisdom); getCrowns(itemsArray); }) //console.log('stats done') return itemsArray } function getCrowns (itemsArray) { hg.utils.MouseUtil.getCrowns(function(data) { data.forEach(function(arrayItem, i) { let crownName = arrayItem.name; if (arrayItem.type == "none") { crownName = 'Uncrowned Mice'; } else { crownName = crownName.concat(' Crowns'); } itemsArray.push([crownName,arrayItem.count]); }) localStorage.setItem('ws.mh.invHx', JSON.stringify(itemsArray)) }) //console.log('crowns done') return itemsArray } function getMice() { let mouseArray = []; hg.utils.MouseUtil.getHuntingStats(function(data) { data.forEach(function(arrayItem, index) { const mouseName = correctMouseName(arrayItem.name); mouseArray[index] = [mouseName, arrayItem.num_catches, arrayItem.num_misses]; }) localStorage.setItem('ws.mh.invHx.mice', JSON.stringify(mouseArray)); }) //console.log('mice done') return mouseArray } function correctMouseName(mouseName) { mouseName = mouseName.replace(" Mouse", ""); let newMouseName = ""; if (mouseName == "Ful'Mina, The Mountain Queen") { newMouseName = "Ful'mina the Mountain Queen"; } else if (mouseName == "Inferna, The Engulfed") { newMouseName = "Inferna the Engulfed"; } else if (mouseName == "Nachous, The Molten") { newMouseName = "Nachous the Molten"; } else if (mouseName == "Stormsurge, the Vile Tempest") { newMouseName = "Stormsurge the Vile Tempest"; } else if (mouseName == "Bruticus, the Blazing") { newMouseName = "Bruticus the Blazing"; } else if (mouseName == "Vincent, The Magnificent") { newMouseName = "Vincent The Magnificent"; } else if (mouseName == "Corky, the Collector") { newMouseName = "Corky the Collector"; } else { newMouseName = mouseName; } return newMouseName; } function publishResults(){ const debug = localStorage.getItem('ws.debug'); const webAppURL = localStorage.getItem('ws.mh.invHx.webApp'); let timestamp_label = localStorage.getItem('ws.mh.invHx.dataLabel'); const itemArray = localStorage.getItem('ws.mh.invHx'); const mouseArray = localStorage.getItem('ws.mh.invHx.mice'); if (debug == true) { console.log('Inventory',itemArray); console.log('Mice',mouseArray); } if (timestamp_label) { } else { timestamp_label = new Date().toString().split(" G")[0]; } if (webAppURL){ if (debug == true) { console.log(webAppURL); } GM_xmlhttpRequest({ method: "POST", url: webAppURL, data: JSON.stringify({ inventory: itemArray, timestamp: timestamp_label,mice: mouseArray}), onload: function(response) { if (debug == true) { console.log('Inventory Submitted') } }, onerror: function(response) { if (debug == true) { console.log('No Good, Error') } } }); } else { myAlert(); } } //========== Modals ======================// //https://craftpip.github.io/jquery-confirm/#getting-started function onInvHXOnClick(){ $.confirm({ title: 'MH: Inventory History', content: '' + '<form action="" class="formName">' + '<div class="form-group">' + '<label>Custom Data Label</label>' + '<input type="text" placeholder="Give this data a name (i.e Pre-GWH) so you can recognize it (optional)" class="inventory nickname" size="100" "/>' + '<div width = "100"</div>' + '<label>Paste your WebApp link here. Only needed the first time unless you need to update it.</label>' + '<input type="text" placeholder="Paste WebApp Link Here" class="webapp link" size="100" "/>' + '</div>' + '</form>', boxWidth: '50%', useBootstrap: false, closeIcon: true, icon: 'fas fa-history', draggable: true, theme: 'dark', buttons: { formSubmit: { text: 'Submit Inventory', btnClass: 'btn-blue', action: function () { const link = this.$content.find('.webapp.link').val(); const dataLabel = this.$content.find('.inventory.nickname').val(); if (link) { localStorage.setItem('ws.mh.invHx.dataLabel',dataLabel) localStorage.setItem('ws.mh.invHx.webApp',link) getInvNow(); } else if (localStorage.getItem('ws.mh.invHx.webApp')) { localStorage.setItem('ws.mh.invHx.dataLabel',dataLabel) getInvNow(); } else { myAlert(); } } }, cancel: function () { }, }, }) } function myAlert() { var icon = 'fas fa-exclamation-circle' var title = "WebApp Link Error" $.alert({ autoClose: 'acknowledge|60000', title: title, content: 'There was an issue with your web app link. Please paste it in again', icon: icon, type: 'dark', typeAnimated: true, boxWidth: '30%', useBootstrap: false, draggable: true, escapeKey: 'aknowledge', buttons: { acknowledge: { text: 'Ok', keys: ['enter', 'space'], btnClass: 'btn-red', action: function() { } }, } }) }