Anti Invisible Buildings [No bundle]

Draws invisible objects (Sets a new dir (angle) for them)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Anti Invisible Buildings [No bundle]
// @namespace    -
// @version      0.1
// @description  Draws invisible objects (Sets a new dir (angle) for them)
// @author       Nudo#3310
// @match        *://moomoo.io/*
// @match        *://sandbox.moomoo.io/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=moomoo.io
// @grant        none
// ==/UserScript==

(function() {
    /**
     * @class AntiInvisible
     */
    let AntiInvisible = {}

    let { rotate } = CanvasRenderingContext2D.prototype

    /**
     * When the game is fully loaded, the main AntiInvisible parameters will be set
     * @method init
     */
    AntiInvisible.init = function() {
        /**Activate AntiInvisible*/
        AntiInvisible.toggler = true

        /**How transparent will the object itself be*/
        AntiInvisible.opacity = .6

        /**On which dir (angle) will AntiInvisible work*/
        AntiInvisible.invisibleAngle = 38e38
    }

    AntiInvisible.init()

    /**
     * Return fixed object direction.
     * @method getFixedDir
     * @param {Number} angle
     * @returns {Number} New object angle
     */
    AntiInvisible.getFixedDir = function(angle) {
        return Math.atan2(Math.sin(angle), Math.cos(angle))
    }

    /**
     * If it does not match the game normal dir then returns true otherwise false
     * @method isAbnormalDir
     * @param {Number} angle
     * @returns {Boolean}
     */
    AntiInvisible.isAbnormalDir = function(angle) {
        if (angle <= -AntiInvisible.invisibleAngle || angle >= AntiInvisible.invisibleAngle) {
            return true
        }
        return false
    }

    /**
     * Set opacity (globalAlpha) for an object
     * @method setOpacity
     * @param {Number} opacity
     */
    AntiInvisible.setOpacity = function(opacity) {
        this.globalAlpha = opacity
    }

    /**
     * Rotates the image
     * @method rotate
     * @param {Number} angle
     * @returns {function}
     */
    CanvasRenderingContext2D.prototype.rotate = function(angle) {
        if (AntiInvisible.isAbnormalDir(angle) && AntiInvisible.toggler) {
            angle = AntiInvisible.getFixedDir(angle)

            AntiInvisible.setOpacity.call(this, AntiInvisible.opacity)

            return rotate.call(this, angle)
        }

        return rotate.apply(this, arguments)
    }
})()