🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Greasy Fork is available in English.

📂 缓存分发状态(共享加速已生效)
🕒 页面同步时间:2026/01/26 03:09:32
🔄 下次更新时间:2026/01/26 04:09:32
手动刷新缓存

MyBot Compiler

MyBot Pixel Place Compile Client

Tento skript by neměl být instalován přímo. Jedná se o knihovnu, kterou by měly jiné skripty využívat pomocí meta příkazu // @require https://update.greasyfork.org/scripts/479131/1275798/MyBot%20Compiler.js

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name         MyBot Compiler
// @description  MyBot Pixel Place Compile Client
// @version      1.6.2
// @author       SamaelWired
// @namespace    https://greasyfork.org/tr/users/976572
// @match        https://pixelplace.io/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=pixelplace.io
// @license      MIT
// @grant        none
// @run-at       document-start
// ==/UserScript==
(() => {
    const MyBot = window.MyBot || {modules: {}};
    window.MyBot = MyBot;
    if ('Compiler' in MyBot.modules) return;

    const module = {};
    module.args = {};
    module.intervals = [];
    module.main = null;

    module.config = ({timer, packetSpeed, packetCount}) => {
        if (module.main) {
            module.args.timer.clearInterval(module.main[0]);
            module.main = [
                timer.setInterval(module.main[1]),
                module.main[1]
            ];
        }

        if (module.intervals.length) {
            module.intervals = module.intervals.map(([id, func, ws]) => {
                module.args.timer.clearInterval(id);
                ws._inter = timer.setInterval(func, packetCount > 0 ? 0 : 1e3/packetSpeed);
                return [ws._inter, func, ws];
            });
        }

        Object.assign(module.args, {timer, packetSpeed, packetCount});
    };

    module.compile = () => {
        const {timer, packetCount, packetSpeed} = module.args;
        
        Object.assign(MyBot, {
            ws: null,
            map: {},
            onclick: null,
            queueId: 0,
            queue: [],
            pos: 0,
            lock: false,
            last: [0, 0, 255],
            set(x, y, p) {
                MyBot.queue.push([x, y, p, MyBot.queueId++]);
            },
            _id: 0,
            _posSocket: 0,
            sockets: [],
            getSocket() {
                let i = 0;
                let ws = null;
                
                while (i++ < MyBot.sockets.length) {
                    const _ws = MyBot.sockets[MyBot._posSocket++];
                    if (MyBot._posSocket > MyBot.sockets.length-1) MyBot._posSocket = 0;
                    if (!_ws) continue;
                    if (_ws.ignore) continue;
                    
                    if (MyBot.config.packetCount > 0) {
                        if (_ws.count > 0) _ws.count--;
                        else continue;
                    } else if (!_ws.can || !_ws.ready) continue;

                    ws = _ws;
                    break;
                }
                
                return ws;
            }
        });

        let progress = false;
        const mainFunc = () => {
            if (progress) return;
            progress = true;
            
            while (MyBot.pos < MyBot.queue.length) {
                const [x, y, p, i] = MyBot.queue[MyBot.pos++];
                if (p === 255 || MyBot.map.get(x, y) === 255) {
                    MyBot.queue.splice(--MyBot.pos, 1);
                    continue;
                }
                if (MyBot.map.get(x, y) === p) continue;
                
                const ws = MyBot.getSocket();
                if (!ws) {
                    MyBot.pos--;
                    progress = false;
                    return;
                }
                
                ws.can = false;
                MyBot.CWSS.send.call(ws, `42["p",[${x},${y},${p},${1+MyBot.pos}]]`);
                continue;
            }
            
            if (MyBot.lock && MyBot.pos > MyBot.queue.length-1) {
                MyBot.pos = 0;
                progress = false;
                return;
            }
            
            MyBot.pos = 0;
            MyBot.queue = [];
            MyBot.queueId = 0;
            progress = false;
        };
        module.main = [timer.setInterval(mainFunc), mainFunc];

        MyBot.modules.MapLoader.subscribe((module, map) => {
            Object.assign(MyBot.map, map);
            MyBot.map.pixels = new Uint8Array(map.pixels);
            MyBot.serverId = map.serverId;
        });

        module.hook = {
            priority: 0,
            open() {
                if (!this.username) {
                    MyBot.ws = this;
                    this.addEventListener('close', e=>{
                        MyBot.ws = null;
                    });
                }

                MyBot.sockets.push(this);
                this.id = MyBot._id++;
                const func = () => this.can = true;

                this.addEventListener('close', () => {
                    const el = module.intervals.find(([id, f, ws]) => f == func);
                    module.intervals.splice(module.intervals.indexOf(el), 1);
                    module.args.timer.clearInterval(this._inter);
                    MyBot.sockets.splice(MyBot.sockets.indexOf(this),1);
                });
                
                this.can = true;
                this._inter = module.args.timer.setInterval(func, packetCount > 0 ? 0 : 1e3/packetSpeed);
                module.intervals.push([this._inter, func, this]);
                
                return arguments;
            },

            message({data}) {
                if (MyBot.ws != this) return arguments;

                const message = JSON.parse(data.split(/(?<=^\d+)(?=[^\d])/)[1] || '[]');
                if (!message.length) return arguments;

                const [event, json] = message;
                if (event == 'canvas') {
                    json.map(p => MyBot.map.set(...p));
                    MyBot.ws.ready = true;
                }
                if (event == 'p') {
                    json.map(p => MyBot.map.set(...p));
                    this.count = MyBot.config.packetCount;
                }

                return arguments;
            },

            send(data) {
                if (MyBot.ws != this) return arguments;

                const message = JSON.parse(data.split(/(?<=^\d+)(?=[^\d])/)[1] || '[]');
                if (!message.length) return arguments;

                const [event, json] = message;
                if (event == 'p') {
                    const [x, y, pixel] = json;
                    MyBot.last = [x, y, pixel];
                    if (MyBot.onclick && MyBot.onclick(x, y, pixel) === false) return;
                }

                return arguments;
            }
        };
        MyBot.CWSS.setHook(module.hook);
    };

    MyBot.modules.Compiler = module;
})();