Chat Message Scraper

Scrape chat messages in GoBattle's chats through DevTools' Console. | Join us! - https://discord.gg/3xDbJ8QD8f

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

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

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         Chat Message Scraper
// @namespace    http://tampermonkey.net/
// @version      2025-11-17
// @description  Scrape chat messages in GoBattle's chats through DevTools' Console. | Join us! - https://discord.gg/3xDbJ8QD8f
// @author       GoBattle Hacks Official
// @match        *://gobattle.io/*
// @match        *://*.gobattle.io/*
// @grant        none
// @license      MIT
// ==/UserScript==

const nativeWebSocket = window.WebSocket;
window.WebSocket = function(...args){
    const socket = new nativeWebSocket(args[0], args[1]);

    socket.addEventListener("open", (event) => {
        console.log("connected CACA!!!!");
    });

    socket.addEventListener("message", (event) => {
        if (!event.data instanceof ArrayBuffer){
            return;
        }

        const view = new DataView(event.data);

        let cursor = 0;

        while (cursor < view.byteLength){
            const message_size = view.getUint8(cursor);
            cursor ++;

            const unknown = view.getUint8(cursor);
            cursor ++;

            const opcode = view.getUint8(cursor);
            cursor ++;

            switch (opcode){
                case 0x01:
                    cursor++;
                    break;
                case 0x06: // Message chat
                    const flags = view.getUint8(3 + cursor);
                    cursor += 4;
                    const sub_op = view.getUint8(cursor);
                    cursor += 1;
                    //console.log("m", flags, sub_op);
                    //console.log(Array.from(new Uint8Array(event.data)));
                    const id_entity = view.getUint32(cursor);
                    cursor += 5;
                    if (sub_op == 0x01){ // Message chat simple
                        const zero = view.getUint8(cursor);
                        cursor ++;
                        const nike_size = view.getUint8(cursor);
                        //console.log(zero, nike_size);
                        cursor ++;
                        const nike = new TextDecoder().decode(event.data.slice(cursor, nike_size + cursor));
                        cursor += nike_size;
                        const content_message_size = view.getUint8(cursor);
                        cursor += 2;
                        const content_message = new TextDecoder().decode(event.data.slice(cursor, content_message_size + cursor));

                        let transmitter = "UNKNOWN";
                        /*if (id_entity != 0){
                             transmitter = "PLAYER";
                        }else if (id_entity == 0){
                             transmitter = "NPC";
                        }else if (id_entity == 128){
                             transmitter = "SERVER";
                        }else{
                             transmitter = `UNKNOWN (${flags})`;
                        }*/
                        console.log(`${transmitter}#${id_entity} -> [${nike}]: ${content_message}`);
                    }else{
                        //console.log(String.fromCharCode.apply(null, new Uint8Array(event.data)));
                    }

                    break;
                case 0x80:
                    cursor++;
                    break;
                case 0xc8:
                    cursor++;
                    break;
                default:
                    cursor++;
            }

            cursor += message_size;
            break;
        }
    });
    return socket;
};