Moomoo.io Hat Hotkeys + Custom Title 🎩

Atajos de sombreros con menú editable y título personalizado "🎩 Hat Control"

目前為 2025-07-01 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Moomoo.io Hat Hotkeys + Custom Title 🎩
// @version      1.3
// @description  Atajos de sombreros con menú editable y título personalizado "🎩 Hat Control"
// @match        *://*.moomoo.io/*
// @license      MIT
// @grant        none
// @namespace https://greasyfork.org/users/805514
// ==/UserScript==

(function () {
  'use strict';

  const keys = {};

  let config = {
    menuKey: 'b',
    binds: {
      r: { id: 7, name: "Bull Helmet" },
      g: { id: 6, name: "Soldier Helmet" },
      z: { id: 40, name: "Tank Gear" },
      t: { id: 53, name: "Turret Gear" },
      j: { id: 22, name: "Emp Helmet" },
      u: { id: 12, name: "Booster Hat" },
      y: { id: 31, name: "Flipper Hat" },
      n: { id: 15, name: "Winter Cap" }
    }
  };

  function storeEquipOrBuy(id) {
    if (typeof storeBuy === 'function') storeBuy(id);
    if (typeof storeEquip === 'function') storeEquip(id);
  }

  function checkKeys() {
    for (let k in config.binds) {
      if (keys[k] || keys[k.toUpperCase()]) {
        storeEquipOrBuy(config.binds[k].id);
      }
    }
  }

  window.addEventListener('keydown', e => {
    if (document.activeElement.id === 'chatBox') return;
    keys[e.key] = true;
    if (e.key.toLowerCase() === config.menuKey) toggleMenu();
    else checkKeys();
  });

  window.addEventListener('keyup', e => {
    keys[e.key] = false;
  });

  // Crear menú
  const menu = document.createElement('div');
  menu.id = 'hatHotkeyMenu';
  menu.style = `
    position:absolute;
    top:10px;
    right:10px;
    padding:10px;
    background:#f9f9f9;
    border:2px solid #444;
    border-radius:10px;
    font-family:sans-serif;
    z-index:9999;
    display:none;
  `;

  function buildMenu() {
    menu.innerHTML = `<h3>🎩 Hat Control</h3>`;
    menu.innerHTML += `<div><label>Tecla de menú: <input id="menuKey" value="${config.menuKey}" size="1"></label></div><hr>`;
    for (let k in config.binds) {
      const hat = config.binds[k];
      menu.innerHTML += `
        <div>
          <label><b>${hat.name}</b> → Tecla: 
          <input data-hat="${hat.name}" data-id="${hat.id}" value="${k.toUpperCase()}" size="2"></label>
        </div>`;
    }
    menu.innerHTML += `<hr><button id="saveHotkeys">Guardar</button>`;
  }

  buildMenu();
  document.body.appendChild(menu);

  menu.addEventListener('click', e => {
    if (e.target.id === 'saveHotkeys') {
      const newBinds = {};
      config.menuKey = document.getElementById('menuKey').value;
      document.querySelectorAll('#hatHotkeyMenu input[data-hat]').forEach(inp => {
        const newKey = inp.value.toLowerCase();
        const name = inp.getAttribute('data-hat');
        const id = parseInt(inp.getAttribute('data-id'));
        if (newKey && !isNaN(id)) {
          newBinds[newKey] = { id, name };
        }
      });
      config.binds = newBinds;
      alert('Teclas actualizadas correctamente');
      buildMenu();
    }
  });

  function toggleMenu() {
    menu.style.display = (menu.style.display === 'none') ? 'block' : 'none';
  }

  // Cambiar el título del menú principal del juego
  const menuObserver = new MutationObserver(() => {
    const title = document.querySelector('#mainMenu h1');
    if (title && title.innerText !== '🎩 Hat Control') {
      title.innerText = '🎩 Hat Control';
    }
  });
  menuObserver.observe(document.body, { childList: true, subtree: true });

  // Cambiar título de la pestaña del navegador
  const tabObserver = new MutationObserver(() => {
    if (document.title !== '🎩 Hat Control') {
      document.title = '🎩 Hat Control';
    }
  });
  tabObserver.observe(document.querySelector('head') || document.body, { childList: true, subtree: true });

})();