Queso Cannonstorm Base Reminder

Requires MouseHunt Improved. Reminds the user to switch to the Queso Cannonstorm Base when traveling to somewhere in the Queso Region.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Queso Cannonstorm Base Reminder
// @description Requires MouseHunt Improved. Reminds the user to switch to the Queso Cannonstorm Base when traveling to somewhere in the Queso Region.
// @version     1.0.0
// @license     MIT
// @author      bradp
// @namespace   bradp
// @match       https://www.mousehuntgame.com/*
// @icon        https://brrad.com/mouse.png
// @run-at      document-end
// @grant       none
// ==/UserScript==
(function() {
  'use strict';

  // Ensure that the script only runs after MouseHunt Improved has loaded.
  document.addEventListener('mh-improved-loaded', () => {
    // Log a load message to the console for debugging purposes.
    app.mhutils.debuglog('Queso Cannonstorm Base Reminder', 'Loaded user script.');

    // We pass null as the first argument as we want to run this on every travel
    // and do our own location check. If we passed a location, it would only run
    // when traveling to that specific location.
    app.mhutils.onTravel(null, { callback: () => {
      const locations = [ 'queso_river', 'queso_plains', 'queso_quarry', 'queso_geyser'];
      if (! locations.includes(app.mhutils.getCurrentLocation())) {
        return;
      }

      // If the user has the base equipped, don't do anything.
      if (3526 === user.base_item_id) {
        return;
      }

      app.mhutils.showHornMessage({
        title: 'Base Reminder',
        text: 'Switch your base to the Queso Cannonstorm Base.',
        color: 'orange',
        button: 'Switch',
        dismiss: 5000, // Automatically closes the reminder after 5 seconds.
        action: () => {
          // Open up the base selector so the user can switch bases.
          document.querySelector('.campPage-base-armedItem.base')?.click();
        }
      });
    }});

    // If you only need to check when traveling to a single location, you can simplify the code by replacing the entire app.mhutils.onTravel call with this one:
    /*
    app.mhutils.onTravel('queso_river', { callback: () => {
      if (3526 !== user.base_item_id) {
        app.mhutils.showHornMessage({
          title: 'Base Reminder',
          text: 'Switch your base to the Queso Cannonstorm Base.',
          color: 'orange',
          button: 'Switch',
          dismiss: 5000, // Automatically closes the reminder after 5 seconds.
          action: () => {
            document.querySelector('.campPage-base-armedItem.base')?.click();
          }
        });
      }
    }});
    */
  });
})();