★moomoo.io DetailMiniMap Fixed! Working 2021

Add details to the existing mini map. (wood/food/stone/points)

目前為 2021-12-19 提交的版本,檢視 最新版本

// ==UserScript==
// @name			★moomoo.io DetailMiniMap Fixed! Working 2021
// @version			2.0
// @description		Add details to the existing mini map. (wood/food/stone/points)
// @author			nekosan (Fixed by Jet-X)
// @match			*://moomoo.io/*
// @grant			none
// @namespace		https://gf.qytechs.cn/en/scripts/29014-moomoo-io-detailminimap
// @license MIT
// ==/UserScript==

import("https://rawgit.com/kawanet/msgpack-lite/master/dist/msgpack.min.js");

(function() {
    'use strict';

    var conf = {
        'map': {
            'w': '200',
            'h': '200',
            'bottom': '80',
            'left': '20'
        },
        'resource':{
            'wood': {
                'color': '#8ecc51',
                'w': '3',
                'h': '3'
            },
            'food': {
                'color': '#ff3333',
                'w': '5',
                'h': '5'
            },
            'stone': {
                'color': '#888888',
                'w': '5',
                'h': '5'
            },
            'points': {
                'color': '#ffee33',
                'w': '5',
                'h': '5'
            }
        },
        'scale': 13200.0
    };

    var ws = null;
    WebSocket.prototype.sender = WebSocket.prototype.send;
    WebSocket.prototype.send = function(m){
        if(ws === null){
            ws = this;
            this.addEventListener('message', handleMessage);
        }
        this.sender(...arguments);
    }

    // Change Layout
    $('#mapDisplay').css({
        'bottom': conf.map.bottom + 'px',	// default 20px
        'left': conf.map.left + 'px',		// default 20px
        'width': conf.map.w + 'px',			// default 130px
        'height': conf.map.h + 'px'			// default 130px
    });
    $('#scoreDisplay').css({
        'bottom': '20px',					// default 20px
        'left': '20px'						// default 170px
    });

    function handleMessage(m){
        let temp = msgpack.decode(new Uint8Array(m.data));
        let data;
        if(temp.length > 1) {
            data = [temp[0], ...temp[1]];
            if (data[1] instanceof Array){
                data = data;
            }
        } else {
            data = temp;
        }
        let item = data[0];
        if(!data) {return};
        if(item == '6'){
            let e = data[1];
            for (var t = 0; t < e.length; t += 8) addItem(e[t], e[t + 1], e[t + 2], e[t + 3], e[t + 4], e[t + 5]);
        };
    }


    $('#gameUI').append('<div id="minimap" class=" " ' +
                        'style="' +
                        'position: absolute;' +
                        'bottom: ' + conf.map.bottom + 'px;' +
                        'left: ' + conf.map.left + 'px;' +
                        'display: inline-block;' +
                        'width: ' + conf.map.w + 'px;' +
                        'height: ' + conf.map.h + 'px;' +
                        '"></div>');

    function addItem(sid, x, y, dir, scale, type, item, owner) {
        if (!$('#minimap').length || type === null || $('#resource' + sid).length) return true;

        var name = '';
        var color = '';
        var tx = x * 100 / conf.scale;
        var ty = y * 100 / conf.scale;
        var w;
        var h;

        switch (type) {
            default:
                return;
            case 0:
                name = 'wood';
                color = conf.resource.wood.color;
                w = conf.resource.wood.w;
                h = conf.resource.wood.h;
                break;
            case 1:
                name = 'food';
                color = conf.resource.food.color;
                w = conf.resource.food.w;
                h = conf.resource.food.h;
                break;
            case 2:
                name = 'stone';
                color = conf.resource.stone.color;
                w = conf.resource.stone.w;
                h = conf.resource.stone.h;
                break;
            case 3:
                name = 'points';
                color = conf.resource.points.color;
                w = conf.resource.points.w;
                h = conf.resource.points.h;
                break;
        }
        $('#minimap').append('<div id="resource' + sid + '" style="' +
                             'display: block;' +
                             'width: ' + w + 'px;' +
                             'height: ' + h + 'px;' +
                             'background:' + color + ';' +
                             'left:' + tx + '%;' +
                             'top:' + ty + '%;' +
                             'position: absolute;' +
                             'border-radius: 9999px;' +
                             '"></div>');
    }

    document.addEventListener('keydown', function (e) {
        if (e.keyCode == 77) {
            $('#minimap').toggle();
        }
    });
})();

QingJ © 2025

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