Greasy Fork

Greasy Fork is available in English.

MooMoo.io Bow Insta Helper

Helps you to bow insta faster

当前为 2023-04-01 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         MooMoo.io Bow Insta Helper
// @description  Helps you to bow insta faster
// @author       WEIRD
// @match        *://*.moomoo.io/*
// @icon         https://moomoo.io/img/favicon.png?v=1
// @require      https://cdnjs.cloudflare.com/ajax/libs/msgpack-lite/0.1.26/msgpack.min.js
// @run-at       document-start
// @grant        unsafeWindow
// @license      MIT
// @version      0.5
// @namespace    http://greasyfork.icu/users/999838
// ==/UserScript==

/*
- To activate or deactivate the helper, simply click the middle mouse button
- Adjust your position with precision by pressing the "Z" key and using your mouse as a guide
- The helper will display a circle around you, representing the maximum range of the turret gear bullet
*/

;(async () => {
	unsafeWindow.bowInstaHelper = true

	const mouse = {
		x: null,
		y: null
	}
	let toggle = false
	var inGame = false
	new Promise(async (resolve) => {
		let { send } = WebSocket.prototype

		WebSocket.prototype.send = function (...x) {
			send.apply(this, x)
			this.addEventListener("message", (e) => {
				const [packet, data] = msgpack.decode(new Uint8Array(e.data))
				let storeHolder = unsafeWindow.customStore
					? document.getElementById("customStoreHolder")
					: document.getElementById("storeHolder")
				let gameUI = document.getElementById("gameUI")
				let upgradeHolder = document.getElementById("upgradeHolder")
				switch (packet) {
					case "1":
						inGame = true
						break
					case "11":
						inGame = false
						if (toggle) {
							toggle = false
							gameUI.style.visibility = null

							storeHolder.style.position = null
							storeHolder.style.left = null
							storeHolder.style.top = null

							upgradeHolder.style.left = null
							upgradeHolder.style.top = null
						}
						break
				}
			})
			resolve(this)
		}
	})

	new Promise(async (resolve) => {
		let { clearRect } = CanvasRenderingContext2D.prototype

		CanvasRenderingContext2D.prototype.clearRect = function (...x) {
			clearRect.apply(this, x)
			if (toggle) {
				let ctx = document.getElementById("gameCanvas").getContext("2d")
				let maxScreenWidth = unsafeWindow.config.maxScreenWidth
				let maxScreenHeight = unsafeWindow.config.maxScreenHeight
				ctx.beginPath()
				ctx.arc(maxScreenWidth / 2, maxScreenHeight / 2, 700, 0, 2 * Math.PI, false)
				ctx.fillStyle = "rgb(0, 0, 0, 0.1)"
				ctx.fill()
			}
			resolve(this)
		}
	})

	function waitForElm(selector) {
		return new Promise((resolve) => {
			if (document.querySelector(selector)) {
				return resolve(document.querySelector(selector))
			}

			const observer = new MutationObserver((mutations) => {
				if (document.querySelector(selector)) {
					resolve(document.querySelector(selector))
					observer.disconnect()
				}
			})

			observer.observe(document.body, {
				childList: true,
				subtree: true
			})
		})
	}

	document.addEventListener("DOMContentLoaded", () => {
		let gameUI = document.getElementById("gameUI")
		let upgradeHolder = document.getElementById("upgradeHolder")
		upgradeHolder.style.visibility = "visible"
		document.getElementById("storeButton").style.visibility = "visible"
		document.getElementById("chatHolder").style.visibility = "visible"
		document.getElementById("mapDisplay").style.visibility = "visible"
		document.getElementById("storeMenu").style.visibility = "visible"

		document.addEventListener("keydown", (event) => {
			if (
				inGame &&
				event.code == "KeyZ" &&
				toggle &&
				document.getElementById("allianceMenu").style.display != "block" &&
				document.getElementById("chatHolder").style.display != "block"
			) {
				let storeHolder = unsafeWindow.customStore
					? document.getElementById("customStoreHolder")
					: document.getElementById("storeHolder")
				storeHolder.style.position = "absolute"
				storeHolder.style.left = mouse.x - 370 + "px"
				storeHolder.style.top = mouse.y - window.innerHeight / 2 + "px"

				upgradeHolder.style.left = mouse.x - (window.innerWidth / 1600) * 815 + "px"
				upgradeHolder.style.top = mouse.y - 33 + "px"
			}
		})

		document.addEventListener("mousedown", (event) => {
			if (
				inGame &&
				event.button == 1 &&
				document.getElementById("allianceMenu").style.display != "block" &&
				document.getElementById("chatHolder").style.display != "block"
			) {
				if (toggle) {
					toggle = false
					gameUI.style.visibility = null

					let storeHolder = unsafeWindow.customStore
						? document.getElementById("customStoreHolder")
						: document.getElementById("storeHolder")
					storeHolder.style.position = null
					storeHolder.style.left = null
					storeHolder.style.top = null

					upgradeHolder.style.left = null
					upgradeHolder.style.top = null
				} else {
					toggle = true
					gameUI.style.visibility = "hidden"

					storeHolder.style.position = "absolute"
					storeHolder.style.left = mouse.x - 370 + "px"
					storeHolder.style.top = mouse.y - window.innerHeight / 2 + "px"

					upgradeHolder.style.left = mouse.x - (window.innerWidth / 1600) * 815 + "px"
					upgradeHolder.style.top = mouse.y - 33 + "px"
				}
			}
		})

		document.getElementById("gameCanvas").addEventListener("mousemove", (event) => {
			mouse.x = event.clientX
			mouse.y = event.clientY
		})
	})
})()