Gartic chat - FIXED

tr: gartic chat alanını geri getirir / büyük chat | en: brings back gartic chat area / bigger chat

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Gartic chat - FIXED
// @description:tr gartic chat alanını geri getirir / büyük chat
// @description:en brings back gartic chat area / big chat
// @author       Enes Yıldız
// @icon         https://i.ibb.co/s9Qv6JNW/107653-thumb.jpg
// @match        https://gartic.io/*
// @run-at       document-start
// @grant        unsafeWindow
// @grant        GM_addStyle
// @version     0.2
// @namespace https://greasyfork.org/users/1424758
// @description tr: gartic chat alanını geri getirir / büyük chat | en: brings back gartic chat area / bigger chat
// ==/UserScript==

(function() {
    'use strict';
    const window = typeof unsafeWindow !== 'undefined' ? unsafeWindow : window;
    window.kullanicilar = {}; window.mesajlar = []; window.ben = null; window.socket = null; window.id = null;

    GM_addStyle(`.aktif #canvas, .aktif #answer, .aktif .bar { display: none !important; } .aktif .ctt { display: flex !important; } .aktif #interaction { flex: 1 !important; margin: 0 !important; } .sohbet { padding: 5px 10px; } #chat .history .scrollElements > div.msg:not(.you):not(.system):not(.alert) { display: none !important; } .buton { background: #ffcc00; color: #001b4d; border-radius: 4px; padding: 2px 8px; font-size: 11px; cursor: pointer; margin-left: 10px; font-family: 'NunitoBlack'; text-transform: uppercase; display: inline-block; border: 1px solid #000; } .mesaj.you span { color: #4B0082 !important; } .mesaj.you strong { color: #FF0000 !important; }`);

    function print(user, text, my) {
        const hedef = document.querySelector('#chat .history .scrollElements'); if (!hedef) return;
        const satir = document.createElement('div'); satir.className = `msg mesaj ${my ? 'you' : ''}`;
        const image = user.foto ? `<div class="avatar" style="background-image: url('${user.foto}')"></div>` : `<div class="avatar"><div class="av avt${user.avatar}"></div></div>`;
        satir.innerHTML = `${image}<div><strong>${user.nick} </strong><span>${text}</span></div>`;
        hedef.appendChild(satir); satir.scrollIntoView({ block: "end" }); }

    const bridge = window.WebSocket;
    window.WebSocket = function(...args) {
        const socket = new bridge(...args); window.socket = socket;
        socket.addEventListener('message', (event) => {
            if (!event.data.startsWith('42[')) return;
            const paket = JSON.parse(event.data.slice(2));
            const sync = (user) => window.kullanicilar[user.id] = { nick: user.nick, avatar: user.avatar, foto: user.foto };

            if (paket[0] == 5) { window.ben = paket[1]; window.id = paket[2]; paket[5].forEach(sync); }
            if (paket[0] == 23) sync(paket[1]);
            
            if (paket[0] == 11) {
                const user = window.kullanicilar[paket[1]] || { nick: paket[1], avatar: 0, foto: null };
                window.mesajlar.push(`${user.nick} ${paket[2]}`); 
                print(user, paket[2], paket[1].toString() === window.ben?.toString()); } });
        return socket; };
    window.WebSocket.prototype = bridge.prototype;

    setInterval(() => {
        const chat = document.querySelector('#chat');
        if (chat && !document.querySelector('.sohbet')) {
            const sohbet = document.createElement('form'); sohbet.className = 'sohbet';
            sohbet.innerHTML = `<div class="textGame"><input type="text" class="mousetrap" placeholder="text"><span></span></div>`;
            sohbet.onsubmit = (event) => { event.preventDefault(); const input = sohbet.querySelector('input');
                if (input.value.trim() && window.socket && window.id) {
                    window.socket.send(`42["11","${window.id}","${input.value}"]`); input.value = ''; } };
            chat.appendChild(sohbet); }
        const head = document.querySelector('#chat h5');
        if (head && !document.querySelector('.buton')) {
            const buton = document.createElement('div'); buton.className = 'buton';
            buton.innerText = document.body.classList.contains('aktif') ? 'DOWN' : 'UP';
            buton.onclick = () => buton.innerText = document.body.classList.toggle('aktif') ? 'DOWN' : 'UP';
            head.appendChild(buton); } }, 1000);
})();