MooMoo.io Auto Heal

Simple auto-healing script for MooMoo.io.

< Feedback on MooMoo.io Auto Heal

Değerlendirme: İyi - script çalışıyor

§
Gönderildi: 28.01.2024

Hello, this is a message to the owner, I made a few changes to your script to make the reading clear. Changed the menu to make it look 10x better. No need to give me credit as I only made this account to make this message. In case anyone is wondering, my name is z-r.


// ==UserScript==
// @name         MooMoo.io Auto Heal
// @namespace    https://google.com
// @version      1.0
// @description  Simple auto-healing script for MooMoo.io.
// @match        *://moomoo.io/*
// @match        *://*.moomoo.io/*
// @author       z-r
// @require      https://greasyfork.org/scripts/423602-msgpack/code/msgpack.js
// @grant        none
// @license      MIT
// ==/UserScript==
(function () {
/*
Variables:
*/
  let HealSpeed = 120;
  let HealEnabled = true;
  let items = [];
  let weapons = [];
  let inGame = false;
  let tmpHealth = 100;
  let z3r0 = 0;
  let zrz = 0;
  let msgpack = window.msgpack;
  let ws;

/*
Websocket setup:
*/


  ws = new Promise(function (resolve) {
    let {
      send
    } = WebSocket.prototype;
    WebSocket.prototype.send = function (...x) {
      send.apply(this, x);
      this.send = send;
      this.io = function (...datas) {
        const [packet, ...data] = datas;
        this.send(new Uint8Array(Array.from(msgpack.encode([packet, data]))));
      };
      this.addEventListener("message", function (e) {
        const [packet, data] = msgpack.decode(new Uint8Array(e.data));
        let sid = data[0];
        let health = data[1];
        let inventory = {
          food: items[0],
          walls: items[1],
          spikes: items[2],
          mill: items[3],
          mine: items[4],
          trap: items[5],
          booster: items[6],
          turret: items[7],
          watchtower: items[8],
          buff: items[9],
          spawn: items[10],
          sapling: items[11],
          blocker: items[12],
          teleporter: items[13]
        };
        let addEventListener = {
          setupGame: "C",
          updateHealth: "O",
          killPlayer: "P",
          updateItems: "V"
        };
        switch (packet) {
          case addEventListener.setupGame:
            inGame = true;
            items = [0, 3, 6, 10];
            weapons = [0];
            break;
          case addEventListener.updateHealth:
            if (sid) {
              const AutoHealSpeed = parseInt(document.getElementById('speedInput').value);
              if (inGame && HealEnabled) {
                if (health < 100 && health > 0) {
                  setTimeout(function () {
                    place(inventory.food);
                    place(inventory.food);
                    place(inventory.food);
                    place(inventory.food);
                  }, AutoHealSpeed);
                }
              }
              if (tmpHealth - health < 0) {
                if (z3r0) {
                  let timeHit = Date.now() - z3r0;
                  z3r0 = 0;
                  zrz = timeHit <= 120 ? zrz + 1 : Math.max(0, zrz - 2);
                }
              } else {
                z3r0 = Date.now();
              }
              tmpHealth = health;
            }
            break;
          case addEventListener.killPlayer:
            inGame = false;
            break;
          case addEventListener.updateItems:
            if (sid) {
              if (health) {
                weapons = sid;
              } else {
                items = sid;
              }
            }
            break;
        }
      });
      resolve(this);
    };
  });

/*
Functions:
*/
  const sendPacket = function (...datas) {
    const [type, ...data] = datas;
    var binary = msgpack.encode([type, data]);
    ws.then(function (wsInstance) {
      wsInstance.send(new Uint8Array(Array.from(binary)));
    });
  };

/*
Place:
*/
  const place = function (id, ang) {
    if (inGame) {
      sendPacket("G", id, false);
      hit(ang);
      selectWeapon();
    }
  };

/*
Select weapon:
*/
  const selectWeapon = function () {
    if (inGame) {
      sendPacket("G", weapons[0], true);
    }
  };

/*
Hit:
*/
  const hit = function (id, ang) {
    if (inGame) {
      sendPacket("d", 1, ang);
      sendPacket("d", 0, ang);
    }
  };
/*
Chat:
*/
  const chat = function (e) {
    if (inGame) {
      sendPacket("6", e);
    }
  };

/*
Creating modMenu div:
*/
let modMenus = document.createElement("div");
modMenus.id = "modMenus";
document.body.append(modMenus);

/*
Set CSS styles for modMenu:
*/
modMenus.style.display = "none"; // Initially hide the menu
modMenus.style.flexDirection = "column";
modMenus.style.alignItems = "center";
modMenus.style.padding = "20px";
modMenus.style.backgroundColor = "#282c34"; // Dark background color
modMenus.style.borderRadius = "10px";
modMenus.style.position = "fixed";
modMenus.style.left = "50%";
modMenus.style.top = "50%";
modMenus.style.transform = "translate(-50%, -50%)";
modMenus.style.width = "320px";
modMenus.style.maxHeight = "80vh";
modMenus.style.overflowY = "auto";
modMenus.style.overflowX = "hidden"; // Hide horizontal scrollbar
modMenus.style.boxShadow = "0 8px 16px rgba(0, 0, 0, 0.5)";
modMenus.style.color = "#fff"; // White text color
modMenus.style.fontFamily = "'Roboto', sans-serif"; // Modern font

/*
Update innerhtml content:
*/
function updateInnerHTML() {
  modMenus.innerHTML = `
    <h2 style="font-size: 32px; margin-bottom: 20px;">Auto Heal Settings</h2>
    <hr style="width: 100%; border: none; border-top: 1px solid rgba(255, 255, 255, 0.3); margin-bottom: 20px;">
    <label for="speedInput" style="font-size: 18px; margin-bottom: 10px;">Speed:</label>
    <input type="number" id="speedInput" oninput="this.value = this.value.slice(0, 4)" value=${HealSpeed} style="width: 100%; padding: 10px; margin-bottom: 20px; border: none; border-radius: 8px; background-color: rgba(255, 255, 255, 0.1); color: #fff;"> <!-- White input text color -->
    <input type="checkbox" checked id="AutoHeal" style="margin-right: 10px;">
    <label for="AutoHeal" style="font-size: 18px; color: rgba(255, 255, 255, 0.8);">Enable Auto Heal</label>
    <br>`;
}

/*
Update innerHTML:
*/
updateInnerHTML();


/*
 Toggle modMenus visibility when 'Esc' key is pressed.
*/
document.addEventListener('keydown', function(event) {
  if (event.key === 'Escape') {
    modMenus.style.display = modMenus.style.display === 'none' ? 'flex' : 'none';
  }
});

/*
Script menu continued:
*/
  function ElementGet(id) {
    return document.getElementById(id);
  }

/*
More script-menu:
*/
  ElementGet("AutoHeal").onclick = function () {
    HealEnabled = !HealEnabled;
    chat(`Auto-heal has been ${HealEnabled ? 'enabled.' : 'disabled.'}`);
  };
  ElementGet("speedInput").oninput = function () {
    chat(`Auto-heal speed: ${ElementGet("speedInput").value}`);
  };
})();
§
Gönderildi: 28.01.2024

Hello, this is a message to the owner, I made a few changes to your script to make the reading clear. Changed the menu to make it look 10x better. No need to give me credit as I only made this account to make this message. In case anyone is wondering, my name is z-r.. Press 'esc' for menu.


// ==UserScript==
// @name         MooMoo.io Auto Heal
// @namespace    https://google.com
// @version      1.0
// @description  Simple auto-healing script for MooMoo.io.
// @match        *://moomoo.io/*
// @match        *://*.moomoo.io/*
// @author       z-r
// @require      https://greasyfork.org/scripts/423602-msgpack/code/msgpack.js
// @grant        none
// @license      MIT
// ==/UserScript==
(function () {
/*
Variables:
*/
  let HealSpeed = 120;
  let HealEnabled = true;
  let items = [];
  let weapons = [];
  let inGame = false;
  let tmpHealth = 100;
  let z3r0 = 0;
  let zrz = 0;
  let msgpack = window.msgpack;
  let ws;

/*
Websocket setup:
*/


  ws = new Promise(function (resolve) {
    let {
      send
    } = WebSocket.prototype;
    WebSocket.prototype.send = function (...x) {
      send.apply(this, x);
      this.send = send;
      this.io = function (...datas) {
        const [packet, ...data] = datas;
        this.send(new Uint8Array(Array.from(msgpack.encode([packet, data]))));
      };
      this.addEventListener("message", function (e) {
        const [packet, data] = msgpack.decode(new Uint8Array(e.data));
        let sid = data[0];
        let health = data[1];
        let inventory = {
          food: items[0],
          walls: items[1],
          spikes: items[2],
          mill: items[3],
          mine: items[4],
          trap: items[5],
          booster: items[6],
          turret: items[7],
          watchtower: items[8],
          buff: items[9],
          spawn: items[10],
          sapling: items[11],
          blocker: items[12],
          teleporter: items[13]
        };
        let addEventListener = {
          setupGame: "C",
          updateHealth: "O",
          killPlayer: "P",
          updateItems: "V"
        };
        switch (packet) {
          case addEventListener.setupGame:
            inGame = true;
            items = [0, 3, 6, 10];
            weapons = [0];
            break;
          case addEventListener.updateHealth:
            if (sid) {
              const AutoHealSpeed = parseInt(document.getElementById('speedInput').value);
              if (inGame && HealEnabled) {
                if (health < 100 && health > 0) {
                  setTimeout(function () {
                    place(inventory.food);
                    place(inventory.food);
                    place(inventory.food);
                    place(inventory.food);
                  }, AutoHealSpeed);
                }
              }
              if (tmpHealth - health < 0) {
                if (z3r0) {
                  let timeHit = Date.now() - z3r0;
                  z3r0 = 0;
                  zrz = timeHit <= 120 ? zrz + 1 : Math.max(0, zrz - 2);
                }
              } else {
                z3r0 = Date.now();
              }
              tmpHealth = health;
            }
            break;
          case addEventListener.killPlayer:
            inGame = false;
            break;
          case addEventListener.updateItems:
            if (sid) {
              if (health) {
                weapons = sid;
              } else {
                items = sid;
              }
            }
            break;
        }
      });
      resolve(this);
    };
  });

/*
Functions:
*/
  const sendPacket = function (...datas) {
    const [type, ...data] = datas;
    var binary = msgpack.encode([type, data]);
    ws.then(function (wsInstance) {
      wsInstance.send(new Uint8Array(Array.from(binary)));
    });
  };

/*
Place:
*/
  const place = function (id, ang) {
    if (inGame) {
      sendPacket("G", id, false);
      hit(ang);
      selectWeapon();
    }
  };

/*
Select weapon:
*/
  const selectWeapon = function () {
    if (inGame) {
      sendPacket("G", weapons[0], true);
    }
  };

/*
Hit:
*/
  const hit = function (id, ang) {
    if (inGame) {
      sendPacket("d", 1, ang);
      sendPacket("d", 0, ang);
    }
  };
/*
Chat:
*/
  const chat = function (e) {
    if (inGame) {
      sendPacket("6", e);
    }
  };

/*
Creating modMenu div:
*/
let modMenus = document.createElement("div");
modMenus.id = "modMenus";
document.body.append(modMenus);

/*
Set CSS styles for modMenu:
*/
modMenus.style.display = "none"; // Initially hide the menu
modMenus.style.flexDirection = "column";
modMenus.style.alignItems = "center";
modMenus.style.padding = "20px";
modMenus.style.backgroundColor = "#282c34"; // Dark background color
modMenus.style.borderRadius = "10px";
modMenus.style.position = "fixed";
modMenus.style.left = "50%";
modMenus.style.top = "50%";
modMenus.style.transform = "translate(-50%, -50%)";
modMenus.style.width = "320px";
modMenus.style.maxHeight = "80vh";
modMenus.style.overflowY = "auto";
modMenus.style.overflowX = "hidden"; // Hide horizontal scrollbar
modMenus.style.boxShadow = "0 8px 16px rgba(0, 0, 0, 0.5)";
modMenus.style.color = "#fff"; // White text color
modMenus.style.fontFamily = "'Roboto', sans-serif"; // Modern font

/*
Update innerhtml content:
*/
function updateInnerHTML() {
  modMenus.innerHTML = `
    <h2 style="font-size: 32px; margin-bottom: 20px;">Auto Heal Settings</h2>
    <hr style="width: 100%; border: none; border-top: 1px solid rgba(255, 255, 255, 0.3); margin-bottom: 20px;">
    <label for="speedInput" style="font-size: 18px; margin-bottom: 10px;">Speed:</label>
    <input type="number" id="speedInput" oninput="this.value = this.value.slice(0, 4)" value=${HealSpeed} style="width: 100%; padding: 10px; margin-bottom: 20px; border: none; border-radius: 8px; background-color: rgba(255, 255, 255, 0.1); color: #fff;"> <!-- White input text color -->
    <input type="checkbox" checked id="AutoHeal" style="margin-right: 10px;">
    <label for="AutoHeal" style="font-size: 18px; color: rgba(255, 255, 255, 0.8);">Enable Auto Heal</label>
    <br>`;
}

/*
Update innerHTML:
*/
updateInnerHTML();


/*
 Toggle modMenus visibility when 'Esc' key is pressed.
*/
document.addEventListener('keydown', function(event) {
  if (event.key === 'Escape') {
    modMenus.style.display = modMenus.style.display === 'none' ? 'flex' : 'none';
  }
});

/*
Script menu continued:
*/
  function ElementGet(id) {
    return document.getElementById(id);
  }

/*
More script-menu:
*/
  ElementGet("AutoHeal").onclick = function () {
    HealEnabled = !HealEnabled;
    chat(`Auto-heal has been ${HealEnabled ? 'enabled.' : 'disabled.'}`);
  };
  ElementGet("speedInput").oninput = function () {
    chat(`Auto-heal speed: ${ElementGet("speedInput").value}`);
  };
})();
_VcrazY_Sahip
§
Gönderildi: 04.02.2024

ok thanks, maybe I'll take that into account for the next update

Cevap paylaş

Yanıt göndermek için oturum açın.