Anti Invisible Buildings [No bundle]

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

当前为 2022-05-17 提交的版本,查看 最新版本

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

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

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

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

您需要先安装一款用户脚本管理器扩展,例如 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)
    }
})()