AnyChars Multi-Account Manager

Менеджер аккаунтов AnyChars — эмуляция ручного ввода

Vous devrez installer une extension telle que Tampermonkey, Greasemonkey ou Violentmonkey pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey ou Violentmonkey pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey ou Userscripts pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey pour installer ce script.

Vous devrez installer une extension de gestionnaire de script utilisateur pour installer ce script.

(J'ai déjà un gestionnaire de scripts utilisateur, laissez-moi l'installer !)

Vous devrez installer une extension telle que Stylus pour installer ce style.

Vous devrez installer une extension telle que Stylus pour installer ce style.

Vous devrez installer une extension telle que Stylus pour installer ce style.

Vous devrez installer une extension du gestionnaire de style pour utilisateur pour installer ce style.

Vous devrez installer une extension du gestionnaire de style pour utilisateur pour installer ce style.

Vous devrez installer une extension du gestionnaire de style pour utilisateur pour installer ce style.

(J'ai déjà un gestionnaire de style utilisateur, laissez-moi l'installer!)

// ==UserScript==
// @name         AnyChars Multi-Account Manager
// @namespace    http://tampermonkey.net/
// @version      3.0
// @description  Менеджер аккаунтов AnyChars — эмуляция ручного ввода
// @author       Shellk0v
// @match        https://app.anychars18.ru/*
// @match        https://app.anychars.fun/*
// @grant        GM_xmlhttpRequest
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_addStyle
// @grant        unsafeWindow
// @run-at       document-end
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // ================== СТИЛИ ==================
    GM_addStyle(`
        #shellk0v-panel {
            position: fixed;
            top: 10px;
            right: 10px;
            z-index: 99999;
            background: #1a1a2e;
            border: 1px solid #2a2a3e;
            border-radius: 16px;
            padding: 16px;
            min-width: 280px;
            max-width: 380px;
            font-family: 'Segoe UI', sans-serif;
            font-size: 13px;
            color: #f1f1f1;
            box-shadow: 0 10px 40px rgba(0,0,0,0.5);
        }
        #shellk0v-panel .shellk0v-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 12px;
        }
        #shellk0v-panel .shellk0v-title {
            font-weight: 700;
            font-size: 14px;
            background: linear-gradient(135deg, #a78bfa, #7c3aed);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }
        #shellk0v-panel .shellk0v-account {
            background: #12121a;
            border: 1px solid #2a2a3e;
            border-radius: 10px;
            padding: 10px;
            margin-bottom: 8px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            transition: border-color 0.2s;
        }
        #shellk0v-panel .shellk0v-account:hover {
            border-color: #7c3aed;
        }
        #shellk0v-panel .shellk0v-account-name {
            font-weight: 600;
            font-size: 13px;
        }
        #shellk0v-panel .shellk0v-account-tokens {
            font-size: 11px;
            color: #9ca3af;
        }
        #shellk0v-panel .shellk0v-account-actions {
            display: flex;
            gap: 4px;
        }
        #shellk0v-panel .shellk0v-btn {
            padding: 5px 10px;
            border-radius: 6px;
            border: 1px solid #2a2a3e;
            background: #16162a;
            color: #9ca3af;
            cursor: pointer;
            font-size: 11px;
            transition: all 0.2s;
        }
        #shellk0v-panel .shellk0v-btn:hover {
            background: #7c3aed;
            color: white;
        }
        #shellk0v-panel .shellk0v-btn.danger:hover {
            background: #ef4444;
        }
        #shellk0v-panel .shellk0v-btn.success {
            background: #10b981;
            color: white;
            border-color: #10b981;
        }
        #shellk0v-panel .shellk0v-add-form {
            display: flex;
            gap: 6px;
            margin-top: 10px;
        }
        #shellk0v-panel .shellk0v-input {
            flex: 1;
            padding: 6px 10px;
            background: #16162a;
            border: 1px solid #2a2a3e;
            border-radius: 6px;
            color: #f1f1f1;
            font-size: 12px;
        }
        #shellk0v-panel .shellk0v-input:focus {
            outline: none;
            border-color: #7c3aed;
        }
        #shellk0v-panel .shellk0v-status {
            font-size: 11px;
            color: #10b981;
            text-align: center;
            margin-top: 8px;
        }
    `);

    // ================== ХРАНИЛИЩЕ ==================
    let accounts = GM_getValue('anychars_accounts', []);

    function saveAccounts() {
        GM_setValue('anychars_accounts', accounts);
    }

    // ================== ПОЛУЧЕНИЕ JWT ==================
    function getJWT(authToken, callback) {
        GM_xmlhttpRequest({
            method: 'POST',
            url: 'https://api.anychars.fun/initialData/login',
            headers: {
                'Content-Type': 'application/json',
                'Origin': 'https://app.anychars18.ru',
                'Referer': 'https://app.anychars18.ru/'
            },
            data: JSON.stringify({ authToken: authToken, jwtToken: 'null' }),
            onload: function(resp) {
                try {
                    const data = JSON.parse(resp.responseText);
                    if (data.ok && data.jwtToken) {
                        callback(null, data.jwtToken);
                    } else {
                        callback(data.message || 'Неверный токен');
                    }
                } catch(e) {
                    callback('Ошибка парсинга');
                }
            },
            onerror: function() {
                callback('Ошибка сети');
            }
        });
    }

    // ================== ВХОД (ЭМУЛЯЦИЯ РУЧНОГО ВВОДА) ==================
    function loginToAccount(authToken) {
        const status = document.getElementById('shellk0v-status');
        status.textContent = '⏳ Получаю JWT...';

        getJWT(authToken, function(err, jwt) {
            if (err) {
                status.textContent = '❌ ' + err;
                return;
            }

            // Формируем ТОЧНО такой же код, как при ручном вводе
            const code = `
                localStorage.setItem("authToken", "${authToken.replace(/"/g, '\\"')}");
                localStorage.setItem("jwtToken", "${jwt.replace(/"/g, '\\"')}");
                localStorage.setItem("version", "1.8.1");
                location.reload();
            `;

            // Выполняем через script-тег (как будто вручную в консоли)
            const script = document.createElement('script');
            script.textContent = code;
            document.body.appendChild(script);
            script.remove();

            status.textContent = '✅ Команда выполнена!';
        });
    }

    // ================== ИНТЕРФЕЙС ==================
    function renderAccounts() {
        const container = document.getElementById('shellk0v-accounts');
        if (!container) return;

        if (accounts.length === 0) {
            container.innerHTML = '<div style="color:#6b7280;font-size:12px;text-align:center;padding:10px;">Нет аккаунтов. Добавь токен ниже.</div>';
            return;
        }

        container.innerHTML = accounts.map(function(acc, i) {
            return `
                <div class="shellk0v-account">
                    <div>
                        <div class="shellk0v-account-name">${acc.name || 'Аккаунт ' + (i+1)}</div>
                        <div class="shellk0v-account-tokens">🔑 ${acc.tokenPreview || acc.authToken.substring(0, 15) + '...'}</div>
                    </div>
                    <div class="shellk0v-account-actions">
                        <button class="shellk0v-btn success" data-action="login" data-index="${i}">🔑 Войти</button>
                        <button class="shellk0v-btn danger" data-action="remove" data-index="${i}">✕</button>
                    </div>
                </div>
            `;
        }).join('');

        container.querySelectorAll('[data-action="login"]').forEach(function(btn) {
            btn.addEventListener('click', function(e) {
                e.stopPropagation();
                const index = parseInt(this.getAttribute('data-index'));
                loginToAccount(accounts[index].authToken);
            });
        });

        container.querySelectorAll('[data-action="remove"]').forEach(function(btn) {
            btn.addEventListener('click', function(e) {
                e.stopPropagation();
                const index = parseInt(this.getAttribute('data-index'));
                if (confirm('Удалить ' + (accounts[index].name || 'аккаунт') + '?')) {
                    accounts.splice(index, 1);
                    saveAccounts();
                    renderAccounts();
                }
            });
        });
    }

    function addAccount() {
        const input = document.getElementById('shellk0v-new-token');
        const token = input.value.trim();

        if (!token) {
            document.getElementById('shellk0v-status').textContent = '❌ Введи токен!';
            return;
        }

        const name = prompt('Имя для аккаунта (можно пропустить):', '') || ('Аккаунт ' + (accounts.length + 1));

        accounts.push({
            name: name,
            authToken: token,
            tokenPreview: token.substring(0, 15) + '...'
        });

        saveAccounts();
        input.value = '';
        document.getElementById('shellk0v-status').textContent = '✅ Добавлен: ' + name;
        renderAccounts();
    }

    function createPanel() {
        const panel = document.createElement('div');
        panel.id = 'shellk0v-panel';

        panel.innerHTML = `
            <div class="shellk0v-header">
                <span class="shellk0v-title">✦ AnyChars Manager</span>
            </div>
            <div id="shellk0v-accounts"></div>
            <div class="shellk0v-add-form">
                <input class="shellk0v-input" id="shellk0v-new-token" placeholder="Auth Token">
                <button class="shellk0v-btn success" id="shellk0v-add-btn">+</button>
            </div>
            <div class="shellk0v-status" id="shellk0v-status">Готов к работе</div>
        `;

        document.body.appendChild(panel);

        document.getElementById('shellk0v-add-btn').addEventListener('click', addAccount);
        document.getElementById('shellk0v-new-token').addEventListener('keydown', function(e) {
            if (e.key === 'Enter') addAccount();
        });

        renderAccounts();
    }

    // ================== ЗАПУСК ==================
    console.log('✅ AnyChars Manager by Shellk0v v3.0 загружен!');
    createPanel();

})();