Gartic chat - FIXED

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

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==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);
})();