A L Z E~WHOWHERE Gartic.io

Odalardaki kullanıcıları gösterir (AZE)

// ==UserScript==
// @name         A L Z E~WHOWHERE Gartic.io
// @description  Odalardaki kullanıcıları gösterir (AZE)
// @namespace    http://tampermonkey.net/
// @version      1.1
// @author       A L Z E
// @match        *://gartic.io/*
// @license      MIT
// @icon         https://www.google.com/s2/favicons?sz=64&domain=gartic.io
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    window.addEventListener('load', function() {
        const panel = document.createElement('div');
        panel.style.position = 'fixed';
        panel.style.top = '10px';
        panel.style.right = '10px';
        panel.style.width = '400px';
        panel.style.height = 'auto';
        panel.style.backgroundColor = 'gris';
        panel.style.color = 'black';
        panel.style.padding = '15px';
        panel.style.borderRadius = '8px';
        panel.style.zIndex = '9999';
        panel.style.maxHeight = '80vh';
        panel.style.overflowY = 'auto';
        panel.style.transition = 'all 0.3s ease-in-out';

        if(localStorage.getItem('panelOpen') === 'true') {
            panel.style.display = 'block';
        } else {
            panel.style.display = 'none';
            }

        const toggleButton = document.createElement('button');
        toggleButton.innerText = '▶';
        toggleButton.style.backgroundColor = 'transparent';
        toggleButton.style.border = 'none';
        toggleButton.style.color = 'white';
        toggleButton.style.fontSize = '20px';
        toggleButton.style.cursor = 'pointer';
        toggleButton.style.position = 'absolute';
        toggleButton.style.top = '10px';
        toggleButton.style.right = '10px';
        toggleButton.style.zIndex = '10000';

        toggleButton.onclick = () => {
            if (panel.style.display === 'none') {
                panel.style.display = 'block';
                toggleButton.innerText = '▶';

                localStorage.setItem('panelOpen', 'true');
            } else {
                panel.style.display = 'none';
                toggleButton.innerText = '◀';

                localStorage.setItem('panelOpen', 'false');
            }
        };

        document.body.appendChild(toggleButton);
        document.body.appendChild(panel);

        const style = document.createElement('style');
        style.textContent = `
            @keyframes rgb-glow {
                0% { box-shadow: 0 0 25px 10px blue; }
                33% { box-shadow: 0 0 25px 10px red; }
                66% { box-shadow: 0 0 25px 10px green; }
                100% { box-shadow: 0 0 25px 10px blue; }
            }
            .rgb-led-effect {
                animation: rgb-glow 2s infinite;
            }
            @media (max-width: 768px) {
                .responsive-panel {
                    width: 90%;
                    right: 5%;
                    padding: 10px;
                }
                .responsive-title {
                    font-size: 20px;
                }
            }

            .responsive-panel {
                width: 90%;
                right: 5%;
                padding: 10px;
            }

            ::-webkit-scrollbar {
                width: 10px;
            }
            ::-webkit-scrollbar-track {
                background: #gris;
                }

            ::-webkit-scrollbar-thumb {
                background: #888;
                border-radius: 10px;
            }
            ::-webkit-scrollbar-thumb:hover {
                background: #555;
            }
        `;
        document.head.appendChild(style);

        panel.classList.add('rgb-led-effect', 'responsive-panel');
        document.body.appendChild(panel);

        const alzeTitle = document.createElement('h2');
        alzeTitle.innerText = '🅰 🅻 🆉 🅴';
        alzeTitle.style.textAlign = 'center';
        alzeTitle.style.marginBottom = '10px';
        alzeTitle.style.color = 'white';
        alzeTitle.classList.add('wihite');
        panel.appendChild(alzeTitle);

        const title = document.createElement('div');
        title.innerText = 'Çevrimiçi Kullanıcılar';
        title.style.textAlign = 'center';
        title.style.color = 'white';
        panel.appendChild(title);

        const totalCountDisplay = document.createElement('div');
        totalCountDisplay.style.marginTop = '10px';
        panel.appendChild(totalCountDisplay);

        const fl = document.createElement('div');
        fl.style.display = 'flex';
        fl.style.flexDirection = 'column';
        fl.style.gap = '10px';
        panel.appendChild(fl);

        let roomIds = [];

        function f(lang) {
            fetch('https://gartic.io/req/list?search=&language[]=' + lang)
                .then(res => res.json())
                .then(data => {
                    const active = data.filter(room => room.quant > 0);
                    if (active.length !== 0) {
                        fl.innerHTML = '';
                        for (let k = 0; k < active.length; k++) {
                            roomIds.push(active[k].id);

                            const flc = document.createElement('div');
                            flc.style.backgroundColor = 'gris';
                            flc.style.padding = '10px';
                            flc.style.borderRadius = '8px';
                            flc.style.border = '1px solid #666';
                            fl.appendChild(flc);

                            const roomTag = document.createElement('div');
                            roomTag.style.color = 'white';
                            roomTag.style.fontSize = '18px';
                            const roomSubjIcon = document.createElement('img');
                            roomSubjIcon.style.width = '50px';
                            roomSubjIcon.style.height = '50px';
                            const inRoomPlayers = document.createElement('p');
                            const users = document.createElement('div');
                            const viewBtn = document.createElement('button');
                            const joinBtn = document.createElement('button');

                            users.style.backgroundColor = 'gris';
                            users.style.color = 'white';
                            users.style.padding = '10px';
                            users.style.borderRadius = '8px';
                            users.style.marginTop = '10px';

                            users.classList.add('users');

                            roomTag.innerHTML = active[k].id.slice(1);
                            roomSubjIcon.src = `https://gartic.io/static/images/subjects/${active[k].subject}.svg`;
                            inRoomPlayers.innerHTML = `${active[k].quant} / ${active[k].max} ・ ${active[k].points} / ${active[k].goal}`;
                            inRoomPlayers.style.color = 'white';
                            viewBtn.innerHTML = 'Otağı izlə';
                            viewBtn.style.backgroundColor = 'blue';
                            viewBtn.style.color = 'white';
                            viewBtn.style.border = 'none';
                            viewBtn.style.padding = '8px 15px';
                            viewBtn.style.borderRadius = '8px';
                            viewBtn.style.cursor = 'pointer';
                            viewBtn.onclick = () => window.open(`https://gartic.io/${active[k].code}/viewer`, '_blank');

                            joinBtn.innerHTML = 'Otağa daxil ol';
                            joinBtn.style.backgroundColor = 'red';
                            joinBtn.style.color = 'white';
                            joinBtn.style.border = 'none';
                            joinBtn.style.padding = '8px 15px';
                            joinBtn.style.borderRadius = '8px';
                            joinBtn.style.cursor = 'pointer';
                            joinBtn.onclick = () => window.open(`https://gartic.io/${active[k].code}`, '_blank');

                            fetch(`https://gartic.io/serverViewer?room=${active[k].code}`).then(rs => rs.text()).then(dt => {
                                const s = dt.slice(15, 16);
                                const ws = new WebSocket(`wss://server0${s}.gartic.io/socket.io/?EIO=3&transport=websocket`);

                                ws.onopen = () => {
                                    ws.send(`42["12",{"v":20000,"sala":"${roomIds[k]}"}]`);
                                };

                                ws.onmessage = (m) => {
                                    try {
                                        const d = JSON.parse(m.data.slice(2));
                                        if (d[0] == 5) {
                                            users.innerHTML = '';
                                            for (let i = 0; i < d[5].length; i++) {
                                                const userB = document.createElement('div');
                                                userB.classList.add('user-info');
                                                users.appendChild(userB);

                                                const userPp = document.createElement('img');
                                                const userName = document.createElement('p');

                                                userPp.src = d[5][i].foto ? d[5][i].foto : 'https://gartic.io/static/images/avatar/svg/0.svg';
                                                userPp.style.width = '40px';
                                                userPp.style.height = '40px';
                                                userPp.style.borderRadius = '50%';

                                                userName.innerHTML = d[5][i].nick;
                                                userName.style.color = 'white';

                                                userB.append(userPp, userName);
                                            }
                                        }
                                    } catch (err) {
                                        console.error("Kullanıcılar alınırken hata oluştu: ", err);
                                    }
                                };
                            });

                            flc.append(roomTag, roomSubjIcon, inRoomPlayers, users, viewBtn, joinBtn);
                        }

                        totalCountDisplay.textContent = `Toplam Oda: ${active.length}, Toplam Kullanıcı: ${active.reduce((acc, curr) => acc + curr.quant, 0)}`;
                        panel.style.display = 'block';
                        totalCountDisplay.style.color = 'white';
                    } else {
                        fl.innerHTML = '<h4>Seçilən dildə oda yok.</h4>';
                        totalCountDisplay.textContent = 'white';
                    }
                });
        }

        f('23');
    });
})();