MooMoo.io Change Resolution

Change the resolution of canvas to boost your FPS

您需要先安裝使用者腳本管理器擴展,如 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 Change Resolution
// @description  Change the resolution of canvas to boost your FPS
// @author       WEIRD
// @match        *://*.moomoo.io/*
// @icon         https://moomoo.io/img/favicon.png?v=1
// @run-at       document-start
// @grant        unsafeWindow
// @license      MIT
// @version      0.1.1
// @namespace    https://greasyfork.org/users/999838
// ==/UserScript==

;(() => {
	unsafeWindow.changeResolution = true

	const checkTrustedSymbol = Symbol("checkTrusted")
	Object.defineProperty(Object.prototype, "checkTrusted", {
		get() {
			return this[checkTrustedSymbol]
		},
		set() {
			delete Object.prototype.checkTrusted
			this.checkTrusted = (e) => e
		},
		configurable: true
	})

	var resolutionValue = localStorage.getItem("resolutionValue")
	if (resolutionValue == null) {
		resolutionValue = 0.9
		localStorage.setItem("resolutionValue", resolutionValue)
	}

	unsafeWindow.addEventListener("DOMContentLoaded", () => {
		const parent =
			document.getElementsByClassName("settingRadio")[0]
		parent.childNodes[1].textContent = " Change Resolution"
		unsafeWindow.devicePixelRatio = resolutionValue
		document.getElementById("nativeResolution").dispatchEvent(
			new Event("change")
		)

		const container = document.createElement("div")
		container.className = "settingRadio"
		const numInput = document.createElement("input")
		numInput.type = "number"
		numInput.step = "0.1"
		numInput.min = "0.1"
		numInput.max = "3"
		numInput.value = resolutionValue
		numInput.addEventListener("change", (event) => {
            if (event.target.value < event.target.min) {
                event.target.value = event.target.min
            } else if (event.target.value > event.target.max) {
                event.target.value = event.target.max
            } else if (event.target.value == null) {
                event.target.value = 0.9
            }
			resolutionValue = unsafeWindow.devicePixelRatio = event.target.value
			localStorage.setItem("resolutionValue", resolutionValue)
			document.getElementById(
				"nativeResolution"
			).dispatchEvent(new Event("change"))
		})
		container.appendChild(numInput)
		parent.parentNode.insertBefore(container, parent.nextSibling)
	})
})()