MooMoo.io Auto Triple Mill

Automatically place Triple Mill in MooMoo.io when the [M] key is pressed.

  1. // ==UserScript==
  2. // @name MooMoo.io Auto Triple Mill
  3. // @namespace https://gf.qytechs.cn/users/1064285-vcrazy-gaming
  4. // @version 0.2
  5. // @description Automatically place Triple Mill in MooMoo.io when the [M] key is pressed.
  6. // @match *://moomoo.io/*
  7. // @match *://*.moomoo.io/*
  8. // @author _VcrazY_
  9. // @require https://cdn.jsdelivr.net/npm/msgpack-lite@0.1.26/dist/msgpack.min.js
  10. // @grant none
  11. // @icon https://moomoo.io/img/favicon.png?v=1
  12. // @license MIT
  13. // ==/UserScript==
  14. (() => {
  15. // Constants and Variables
  16. let ws = null;
  17. let x = 0;
  18. let y = 0;
  19. let msgpack5 = window.msgpack;
  20. let scale = 45;
  21. let placeOffset = 5;
  22. let autoMill = false;
  23. const inventory = {
  24. primary: null,
  25. secondary: null,
  26. food: null,
  27. wall: null,
  28. spike: null,
  29. mill: null,
  30. mine: null,
  31. boostPad: null,
  32. trap: null,
  33. turret: null,
  34. spawnpad: null
  35. };
  36. const vars = {
  37. camX: 0,
  38. camY: 0
  39. };
  40. const myPlayer = {
  41. sid: null,
  42. x: null,
  43. y: null,
  44. dir: null,
  45. buildIndex: null,
  46. weaponIndex: null,
  47. weaponVariant: null,
  48. team: null,
  49. isLeader: null,
  50. skinIndex: null,
  51. tailIndex: null,
  52. iconIndex: null
  53. };
  54.  
  55. // Helper Functions
  56.  
  57. /**
  58. * Utility function to join arrays
  59. * @param {Array} message - The array to join
  60. * @returns {Array} - Joined array
  61. */
  62. const join = message => Array.isArray(message) ? [...message] : [...message];
  63.  
  64. /**
  65. * Hook function for WebSocket
  66. * @param {object} ms - WebSocket message
  67. */
  68. const hookWS = ms => {
  69. let tmpData = msgpack5.decode(new Uint8Array(ms.data));
  70. if ((ms = undefined) || (tmpData = (ms = tmpData.length > 1 ? [tmpData[0], ...join(tmpData[1])] : tmpData)[0]) || ms) {
  71. if ("C" == tmpData && null === myPlayer.sid && (myPlayer.sid = ms[1]) || "a" == tmpData) {
  72. for (tmpData = 0; tmpData < ms[1].length / 13; tmpData++) {
  73. let data = ms[1].slice(13 * tmpData, 13 * (tmpData + 1));
  74. if (data[0] == myPlayer.sid) {
  75. Object.assign(myPlayer, {
  76. x: data[1],
  77. y: data[2],
  78. dir: data[3],
  79. buildIndex: data[4],
  80. weaponIndex: data[5],
  81. weaponVariant: data[6],
  82. team: data[7],
  83. isLeader: data[8],
  84. skinIndex: data[9],
  85. tailIndex: data[10],
  86. iconIndex: data[11]
  87. });
  88. }
  89. }
  90. }
  91. vars.camX || (vars.camX = myPlayer.x);
  92. vars.camY || (vars.camY = myPlayer.y);
  93. if (y !== myPlayer.y || x !== myPlayer.x) {
  94. // AUTO MILL CODE:
  95. if (Math.atan2(y - myPlayer.y, x - myPlayer.x) < (scale + placeOffset) * 2) {
  96. if (autoMill) {
  97. let angle = Math.atan2(y - myPlayer.y, x - myPlayer.x);
  98. place(inventory.mill, angle + Math.PI / 2.5);
  99. place(inventory.mill, angle);
  100. place(inventory.mill, angle - Math.PI / 2.5);
  101. }
  102. x = myPlayer.x;
  103. y = myPlayer.y;
  104. }
  105. }
  106. cacheItems();
  107. }
  108. };
  109. /**
  110. * Function to emit a packet
  111. * @param {string} event - Event type
  112. * @param {*} a - Parameter a
  113. * @param {*} b - Parameter b
  114. * @param {*} c - Parameter c
  115. * @param {*} m - Parameter m
  116. * @param {*} r - Parameter r
  117. */
  118. const emit = (event, a, b, c, m, r) => ws.send(Uint8Array.from([...msgpack5.encode([event, [a, b, c, m, r]])]));
  119.  
  120. /**
  121. * Function to place an item
  122. * @param {number} event - Event type
  123. * @param {number} l - Angle
  124. */
  125. const place = (event, l) => {
  126. emit("G", event, false);
  127. emit("d", 1, l);
  128. emit("d", 0, l);
  129. emit("G", myPlayer.weaponIndex, true);
  130. };
  131.  
  132. /**
  133. * Function to send a chat message
  134. * @param {string} event - The chat message
  135. */
  136. const chat = event => emit("6", event);
  137.  
  138. /**
  139. * Cache the player's items
  140. */
  141. const cacheItems = () => {
  142. for (let c = 0; c < 9; c++) {
  143. var _document$getElementB;
  144. if (((_document$getElementB = document.getElementById(`actionBarItem${c}`)) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.offsetParent) !== null) {
  145. inventory.primary = c;
  146. }
  147. }
  148. for (let s = 9; s < 16; s++) {
  149. var _document$getElementB2;
  150. if (((_document$getElementB2 = document.getElementById(`actionBarItem${s}`)) === null || _document$getElementB2 === void 0 ? void 0 : _document$getElementB2.offsetParent) !== null) {
  151. inventory.secondary = s;
  152. }
  153. }
  154. for (let P = 16; P < 19; P++) {
  155. var _document$getElementB3;
  156. if (((_document$getElementB3 = document.getElementById(`actionBarItem${P}`)) === null || _document$getElementB3 === void 0 ? void 0 : _document$getElementB3.offsetParent) !== null) {
  157. inventory.food = P - 16;
  158. }
  159. }
  160. for (let f = 19; f < 22; f++) {
  161. var _document$getElementB4;
  162. if (((_document$getElementB4 = document.getElementById(`actionBarItem${f}`)) === null || _document$getElementB4 === void 0 ? void 0 : _document$getElementB4.offsetParent) !== null) {
  163. inventory.wall = f - 16;
  164. }
  165. }
  166. for (let _ = 22; _ < 26; _++) {
  167. var _document$getElementB5;
  168. if (((_document$getElementB5 = document.getElementById(`actionBarItem${_}`)) === null || _document$getElementB5 === void 0 ? void 0 : _document$getElementB5.offsetParent) !== null) {
  169. inventory.spike = _ - 16;
  170. }
  171. }
  172. for (let u = 26; u < 29; u++) {
  173. var _document$getElementB6;
  174. if (((_document$getElementB6 = document.getElementById(`actionBarItem${u}`)) === null || _document$getElementB6 === void 0 ? void 0 : _document$getElementB6.offsetParent) !== null) {
  175. inventory.mill = u - 16;
  176. }
  177. }
  178. for (let I = 29; I < 31; I++) {
  179. var _document$getElementB7;
  180. if (((_document$getElementB7 = document.getElementById(`actionBarItem${I}`)) === null || _document$getElementB7 === void 0 ? void 0 : _document$getElementB7.offsetParent) !== null) {
  181. inventory.mine = I - 16;
  182. }
  183. }
  184. for (let p = 31; p < 33; p++) {
  185. var _document$getElementB8;
  186. if (((_document$getElementB8 = document.getElementById(`actionBarItem${p}`)) === null || _document$getElementB8 === void 0 ? void 0 : _document$getElementB8.offsetParent) !== null) {
  187. inventory.boostPad = p - 16;
  188. }
  189. }
  190. for (let x = 31; x < 33; x++) {
  191. var _document$getElementB9;
  192. if (((_document$getElementB9 = document.getElementById(`actionBarItem${x}`)) === null || _document$getElementB9 === void 0 ? void 0 : _document$getElementB9.offsetParent) !== null) {
  193. inventory.trap = x - 16;
  194. }
  195. }
  196. for (let g = 29; g < 31; g++) {
  197. var _document$getElementB10;
  198. if (((_document$getElementB10 = document.getElementById(`actionBarItem${g}`)) === null || _document$getElementB10 === void 0 ? void 0 : _document$getElementB10.offsetParent) !== null && g !== 36) {
  199. inventory.turret = g - 16;
  200. }
  201. }
  202. inventory.spawnpad = 36;
  203. };
  204.  
  205. // Override WebSocket's send method
  206. document.msgpack = window.msgpack;
  207. WebSocket.prototype.oldSend = WebSocket.prototype.send;
  208. WebSocket.prototype.send = function (event) {
  209. ws || (document.ws = this, ws = this, document.ws.addEventListener("message", hookWS));
  210. this.oldSend(event);
  211. };
  212.  
  213. // Event listener for [M] key to toggle autoMill
  214. document.addEventListener("keydown", event => {
  215. if (event.keyCode === 77 && document.activeElement.id.toLowerCase() !== 'chatbox') {
  216. autoMill = !autoMill;
  217. chat(`Auto Triple Mill : ${autoMill ? 'enabled' : 'disabled'}`);
  218. }
  219. });
  220. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址