RAGE SCRIPT | TEST

Скрипт для КА ЕКБ

Tendrás que instalar una extensión para tu navegador como Tampermonkey, Greasemonkey o Violentmonkey si quieres utilizar este script.

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

Tendrás que instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Userscripts para instalar este script.

Tendrás que instalar una extensión como Tampermonkey antes de poder instalar este script.

Necesitarás instalar una extensión para administrar scripts de usuario si quieres instalar este script.

(Ya tengo un administrador de scripts de usuario, déjame instalarlo)

Advertisement:

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

(Ya tengo un administrador de estilos de usuario, déjame instalarlo)

Advertisement:

// ==UserScript==
// @name         RAGE SCRIPT | TEST
// @namespace    http://tampermonkey.net/
// @version      12
// @description  Скрипт для КА ЕКБ
// @author       Flora
// @match        https://forum.ragerussia.online/*
// @include      https://forum.ragerussia.online/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=ragerussia.online
// @grant        none
// @license      none
// ==/UserScript==

(async function () {
    `use strict`;
    const UNACCEPT_PREFIX = 3;
    const ACCEPT_PREFIX = 2;
    const CLOSED_PREFIX = 4;
    const PIN_PREFIX = 10;

    
    const STORAGE_KEY = 'forum_script_custom_templates';
    const SCRIPTSETTINGS_KEY = 'forum_script_settings';
    const QUICKREPLY_KEY = 'forum_script_quick_replies';
    const STATS_KEY = 'forum_script_stats';
    const FAVORITES_KEY = 'forum_script_favorites';
    const BANLIST_KEY = 'forum_script_banlist';
    const MACROS_KEY = 'forum_script_macros';
    const TASKS_KEY = 'forum_script_tasks';
    const TEMPLATES_HISTORY_KEY = 'forum_script_history';
    const USER_VARIABLES_KEY = 'forum_script_user_vars';

   
    let userVariables = {
        warnCount: 0,
        banCount: 0,
        lastAction: '',
        adminName: '',
        serverName: 'Екатеринбург'
    };

    function loadUserVariables() {
        const saved = localStorage.getItem(USER_VARIABLES_KEY);
        if (saved) {
            try {
                userVariables = { ...userVariables, ...JSON.parse(saved) };
            } catch(e) {}
        }
    }

    function saveUserVariables() {
        localStorage.setItem(USER_VARIABLES_KEY, JSON.stringify(userVariables));
    }

    function updateUserVariable(key, value) {
        userVariables[key] = value;
        saveUserVariables();
        showNotification(`📝 Переменная ${key} обновлена: ${value}`, 'success');
    }

   
    const COLOR_PALETTE = {
        dark: ['#1a1a2e', '#0f0f1a', '#1a1a1a', '#0a0a2a', '#1a0a2a', '#0a2a1a', '#2a1a0a', '#1a2a3a'],
        light: ['#f5f5f5', '#ffffff', '#f0f0f0', '#e8e8e8', '#fafafa', '#f8f9fa', '#e9ecef', '#dee2e6'],
        accent: ['#9b59b6', '#e74c3c', '#f39c12', '#2ecc71', '#3498db', '#1abc9c', '#e67e22', '#ff69b4', '#00ff00', '#ff00ff', '#00ffff', '#ffff00', '#ff6600', '#0066ff', '#ff0066', '#66ff00', '#ff3300', '#33ff00', '#0033ff', '#ff0033'],
        pastel: ['#FFB3BA', '#C5E99B', '#B5EAD7', '#A0E7E5', '#FFC8DD', '#FFD6A5', '#FDFFB6', '#CAFFBF', '#9BF6FF', '#FBC4C4', '#C4E0FA', '#E0BBE4', '#FADADD', '#D4F1F9', '#FFE5B4', '#B0E57C'],
        gradient: ['linear-gradient(135deg, #667eea 0%, #764ba2 100%)', 'linear-gradient(135deg, #f093fb 0%, #f5576c 100%)', 'linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)', 'linear-gradient(135deg, #43e97b 0%, #38f9d7 100%)', 'linear-gradient(135deg, #fa709a 0%, #fee140 100%)', 'linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%)']
    };

    
       const PRESET_THEMES = {
        // Основные (10)
        dark: { name: '🌙 Тёмная', mainBg: 'linear-gradient(135deg, #1a1a2e, #16213e)', cardBg: '#0f0f1a', textColor: '#ecf0f1', accentColor: '#9b59b6', borderColor: 'rgba(155,89,182,0.3)', headerBg: 'linear-gradient(135deg, #9b59b6, #6a3ad5)', deniedColor: '#e74c3c', pendingColor: '#f39c12', approvedColor: '#2ecc71', requestColor: '#3498db', techColor: '#1abc9c' },
        light: { name: '☀️ Светлая', mainBg: 'linear-gradient(135deg, #f5f5f5, #e0e0e0)', cardBg: '#ffffff', textColor: '#333333', accentColor: '#9b59b6', borderColor: 'rgba(155,89,182,0.3)', headerBg: 'linear-gradient(135deg, #9b59b6, #6a3ad5)', deniedColor: '#e74c3c', pendingColor: '#f39c12', approvedColor: '#2ecc71', requestColor: '#3498db', techColor: '#1abc9c' },

       
        cyberpunk: { name: '💜 Киберпанк', mainBg: 'linear-gradient(135deg, #0a0a2a, #1a0033)', cardBg: '#0d0d1a', textColor: '#00ffcc', accentColor: '#ff00ff', borderColor: 'rgba(0,255,204,0.3)', headerBg: 'linear-gradient(135deg, #ff00ff, #00ffcc)', deniedColor: '#ff4444', pendingColor: '#ffaa00', approvedColor: '#00ff88', requestColor: '#00ccff', techColor: '#00ffcc' },
        neon: { name: '💚 Неон', mainBg: 'linear-gradient(135deg, #0a1a0a, #001a00)', cardBg: '#0a1f0a', textColor: '#aaff00', accentColor: '#ccff00', borderColor: 'rgba(204,255,0,0.3)', headerBg: 'linear-gradient(135deg, #ccff00, #88aa00)', deniedColor: '#ff6666', pendingColor: '#ffee66', approvedColor: '#aaff66', requestColor: '#66ffee', techColor: '#ccff00' },
        synthwave: { name: '🎸 Синтвейв', mainBg: 'linear-gradient(135deg, #2b0b3a, #1a0a2e)', cardBg: '#1f0b33', textColor: '#ff71ce', accentColor: '#01cdfe', borderColor: 'rgba(1,205,254,0.3)', headerBg: 'linear-gradient(135deg, #ff71ce, #b967ff)', deniedColor: '#ff4444', pendingColor: '#ffaa00', approvedColor: '#00ff88', requestColor: '#01cdfe', techColor: '#05ffa1' },
        vaporwave: { name: '🌴 Вейпорвейв', mainBg: 'linear-gradient(135deg, #ff6ad5, #c774e8)', cardBg: '#ff85d9', textColor: '#00ffcc', accentColor: '#ff00ff', borderColor: 'rgba(255,0,255,0.3)', headerBg: 'linear-gradient(135deg, #00ffcc, #ff00ff)', deniedColor: '#ff4444', pendingColor: '#ffaa00', approvedColor: '#00ff88', requestColor: '#00ccff', techColor: '#ff00ff' },
        outrun: { name: '🏎️ Аутран', mainBg: 'linear-gradient(135deg, #ff007f, #7000ff)', cardBg: '#ff33aa', textColor: '#00ffff', accentColor: '#ffff00', borderColor: 'rgba(255,255,0,0.3)', headerBg: 'linear-gradient(135deg, #ffff00, #ff00ff)', deniedColor: '#ff0000', pendingColor: '#ffff00', approvedColor: '#00ff00', requestColor: '#00ffff', techColor: '#ff00ff' },

       
        forest: { name: '🌲 Лес', mainBg: 'linear-gradient(135deg, #1a3a1a, #0d260d)', cardBg: '#1a2e1a', textColor: '#aaffaa', accentColor: '#55aa55', borderColor: 'rgba(85,170,85,0.3)', headerBg: 'linear-gradient(135deg, #55aa55, #227722)', deniedColor: '#ff8888', pendingColor: '#ffcc88', approvedColor: '#88ff88', requestColor: '#88aaff', techColor: '#55ff55' },
        ocean: { name: '🌊 Океан', mainBg: 'linear-gradient(135deg, #001a4a, #000d2a)', cardBg: '#001033', textColor: '#88ddff', accentColor: '#3399ff', borderColor: 'rgba(51,153,255,0.3)', headerBg: 'linear-gradient(135deg, #3399ff, #0055cc)', deniedColor: '#ff6666', pendingColor: '#ffcc66', approvedColor: '#66ff66', requestColor: '#66ccff', techColor: '#66ffcc' },
        desert: { name: '🏜️ Пустыня', mainBg: 'linear-gradient(135deg, #c2a56d, #a0844a)', cardBg: '#b8955e', textColor: '#f5e6c8', accentColor: '#e6a017', borderColor: 'rgba(230,160,23,0.3)', headerBg: 'linear-gradient(135deg, #e6a017, #c4861a)', deniedColor: '#ff6666', pendingColor: '#ffcc66', approvedColor: '#88ff88', requestColor: '#88aaff', techColor: '#ffaa00' },
        mountain: { name: '⛰️ Горы', mainBg: 'linear-gradient(135deg, #2c3e50, #1a252f)', cardBg: '#243342', textColor: '#ecf0f1', accentColor: '#3498db', borderColor: 'rgba(52,152,219,0.3)', headerBg: 'linear-gradient(135deg, #3498db, #2980b9)', deniedColor: '#e74c3c', pendingColor: '#f39c12', approvedColor: '#2ecc71', requestColor: '#3498db', techColor: '#1abc9c' },
        jungle: { name: '🌴 Джунгли', mainBg: 'linear-gradient(135deg, #0a3d2a, #052a1a)', cardBg: '#0d3522', textColor: '#ccffaa', accentColor: '#77dd77', borderColor: 'rgba(119,221,119,0.3)', headerBg: 'linear-gradient(135deg, #77dd77, #44aa44)', deniedColor: '#ffaaaa', pendingColor: '#ffddaa', approvedColor: '#aaffaa', requestColor: '#aaccff', techColor: '#77ff77' },
        arctic: { name: '❄️ Арктика', mainBg: 'linear-gradient(135deg, #e0f0ff, #c0e0ff)', cardBg: '#e8f4ff', textColor: '#004466', accentColor: '#00aaff', borderColor: 'rgba(0,170,255,0.3)', headerBg: 'linear-gradient(135deg, #00aaff, #0088cc)', deniedColor: '#ff8888', pendingColor: '#ffcc88', approvedColor: '#88ff88', requestColor: '#88aaff', techColor: '#00ccff' },
        volcanic: { name: '🌋 Вулкан', mainBg: 'linear-gradient(135deg, #4a0a0a, #2a0000)', cardBg: '#4a1515', textColor: '#ffaa88', accentColor: '#ff4400', borderColor: 'rgba(255,68,0,0.3)', headerBg: 'linear-gradient(135deg, #ff4400, #cc2200)', deniedColor: '#ff4444', pendingColor: '#ff8844', approvedColor: '#44ff44', requestColor: '#44aaff', techColor: '#ff6644' },

        
        spring: { name: '🌸 Весна', mainBg: 'linear-gradient(135deg, #ffb7c5, #ff9eb2)', cardBg: '#ffcdd9', textColor: '#5c3a4a', accentColor: '#ff69b4', borderColor: 'rgba(255,105,180,0.3)', headerBg: 'linear-gradient(135deg, #ff69b4, #ff3388)', deniedColor: '#ff8888', pendingColor: '#ffcc88', approvedColor: '#88ff88', requestColor: '#88aaff', techColor: '#ff69b4' },
        summer: { name: '☀️ Лето', mainBg: 'linear-gradient(135deg, #ff7b00, #ff6600)', cardBg: '#ff9933', textColor: '#ffff00', accentColor: '#ffff00', borderColor: 'rgba(255,255,0,0.3)', headerBg: 'linear-gradient(135deg, #ffff00, #ffaa00)', deniedColor: '#ff4444', pendingColor: '#ff8800', approvedColor: '#00ff00', requestColor: '#00ccff', techColor: '#ffff00' },
        autumn: { name: '🍂 Осень', mainBg: 'linear-gradient(135deg, #d46b2e, #b8531a)', cardBg: '#c97840', textColor: '#ffe6b3', accentColor: '#ffaa00', borderColor: 'rgba(255,170,0,0.3)', headerBg: 'linear-gradient(135deg, #ffaa00, #dd8800)', deniedColor: '#ff8888', pendingColor: '#ffcc88', approvedColor: '#88ff88', requestColor: '#88aaff', techColor: '#ffaa00' },
        winter: { name: '❄️ Зима', mainBg: 'linear-gradient(135deg, #a4d3ff, #8bc4ff)', cardBg: '#b8e0ff', textColor: '#0044aa', accentColor: '#0088ff', borderColor: 'rgba(0,136,255,0.3)', headerBg: 'linear-gradient(135deg, #0088ff, #0066cc)', deniedColor: '#ff8888', pendingColor: '#ffcc88', approvedColor: '#88ff88', requestColor: '#88aaff', techColor: '#00aaff' },

      
        coffee: { name: '☕ Кофе', mainBg: 'linear-gradient(135deg, #3a2a1a, #2a1a0a)', cardBg: '#2a1f12', textColor: '#ddbb99', accentColor: '#c97e5a', borderColor: 'rgba(201,126,90,0.3)', headerBg: 'linear-gradient(135deg, #c97e5a, #8b5a2a)', deniedColor: '#ff8888', pendingColor: '#ffcc88', approvedColor: '#88cc88', requestColor: '#88aacc', techColor: '#c97e5a' },
        cherry: { name: '🍒 Вишня', mainBg: 'linear-gradient(135deg, #4a0a1a, #3a0010)', cardBg: '#5a1525', textColor: '#ffccdd', accentColor: '#ff3366', borderColor: 'rgba(255,51,102,0.3)', headerBg: 'linear-gradient(135deg, #ff3366, #cc2255)', deniedColor: '#ff8888', pendingColor: '#ffcc88', approvedColor: '#88ff88', requestColor: '#88aaff', techColor: '#ff3366' },
        mint: { name: '🍃 Мята', mainBg: 'linear-gradient(135deg, #1a4a3a, #0d261d)', cardBg: '#1a3d2a', textColor: '#aaffcc', accentColor: '#33ffaa', borderColor: 'rgba(51,255,170,0.3)', headerBg: 'linear-gradient(135deg, #33ffaa, #22cc88)', deniedColor: '#ff8888', pendingColor: '#ffcc88', approvedColor: '#88ff88', requestColor: '#88aaff', techColor: '#33ffaa' },
        lavender: { name: '🪻 Лаванда', mainBg: 'linear-gradient(135deg, #3a1a4a, #2a0a3a)', cardBg: '#3d1a4a', textColor: '#ddccff', accentColor: '#aa77ff', borderColor: 'rgba(170,119,255,0.3)', headerBg: 'linear-gradient(135deg, #aa77ff, #8844cc)', deniedColor: '#ffaaaa', pendingColor: '#ffddaa', approvedColor: '#aaffaa', requestColor: '#aaccff', techColor: '#aa77ff' },
        chocolate: { name: '🍫 Шоколад', mainBg: 'linear-gradient(135deg, #4a2a1a, #3a1a0a)', cardBg: '#4a2a18', textColor: '#eebb99', accentColor: '#aa6644', borderColor: 'rgba(170,102,68,0.3)', headerBg: 'linear-gradient(135deg, #aa6644, #884422)', deniedColor: '#ffaaaa', pendingColor: '#ffddaa', approvedColor: '#aaffaa', requestColor: '#aaccff', techColor: '#aa6644' },
        honey: { name: '🍯 Мёд', mainBg: 'linear-gradient(135deg, #eebb55, #ddaa33)', cardBg: '#ffcc66', textColor: '#442200', accentColor: '#ffaa00', borderColor: 'rgba(255,170,0,0.3)', headerBg: 'linear-gradient(135deg, #ffaa00, #dd8800)', deniedColor: '#ff8888', pendingColor: '#ffcc88', approvedColor: '#88ff88', requestColor: '#88aaff', techColor: '#ffcc00' },

        
        sunrise: { name: '🌅 Рассвет', mainBg: 'linear-gradient(135deg, #ff9a56, #ff6b3d)', cardBg: '#ff8a4a', textColor: '#fff4e6', accentColor: '#ffcc00', borderColor: 'rgba(255,204,0,0.3)', headerBg: 'linear-gradient(135deg, #ffcc00, #ff9900)', deniedColor: '#ff8888', pendingColor: '#ffcc88', approvedColor: '#88ff88', requestColor: '#88aaff', techColor: '#ffcc00' },
        twilight: { name: '🌆 Сумерки', mainBg: 'linear-gradient(135deg, #4a2a5a, #2a1a3a)', cardBg: '#3a2a4a', textColor: '#e6ccff', accentColor: '#cc66ff', borderColor: 'rgba(204,102,255,0.3)', headerBg: 'linear-gradient(135deg, #cc66ff, #9933cc)', deniedColor: '#ffaaaa', pendingColor: '#ffddaa', approvedColor: '#aaffaa', requestColor: '#aaccff', techColor: '#cc66ff' },
        night: { name: '🌃 Ночь', mainBg: 'linear-gradient(135deg, #0a0a1a, #000010)', cardBg: '#0a0a15', textColor: '#8888ff', accentColor: '#4444ff', borderColor: 'rgba(68,68,255,0.3)', headerBg: 'linear-gradient(135deg, #4444ff, #2222aa)', deniedColor: '#ff6666', pendingColor: '#ffcc66', approvedColor: '#66ff66', requestColor: '#66ccff', techColor: '#66aaff' },
        starry: { name: '✨ Звёздная', mainBg: 'linear-gradient(135deg, #0a0a2a, #050515)', cardBg: '#0a0a20', textColor: '#ffff66', accentColor: '#ffdd44', borderColor: 'rgba(255,221,68,0.3)', headerBg: 'linear-gradient(135deg, #ffdd44, #ccaa22)', deniedColor: '#ff8888', pendingColor: '#ffcc88', approvedColor: '#88ff88', requestColor: '#88aaff', techColor: '#ffdd44' },

        blood: { name: '🩸 Кровавая', mainBg: 'linear-gradient(135deg, #2a0a0a, #1a0000)', cardBg: '#2a0a0a', textColor: '#ffaaaa', accentColor: '#ff0000', borderColor: 'rgba(255,0,0,0.3)', headerBg: 'linear-gradient(135deg, #ff0000, #aa0000)', deniedColor: '#ff4444', pendingColor: '#ff8844', approvedColor: '#44ff44', requestColor: '#44aaff', techColor: '#ff4444' },
        shadow: { name: '🌑 Тень', mainBg: 'linear-gradient(135deg, #0a0a0a, #000000)', cardBg: '#0a0a0a', textColor: '#888888', accentColor: '#444444', borderColor: 'rgba(68,68,68,0.3)', headerBg: 'linear-gradient(135deg, #444444, #222222)', deniedColor: '#ff8888', pendingColor: '#ffcc88', approvedColor: '#88ff88', requestColor: '#88aaff', techColor: '#666666' },
        void: { name: '🕳️ Пустота', mainBg: 'linear-gradient(135deg, #000000, #0a0a0a)', cardBg: '#050505', textColor: '#aa00aa', accentColor: '#ff00ff', borderColor: 'rgba(255,0,255,0.3)', headerBg: 'linear-gradient(135deg, #ff00ff, #990099)', deniedColor: '#ff4444', pendingColor: '#ffaa00', approvedColor: '#00ff88', requestColor: '#00ccff', techColor: '#ff00ff' },
        noir: { name: '🎬 Нуар', mainBg: 'linear-gradient(135deg, #1a1a1a, #0a0a0a)', cardBg: '#151515', textColor: '#cccccc', accentColor: '#ffaa44', borderColor: 'rgba(255,170,68,0.3)', headerBg: 'linear-gradient(135deg, #ffaa44, #cc8833)', deniedColor: '#ff8888', pendingColor: '#ffcc88', approvedColor: '#88ff88', requestColor: '#88aaff', techColor: '#ffaa44' },
        charcoal: { name: '🖤 Уголь', mainBg: 'linear-gradient(135deg, #1a1a1a, #0a0a0a)', cardBg: '#1a1a1a', textColor: '#cccccc', accentColor: '#888888', borderColor: 'rgba(136,136,136,0.3)', headerBg: 'linear-gradient(135deg, #888888, #555555)', deniedColor: '#ff8888', pendingColor: '#ffcc88', approvedColor: '#88ff88', requestColor: '#88aaff', techColor: '#888888' },

        rainbow: { name: '🌈 Радуга', mainBg: 'linear-gradient(135deg, #ff0000, #ff8800, #ffff00, #00ff00, #0088ff, #8800ff)', cardBg: '#1a1a2e', textColor: '#ffffff', accentColor: '#ff69b4', borderColor: 'rgba(255,105,180,0.3)', headerBg: 'linear-gradient(135deg, #ff69b4, #ff3366)', deniedColor: '#ff0000', pendingColor: '#ff8800', approvedColor: '#00ff00', requestColor: '#0088ff', techColor: '#ff00ff' },
        candy: { name: '🍬 Конфетти', mainBg: 'linear-gradient(135deg, #ff69b4, #ff1493)', cardBg: '#ff69b4', textColor: '#ffffff', accentColor: '#ffff00', borderColor: 'rgba(255,255,0,0.3)', headerBg: 'linear-gradient(135deg, #ffff00, #ffaa00)', deniedColor: '#ff0000', pendingColor: '#ffa500', approvedColor: '#00ff00', requestColor: '#00bfff', techColor: '#ffff00' },
        pastel: { name: '🎨 Пастель', mainBg: 'linear-gradient(135deg, #f0e6ff, #e6ddf5)', cardBg: '#fff5ff', textColor: '#664477', accentColor: '#cc88bb', borderColor: 'rgba(204,136,187,0.3)', headerBg: 'linear-gradient(135deg, #cc88bb, #aa66aa)', deniedColor: '#ffaaaa', pendingColor: '#ffddaa', approvedColor: '#aaffaa', requestColor: '#aaccff', techColor: '#cc88bb' },
        bubblegum: { name: '💗 Бубльгум', mainBg: 'linear-gradient(135deg, #ffccdd, #ffbbcc)', cardBg: '#ffddee', textColor: '#cc3366', accentColor: '#ff66aa', borderColor: 'rgba(255,102,170,0.3)', headerBg: 'linear-gradient(135deg, #ff66aa, #ff3388)', deniedColor: '#ff8888', pendingColor: '#ffcc88', approvedColor: '#88ff88', requestColor: '#88aaff', techColor: '#ff66aa' },

      
        galaxy: { name: '🌌 Галактика', mainBg: 'linear-gradient(135deg, #0a0a2a, #1a0a3a)', cardBg: '#0f0a2a', textColor: '#cc88ff', accentColor: '#aa44ff', borderColor: 'rgba(170,68,255,0.3)', headerBg: 'linear-gradient(135deg, #aa44ff, #6622cc)', deniedColor: '#ff88aa', pendingColor: '#ffcc88', approvedColor: '#88ffaa', requestColor: '#88aaff', techColor: '#aa44ff' },
        nebula: { name: '🌫️ Туманность', mainBg: 'linear-gradient(135deg, #1a0a3a, #0a0a2a)', cardBg: '#1a0a35', textColor: '#88aaff', accentColor: '#6644ff', borderColor: 'rgba(102,68,255,0.3)', headerBg: 'linear-gradient(135deg, #6644ff, #4422cc)', deniedColor: '#ff88aa', pendingColor: '#ffcc88', approvedColor: '#88ffaa', requestColor: '#88aaff', techColor: '#6644ff' },
        aurora: { name: '✨ Аврора', mainBg: 'linear-gradient(135deg, #0a2a3a, #0a1a2a)', cardBg: '#0a2535', textColor: '#aaffcc', accentColor: '#44ffaa', borderColor: 'rgba(68,255,170,0.3)', headerBg: 'linear-gradient(135deg, #44ffaa, #22cc88)', deniedColor: '#ff8888', pendingColor: '#ffcc88', approvedColor: '#88ff88', requestColor: '#88aaff', techColor: '#44ffaa' },

       
        retro: { name: '📼 Ретро', mainBg: 'linear-gradient(135deg, #1a3a5a, #0a2a4a)', cardBg: '#1a3355', textColor: '#ffcc66', accentColor: '#ff9966', borderColor: 'rgba(255,153,102,0.3)', headerBg: 'linear-gradient(135deg, #ff9966, #cc6633)', deniedColor: '#ff8888', pendingColor: '#ffcc88', approvedColor: '#88ff88', requestColor: '#88aaff', techColor: '#ff9966' },
        eighties: { name: '🎸 80-е', mainBg: 'linear-gradient(135deg, #ff00cc, #333399)', cardBg: '#ff33cc', textColor: '#ffff00', accentColor: '#00ffff', borderColor: 'rgba(0,255,255,0.3)', headerBg: 'linear-gradient(135deg, #00ffff, #00cc99)', deniedColor: '#ff4444', pendingColor: '#ffaa00', approvedColor: '#00ff88', requestColor: '#00ccff', techColor: '#ff00cc' }
    };

    const quotes = [
        "«Лучший способ предсказать будущее — создать его» — Питер Друкер",
        "«Не бойтесь ошибаться. Бойтесь повторять ошибки» — Теодор Рузвельт",
        "«Успех — это способность идти от неудачи к неудаче, не теряя энтузиазма» — Уинстон Черчилль"
    ];

    function getRandomQuote() {
        return quotes[Math.floor(Math.random() * quotes.length)];
    }

    
    function loadSettings() {
        const saved = localStorage.getItem(SCRIPTSETTINGS_KEY);
        if (saved) {
            try {
                return JSON.parse(saved);
            } catch(e) {
                return { topBarEnabled: true, theme: 'dark', autoReload: false, autoSaveDrafts: true, soundEnabled: true, useCustomStyle: false, customStyle: null, showQuotes: true };
            }
        }
        return { topBarEnabled: true, theme: 'dark', autoReload: false, autoSaveDrafts: true, soundEnabled: true, useCustomStyle: false, customStyle: null, showQuotes: true };
    }

    function saveSettings(settings) {
        localStorage.setItem(SCRIPTSETTINGS_KEY, JSON.stringify(settings));
    }

    function loadCustomTemplates() {
        const saved = localStorage.getItem(STORAGE_KEY);
        if (saved) {
            try {
                return JSON.parse(saved);
            } catch(e) {
                return [];
            }
        }
        return [];
    }

    function saveCustomTemplates(templates) {
        localStorage.setItem(STORAGE_KEY, JSON.stringify(templates));
    }

    function loadQuickReplies() {
        const saved = localStorage.getItem(QUICKREPLY_KEY);
        if (saved) {
            try {
                return JSON.parse(saved);
            } catch(e) {
                return [];
            }
        }
        return [];
    }

    function saveQuickReplies(replies) {
        localStorage.setItem(QUICKREPLY_KEY, JSON.stringify(replies));
    }

    function loadFavorites() {
        const saved = localStorage.getItem(FAVORITES_KEY);
        if (saved) {
            try {
                return JSON.parse(saved);
            } catch(e) {
                return [];
            }
        }
        return [];
    }

    function saveFavorites(favorites) {
        localStorage.setItem(FAVORITES_KEY, JSON.stringify(favorites));
    }

    function toggleFavorite(templateId) {
        let favorites = loadFavorites();
        if (favorites.includes(templateId)) {
            favorites = favorites.filter(id => id !== templateId);
            showNotification('⭐ Удалено из избранного', 'info');
        } else {
            favorites.push(templateId);
            showNotification('⭐ Добавлено в избранное', 'success');
        }
        saveFavorites(favorites);
        return favorites;
    }

    function isFavorite(templateId) {
        const favorites = loadFavorites();
        return favorites.includes(templateId);
    }

    function loadBanlist() {
        const saved = localStorage.getItem(BANLIST_KEY);
        if (saved) {
            try {
                return JSON.parse(saved);
            } catch(e) {
                return [];
            }
        }
        return [];
    }

    function saveBanlist(banlist) {
        localStorage.setItem(BANLIST_KEY, JSON.stringify(banlist));
    }

    function addToBanlist(playerId, playerName, reason = '') {
        const banlist = loadBanlist();
        banlist.unshift({
            id: playerId,
            name: playerName,
            reason: reason,
            date: new Date().toISOString()
        });
        saveBanlist(banlist);
        showNotification(`➕ ${playerName} добавлен в бан-лист`, 'success');
    }

    function removeFromBanlist(index) {
        const banlist = loadBanlist();
        banlist.splice(index, 1);
        saveBanlist(banlist);
        showNotification('🗑️ Удалено из бан-листа', 'info');
    }

    function updateStats(templateName) {
        const stats = loadStats();
        const today = new Date().toDateString();

        if (!stats[today]) {
            stats[today] = { total: 0, templates: {} };
        }

        stats[today].total++;
        stats[today].templates[templateName] = (stats[today].templates[templateName] || 0) + 1;

        const dates = Object.keys(stats);
        const cutoff = new Date();
        cutoff.setDate(cutoff.getDate() - 30);

        dates.forEach(date => {
            if (new Date(date) < cutoff) {
                delete stats[date];
            }
        });

        saveStats(stats);
        addToHistory(templateName);
    }

    function loadStats() {
        const saved = localStorage.getItem(STATS_KEY);
        if (saved) {
            try {
                return JSON.parse(saved);
            } catch(e) {
                return {};
            }
        }
        return {};
    }

    function saveStats(stats) {
        localStorage.setItem(STATS_KEY, JSON.stringify(stats));
    }

    function loadTemplateHistory() {
        const saved = localStorage.getItem(TEMPLATES_HISTORY_KEY);
        if (saved) {
            try {
                return JSON.parse(saved);
            } catch(e) {
                return [];
            }
        }
        return [];
    }

    function saveTemplateHistory(history) {
        localStorage.setItem(TEMPLATES_HISTORY_KEY, JSON.stringify(history.slice(-30)));
    }

    function addToHistory(templateName) {
        let history = loadTemplateHistory();
        history.unshift({ name: templateName, date: new Date().toISOString() });
        saveTemplateHistory(history);
    }

    function loadMacros() {
        const saved = localStorage.getItem(MACROS_KEY);
        if (saved) {
            try {
                return JSON.parse(saved);
            } catch(e) {
                return [];
            }
        }
        return [];
    }

    function saveMacros(macros) {
        localStorage.setItem(MACROS_KEY, JSON.stringify(macros));
    }

    function addMacro(name, content) {
        const macros = loadMacros();
        macros.push({ name: name, content: content, createdAt: Date.now() });
        saveMacros(macros);
    }

    function deleteMacro(index) {
        const macros = loadMacros();
        macros.splice(index, 1);
        saveMacros(macros);
    }

    function loadTasks() {
        const saved = localStorage.getItem(TASKS_KEY);
        if (saved) {
            try {
                return JSON.parse(saved);
            } catch(e) {
                return [];
            }
        }
        return [];
    }

    function saveTasks(tasks) {
        localStorage.setItem(TASKS_KEY, JSON.stringify(tasks));
    }

    function addTask(title, priority = 'normal') {
        const tasks = loadTasks();
        tasks.push({ id: Date.now(), title: title, completed: false, priority: priority, createdAt: new Date().toISOString() });
        saveTasks(tasks);
    }

    function toggleTask(id) {
        const tasks = loadTasks();
        const task = tasks.find(t => t.id === id);
        if (task) task.completed = !task.completed;
        saveTasks(tasks);
    }

    function deleteTask(id) {
        let tasks = loadTasks();
        tasks = tasks.filter(t => t.id !== id);
        saveTasks(tasks);
    }

    function loadNotes() {
        const saved = localStorage.getItem('forum_script_notes');
        if (saved) {
            try {
                return JSON.parse(saved);
            } catch(e) {
                return [];
            }
        }
        return [];
    }

    function saveNotes(notes) {
        localStorage.setItem('forum_script_notes', JSON.stringify(notes));
    }

    function addNote(title, content) {
        const notes = loadNotes();
        notes.push({ id: Date.now(), title: title, content: content, date: new Date().toISOString() });
        saveNotes(notes);
    }

    function deleteNote(index) {
        const notes = loadNotes();
        notes.splice(index, 1);
        saveNotes(notes);
    }

    function playNotificationSound() {
        const settings = loadSettings();
        if (!settings.soundEnabled) return;
        try {
            const audio = new Audio('https://www.soundjay.com/misc/sounds/bell-ringing-05.mp3');
            audio.volume = 0.2;
            audio.play().catch(e => console.log('Звук не воспроизведён', e));
        } catch(e) {}
    }

    function saveDraft(content) {
        const threadId = window.location.pathname.split('/').pop();
        localStorage.setItem(`draft_${threadId}`, content);
        showNotification('💾 Черновик сохранён', 'success');
    }

    function loadDraft() {
        const threadId = window.location.pathname.split('/').pop();
        return localStorage.getItem(`draft_${threadId}`);
    }

    function clearDraft() {
        const threadId = window.location.pathname.split('/').pop();
        localStorage.removeItem(`draft_${threadId}`);
    }

    function showNotification(message, type = 'info') {
        const colors = {
            success: '#2ecc71',
            error: '#e74c3c',
            info: '#3498db',
            warning: '#f39c12'
        };

        const notification = $(`
            <div style="position:fixed;bottom:80px;right:20px;background:${colors[type]};color:white;padding:10px 16px;border-radius:8px;z-index:10002;font-size:13px;box-shadow:0 4px 12px rgba(0,0,0,0.3);animation:slideIn 0.3s ease;">
                ${message}
            </div>
        `);

        $('body').append(notification);
        setTimeout(() => {
            notification.fadeOut(300, () => notification.remove());
        }, 2000);
    }

    function copyToClipboard(text, successMessage = '✅ Скопировано!') {
        navigator.clipboard.writeText(text);
        showNotification(successMessage, 'success');
        playNotificationSound();
    }

    function addCustomTemplate(title, content, prefix = 3, close = false, moveToForum = '', category = 'complaints') {
        const templates = loadCustomTemplates();
        templates.push({
            id: Date.now(),
            title: title,
            content: content,
            prefix: prefix,
            status: false,
            close: close,
            moveToForum: moveToForum,
            category: category,
            isCustom: true,
            createdAt: Date.now()
        });
        saveCustomTemplates(templates);
        return templates;
    }

    function deleteCustomTemplate(index) {
        const templates = loadCustomTemplates();
        templates.splice(index, 1);
        saveCustomTemplates(templates);
        return templates;
    }

    function updateCustomTemplate(index, title, content, prefix, close, moveToForum, category) {
        const templates = loadCustomTemplates();
        if (templates[index]) {
            templates[index] = {
                ...templates[index],
                title: title,
                content: content,
                prefix: prefix,
                close: close,
                moveToForum: moveToForum,
                category: category
            };
            saveCustomTemplates(templates);
        }
        return templates;
    }

    async function getThreadData() {
        let $username = $('a.username');
        let authorID = null;
        let authorName = 'Игрок';

        if ($username.length && $username[0].attributes && $username[0].attributes['data-user-id']) {
            authorID = $username[0].attributes['data-user-id'].nodeValue;
            authorName = $username.html();
        } else {
            const $authorLink = $('.message-userContent .username, .message-name .username, .message-user .username');
            if ($authorLink.length) {
                authorName = $authorLink.first().text().trim();
                if ($authorLink.first().attr('data-user-id')) {
                    authorID = $authorLink.first().attr('data-user-id');
                }
            }
        }

        if (authorName === 'Игрок' || authorName === '') {
            const threadTitle = $('.p-title-value').text();
            const match = threadTitle.match(/жалоба\s+на\s+(\S+)/i);
            if (match) {
                authorName = match[1];
            }
        }

        return {
            user: {
                id: authorID || 0,
                name: authorName,
                mention: authorID ? `[USER=${authorID}]${authorName}[/USER]` : `[USER]${authorName}[/USER]`
            }
        };
    }

    const data = await getThreadData();
    const user = data.user;
    loadUserVariables();

    function processTemplateContent(content) {
        const now = new Date();
        let result = content
            .replace(/\$\{user\.name\}/g, user.name)
            .replace(/\$\{user\.mention\}/g, user.mention)
            .replace(/\$\{date\}/g, now.toLocaleDateString())
            .replace(/\$\{time\}/g, now.toLocaleTimeString())
            .replace(/\$\{datetime\}/g, now.toLocaleString())
            .replace(/\$\{warnCount\}/g, userVariables.warnCount)
            .replace(/\$\{banCount\}/g, userVariables.banCount)
            .replace(/\$\{adminName\}/g, userVariables.adminName || 'Администратор')
            .replace(/\$\{serverName\}/g, userVariables.serverName)
            .replace(/\$\{random\}/g, Math.floor(Math.random() * 100) + 1);
        return result;
    }

    async function moveThreadToForum(threadId, forumId) {
        return new Promise((resolve, reject) => {
            const formData = new FormData();
            formData.append('_xfToken', XF.config.csrf);
            formData.append('node_id', forumId);
            formData.append('thread_id', threadId);

            fetch('/forum/move-thread', { method: 'POST', body: formData })
                .then(r => r.json())
                .then(data => data.status === 'ok' ? resolve(data) : reject(data))
                .catch(e => reject(e));
        });
    }

   
    const allTemplates = [
{
    title: "Отказано",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(147, 112, 219)][SIZE=5]Отказано.[/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
        "[I][SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Закрыто. [/CENTER][/FONT][/COLOR][/SIZE][/I][/I][/SIZE][/FONT][/SIZE]",
    prefix: 3,
    close: false,
    moveToForum: "",
    tags: [],
    category: "denied"
},
{
    title: "| Наказание выдано верно |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Проверив доказательства администратора, было принято решение, что наказание было выдано верно. [/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
        "[I][SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Закрыто. [/CENTER][/FONT][/COLOR][/SIZE][/I][/I][/SIZE][/FONT][/SIZE]",
    prefix: 3,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "Не подлежит обж",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(147, 112, 219)][SIZE=5] Ваш аккаунт не подлежит обжалованию. [/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
        "[I][SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Закрыто. [/CENTER][/FONT][/COLOR][/SIZE][/I][/I][/SIZE][/FONT][/SIZE]",
    prefix: 3,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| На рассмотрении |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE][/I]<br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Ваша жалоба взята на рассмотрение. <br> Не нужно создавать копии этой жалобы, ожидайте ответа в этой теме.[/SIZE][/COLOR][/FONT]<br>" +
        "[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
        "[I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Ожидайте ответа.[/FONT][/COLOR][/SIZE][/I][/CENTER]",
    prefix: 4,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| Беседа с адм |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Ваша жалоба была одобрена и будет проведена строгая беседа с администратором. [/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
        "[SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приятной игры на сервере [/FONT][COLOR=rgb(106, 90, 205)][FONT=arial]Екатеринбург [/FONT][/COLOR][/COLOR][/SIZE][/I][/SIZE][/FONT][/SIZE][/I][/CENTER]",
    prefix: 2,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| Передано ГА |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Ваша жалоба передана Главному администратору [/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
        "[I][SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Ожидайте ответа [/CENTER][/FONT][/COLOR][/SIZE][/I][/I][/SIZE][/FONT][/SIZE]",
    prefix: 4,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| Нету доказательств |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]В вашей жалобе отсутствуют доказательства. [/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
        "[I][SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Закрыто. [/CENTER][/FONT][/COLOR][/SIZE][/I][/I][/SIZE][/FONT][/SIZE]",
    prefix: 3,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| Не рабочие доказательства |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]В вашей жалобе не работают доказательства. [/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
        "[I][SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Закрыто. [/CENTER][/FONT][/COLOR][/SIZE][/I][/I][/SIZE][/FONT][/SIZE]",
    prefix: 3,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| Недостаточно доказательств  |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]В вашей жалобе недостаточно доказательств . [/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
        "[I][SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Закрыто. [/CENTER][/FONT][/COLOR][/SIZE][/I][/I][/SIZE][/FONT][/SIZE]",
    prefix: 3,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| На рассмотрении |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE][/I]<br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Ваша жалоба взята на рассмотрение. <br> Не нужно создавать копии этой жалобы, ожидайте ответа в этой теме.[/SIZE][/COLOR][/FONT]<br>" +
        "[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
        "[I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Ожидайте ответа.[/FONT][/COLOR][/SIZE][/I][/CENTER]",
    prefix: 4,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| Игрок будет наказан |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE][/I]<br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Ваша жалоба рассмотрена. Игрок будет наказан.[/SIZE][/COLOR][/FONT]<br>" +
        "[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
        "[I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приятной игры![/FONT][/COLOR][/SIZE][/I][/CENTER]",
    prefix: 2,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| Нету тайм-кода |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]В предоставленных доказательствах отсутствует /time. [/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
        "[I][SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Закрыто. [/CENTER][/FONT][/COLOR][/SIZE][/I][/I][/SIZE][/FONT][/SIZE]",
    prefix: 3,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| Админ получит наказание |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Ваша жалоба была одобрена и администратор получит наказание. [/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
        "[SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приятной игры на сервере [/FONT][COLOR=rgb(106, 90, 205)][FONT=arial]Екатеринбург  [/FONT][/COLOR][/COLOR][/SIZE][/I][/SIZE][/FONT][/SIZE][/I][/CENTER]",
    prefix: 2,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| В тех раздел |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Вы ошиблись разделом.<br>Обратитесь в Технический раздел - [URL=https://forum.ragerussia.online/forums/3//]*Тык*[/URL]. [/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
        "[I][SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Закрыто. [/CENTER][/FONT][/COLOR][/SIZE][/I][/I][/SIZE][/FONT][/SIZE]",
    prefix: 2,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| Жалоба не по форме |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Ваша жалоба составлена не по форме.<br>Убедительная просьба ознакомиться с правилами подачи жалоб на администрацию - [URL=https://forum.ragerussia.online/threads/8660/]*Тык*[/URL] [/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
        "[I][SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Закрыто. [/CENTER][/FONT][/COLOR][/SIZE][/I][/I][/SIZE][/FONT][/SIZE]",
    prefix: 3,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| Наказание будет снято |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Ваше наказание будет снято в ближайшее время.[/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
        "[SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приятной игры на сервере [/FONT][COLOR=rgb(106, 90, 205)][FONT=arial]Екатеринбург [/FONT][/COLOR][/COLOR][/SIZE][/I][/SIZE][/FONT][/SIZE][/I][/CENTER]",
    prefix: 2,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| Передано ЗГА |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Ваша жалоба передана Заместителю главного администратора [/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
        "[I][SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Ожидайте ответа [/CENTER][/FONT][/COLOR][/SIZE][/I][/I][/SIZE][/FONT][/SIZE]",
    prefix: 4,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| Уже не адм |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Данный игрок был снят с поста администратора. [/SIZE][/COLOR][/FONT][/I]<br>[url=https://postimages.org/][img]https://i.postimg.cc/TY3TpPFL/9914e97b895811f4cb5f5aafcdebc98f7a9b20a3r1-320-146-hq.gif[/img][/url]<br><br>" +
        "[SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приятной игры на сервере [/FONT][COLOR=rgb(106, 90, 205)][FONT=arial]Екатеринбург  [/FONT][/COLOR][/COLOR][/SIZE][/I][/SIZE][/FONT][/SIZE][/I][/CENTER]",
    prefix: 3,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| Запрошу доки |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Запрошу доказательства у администратора. <br> Ожидайте, пожалуйста, ответа от администрации и не нужно создавать копии этой темы. [/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
        "[I][SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Ожидайте ответа. [/CENTER][/FONT][/COLOR][/SIZE][/I][/I][/SIZE][/FONT][/SIZE]",
    prefix: 4,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| От 3-го лица|",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Жалобы, написанные от 3-го лица рассмотрению не подлежат.[/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
        "[I][SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Закрыто.[/CENTER][/FONT][/COLOR][/SIZE][/I][/I][/SIZE][/FONT][/SIZE]",
    prefix: 3,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| Беседа с лидером |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Ваша жалоба была одобрена и будет проведена строгая беседа с лидером. [/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br]" +
        "[SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приятной игры на сервере [/FONT][COLOR=rgb(106, 90, 205)][FONT=arial]Екатеринбург [/FONT][/COLOR][/COLOR][/SIZE][/I][/SIZE][/FONT][/SIZE][/I][/CENTER]",
    prefix: 2,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
        {
    title: "| Админ получит наказание |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Ваша жалоба была одобрена и администратор получит наказание. [/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
        "[SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приятной игры на сервере [/FONT][COLOR=rgb(106, 90, 205)][FONT=arial]Екатеринбург  [/FONT][/COLOR][/COLOR][/SIZE][/I][/SIZE][/FONT][/SIZE][/I][/CENTER]",
    prefix: 2,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| В тех раздел |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Вы ошиблись разделом.<br>Обратитесь в Технический раздел - [URL=https://forum.ragerussia.online/forums/3//]*Тык*[/URL]. [/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
        "[I][SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Закрыто. [/CENTER][/FONT][/COLOR][/SIZE][/I][/I][/SIZE][/FONT][/SIZE]",
    prefix: 2,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| Жалоба не по форме |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Ваша жалоба составлена не по форме.<br>Убедительная просьба ознакомиться с правилами подачи жалоб на администрацию - [URL=https://forum.ragerussia.online/threads/8660/]*Тык*[/URL] [/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
        "[I][SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Закрыто. [/CENTER][/FONT][/COLOR][/SIZE][/I][/I][/SIZE][/FONT][/SIZE]",
    prefix: 3,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| Наказание будет снято |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Ваше наказание будет снято в ближайшее время.[/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
        "[SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приятной игры на сервере [/FONT][COLOR=rgb(106, 90, 205)][FONT=arial]Екатеринбург [/FONT][/COLOR][/COLOR][/SIZE][/I][/SIZE][/FONT][/SIZE][/I][/CENTER]",
    prefix: 2,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| Передано ЗГА |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Ваша жалоба передана Заместителю главного администратора [/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
        "[I][SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Ожидайте ответа [/CENTER][/FONT][/COLOR][/SIZE][/I][/I][/SIZE][/FONT][/SIZE]",
    prefix: 4,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| Уже не адм |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Данный игрок был снят с поста администратора. [/SIZE][/COLOR][/FONT][/I]<br>[url=https://postimages.org/][img]https://i.postimg.cc/TY3TpPFL/9914e97b895811f4cb5f5aafcdebc98f7a9b20a3r1-320-146-hq.gif[/img][/url]<br><br>" +
        "[SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приятной игры на сервере [/FONT][COLOR=rgb(106, 90, 205)][FONT=arial]Екатеринбург  [/FONT][/COLOR][/COLOR][/SIZE][/I][/SIZE][/FONT][/SIZE][/I][/CENTER]",
    prefix: 3,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| Запрошу доки |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Запрошу доказательства у администратора. <br> Ожидайте, пожалуйста, ответа от администрации и не нужно создавать копии этой темы. [/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
        "[I][SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Ожидайте ответа. [/CENTER][/FONT][/COLOR][/SIZE][/I][/I][/SIZE][/FONT][/SIZE]",
    prefix: 4,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| От 3-го лица|",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Жалобы, написанные от 3-го лица рассмотрению не подлежат.[/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
        "[I][SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Закрыто.[/CENTER][/FONT][/COLOR][/SIZE][/I][/I][/SIZE][/FONT][/SIZE]",
    prefix: 3,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| Беседа с лидером |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Ваша жалоба была одобрена и будет проведена строгая беседа с лидером. [/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br]" +
        "[SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приятной игры на сервере [/FONT][COLOR=rgb(106, 90, 205)][FONT=arial]Екатеринбург [/FONT][/COLOR][/COLOR][/SIZE][/I][/SIZE][/FONT][/SIZE][/I][/CENTER]",
    prefix: 2,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| Лидер получит наказание |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Ваша жалоба была одобрена и лидер получит наказание. [/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br]" +
        "[SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приятной игры на сервере [/FONT][COLOR=rgb(106, 90, 205)][FONT=arial]Екатеринбург  [/FONT][/COLOR][/COLOR][/SIZE][/I][/SIZE][/FONT][/SIZE][/I][/CENTER]",
    prefix: 2,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| Нет нарушений от лд|",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}.  [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Проверив ваши доказательства, нарушения со стороны лидера не выявлено. [/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br]" +
        "[SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приятной игры на сервере [/FONT][COLOR=rgb(106, 90, 205)][FONT=arial]Екатеринбург  [/FONT][/COLOR][/COLOR][/SIZE][/I][/SIZE][/FONT][/SIZE][/I][/CENTER]",
    prefix: 3,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| В нрп обман |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый  ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Вы ошиблись разделом.<br>Обратитесь в раздел жалоб на NonRP разводы - [URL=https://forum.ragerussia.online/forums/105/]*Тык*[/URL]. [/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br]" +
        "[I][SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Закрыто. [/CENTER][/FONT][/COLOR][/SIZE][/I][/I][/SIZE][/FONT][/SIZE]",
    prefix: 3,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| Не лидер |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый  ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Данный игрок не является лидером. [/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br]" +
        "[SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приятной игры на сервере [/FONT][COLOR=rgb(106, 90, 205)][FONT=arial]Екатеринбург  [/FONT][/COLOR][/COLOR][/SIZE][/I][/SIZE][/FONT][/SIZE][/I][/CENTER]",
    prefix: 3,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| Нету условий сделки |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Отсутствуют условия сделки. [/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
        "[I][SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Закрыто. [/CENTER][/FONT][/COLOR][/SIZE][/I][/I][/SIZE][/FONT][/SIZE]",
    prefix: 3,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| Ошиблись сервером |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Вы ошиблись сервером. [/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
        "[I][SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Закрыто. [/CENTER][/FONT][/COLOR][/SIZE][/I][/I][/SIZE][/FONT][/SIZE]",
    prefix: 3,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
{
    title: "| Нарушений не найдено |",
    content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
        "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Просмотрев ваши доказательства, нарушений найдено не было. [/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
        "[I][SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Закрыто. [/CENTER][/FONT][/COLOR][/SIZE][/I][/I][/SIZE][/FONT][/SIZE]",
    prefix: 3,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
        {
        title: "| Ответ в прошлой теме |",
        content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
            "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Ответ был дан в прошлой теме. [/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
            "[I][SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Закрыто. [/CENTER][/FONT][/COLOR][/SIZE][/I][/I][/SIZE][/FONT][/SIZE]",
    prefix: 3,
    close: false,
    moveToForum: "",
    tags: [],
    category: "complaints"
},
              {
        title: "| Не по теме  |",
        content: "[CENTER][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Приветствую, уважаемый ${user.name}. [/FONT][/COLOR][/SIZE] <br><br>" +
            "[FONT=times new roman][COLOR=rgb(146, 58, 255)][SIZE=5]Не по теме. [/SIZE][/COLOR][/FONT][/I]<br>[URL=https://postimages.org/][IMG]https://i.postimg.cc/6pRdXXKx/20240615-022705.png[/IMG][/URL]<br><br>" +
            "[I][SIZE=5][FONT=times new roman][SIZE=5][I][I][SIZE=4][COLOR=rgb(147, 112, 219)][FONT=arial]Закрыто. [/CENTER][/FONT][/COLOR][/SIZE][/I][/I][/SIZE][/FONT][/SIZE]",
    prefix: 3,
    close: false,
    moveToForum: "",
    tags: [],
    category: "denied"
}

    ];

    let isWindowOpen = false;

    
    function filterTemplates() {
        const search = $('#templateSearchInput').val().toLowerCase();
        const categoryFilter = $('#categoryFilterSelect').val();
        const sortBy = $('#sortBySelect').val();
        const dateFilter = $('#dateFilterSelect').val();

        let visibleCount = 0;
        let templateItems = [];

        $('.template-item-btn').each(function() {
            const $btn = $(this);
            const title = $btn.find('.template-title').text().toLowerCase();
            const tags = $btn.data('tags') || '';
            const category = $btn.data('category');
            const createdAt = $btn.data('created') || Date.now();

            const matchesSearch = search === '' || title.includes(search) || (tags && tags.toLowerCase().includes(search));
            const matchesCategory = categoryFilter === 'all' || category === categoryFilter;

            let matchesDate = true;
            const daysOld = (Date.now() - createdAt) / (1000 * 60 * 60 * 24);
            if (dateFilter === 'week') matchesDate = daysOld <= 7;
            else if (dateFilter === 'month') matchesDate = daysOld <= 30;
            else if (dateFilter === 'old') matchesDate = daysOld > 30;

            const isVisible = matchesSearch && matchesCategory && matchesDate;

            if (isVisible) {
                visibleCount++;
                templateItems.push({ element: $btn, title: title, category: category, createdAt: createdAt });
                $btn.show();
            } else {
                $btn.hide();
            }
        });

        if (sortBy === 'alphabet') {
            templateItems.sort((a, b) => a.title.localeCompare(b.title));
        } else if (sortBy === 'alphabet-desc') {
            templateItems.sort((a, b) => b.title.localeCompare(a.title));
        } else if (sortBy === 'date-asc') {
            templateItems.sort((a, b) => a.createdAt - b.createdAt);
        } else if (sortBy === 'date-desc') {
            templateItems.sort((a, b) => b.createdAt - a.createdAt);
        }

        const container = $('.tab-content:visible');
        templateItems.forEach(item => {
            container.append(item.element);
        });

        $('#searchStats').html(`📊 Найдено: ${visibleCount}<br>🔍 Поиск: "${search || 'все'}" | 📁 Категория: ${categoryFilter === 'all' ? 'все' : categoryFilter}`);
    }

    function getCurrentTheme() {
        const settings = loadSettings();
        if (settings.useCustomStyle && settings.customStyle) {
            return settings.customStyle;
        }
        return PRESET_THEMES[settings.theme] || PRESET_THEMES.dark;
    }

    function applyCustomStyle(theme) {
        const $win = $('#compactScriptWindow');
        if (!$win.length) return;

        $win.css('background', theme.mainBg);
        $win.css('color', theme.textColor);
        $win.find('#windowHeader').css('background', theme.headerBg || theme.accentColor);
        $win.find('#windowHeader').css('color', 'white');
        $win.find('.tab-btn.active').css('border-bottom', `2px solid ${theme.accentColor}`);
        $win.find('.tab-btn').css('color', theme.textColor);
        $win.find('.template-item-btn').css({ 'background': theme.cardBg, 'color': theme.textColor });
        $win.find('.template-item-btn[data-category="denied"]').css('border-left-color', theme.deniedColor || '#e74c3c');
        $win.find('.template-item-btn[data-category="pending"]').css('border-left-color', theme.pendingColor || '#f39c12');
        $win.find('.template-item-btn[data-category="approved"]').css('border-left-color', theme.approvedColor || '#2ecc71');
        $win.find('.custom-template-item, .quick-reply-item, .banlist-item, .macro-item, .task-item, .note-item').css({ 'background': theme.cardBg, 'color': theme.textColor });
        $win.find('input, textarea, select').css({ 'background': theme.cardBg, 'color': theme.textColor, 'borderColor': theme.borderColor || 'rgba(155,89,182,0.3)' });
        $win.find('#quickClosedBtn').css('background', theme.deniedColor || '#e74c3c');
        $win.find('#quickUnacceptBtn').css('background', theme.pendingColor || '#f39c12');
        $win.find('#quickConsiderBtn, #quickCopyLinkBtn').css('background', theme.requestColor || '#3498db');
        $win.find('#quickAcceptBtn, #quickRefreshBtn, #quickCopyIDBtn, #quickMentionBtn, #quickClearEditorBtn').css('background', theme.approvedColor || '#2ecc71');
        $win.find('#createTemplateBtn, #addQuickReplyBtn, #addToBanlistBtn, #addMacroBtn, #addNoteBtn, #addTaskBtn, #applyCustomStyleBtn').css('background', theme.accentColor);
    }

    function escapeHtml(str) {
        if (!str) return '';
        return str.replace(/[&<>]/g, m => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;' }[m]));
    }

    function pasteContent(content) {
        const editor = $('div.fr-element.fr-view');
        const placeholder = $('span.fr-placeholder');
        placeholder.empty();
        const currentContent = editor.html();
        if (currentContent === '' || currentContent === '<p><br></p>' || currentContent === '<p></p>') editor.html(content);
        else editor.append(`<p><br></p><p><br></p>${content}`);
        if (loadSettings().autoSaveDrafts !== false) saveDraft(content);
    }

    function closeThreadAsync() {
        return new Promise((resolve, reject) => {
            const formData = new FormData();
            formData.append('_xfToken', XF.config.csrf);
            formData.append('_xfRequestUri', location.pathname + location.search);
            formData.append('_xfWithData', '1');
            formData.append('_xfResponseType', 'json');
            fetch(location.href + 'close', { method: 'POST', body: formData }).then(r => r.json()).then(data => data.status === 'ok' ? resolve(data) : reject(data)).catch(e => reject(e));
        });
    }

    function editThreadDataAsync(prefix, closed = false) {
        return new Promise((resolve, reject) => {
            const $titleValue = $('.p-title-value');
            if (!$titleValue.length) { reject('Элемент заголовка не найден'); return; }
            let threadTitle = $titleValue[0].lastChild ? $titleValue[0].lastChild.textContent : $titleValue.text();
            if (!threadTitle || threadTitle.trim() === '') threadTitle = 'Тема';
            const formData = new FormData();
            formData.append('prefix_id', prefix);
            formData.append('title', threadTitle);
            formData.append('_xfToken', XF.config.csrf);
            formData.append('_xfRequestUri', location.pathname + location.search);
            formData.append('_xfWithData', '1');
            formData.append('_xfResponseType', 'json');
            if (closed) formData.append('sticky', '1');
            fetch(location.href + 'edit', { method: 'POST', body: formData }).then(r => r.json()).then(data => data.status === 'ok' ? resolve(data) : reject(data)).catch(e => reject(e));
        });
    }

    function editThreadDataAndReload(prefix, closed, close) {
        editThreadDataAsync(prefix, closed).then(async () => { if (close) await closeThreadAsync(); location.reload(); }).catch(err => console.error('Ошибка:', err));
    }

    function toggleCompactWindow() {
        if (isWindowOpen) {
            $('#compactScriptWindow').remove();
            isWindowOpen = false;
        } else {
            showCompactWindow();
        }
    }

    function showTopBar() {
        if ($('#topBarScript').length) return;
        const theme = getCurrentTheme();
        const topBarHtml = `
            <div id="topBarScript" style="position:fixed;top:0;left:0;right:0;height:36px;background:${theme.headerBg || theme.accentColor};border-bottom:2px solid ${theme.accentColor};z-index:9999;display:flex;align-items:center;justify-content:space-between;padding:0 16px;">
                <div style="display:flex;align-items:center;gap:8px;">
                    <span style="font-size:18px;">✨</span>
                    <span style="color:white;font-weight:bold;font-size:13px;">RAGE Script EKB</span>
                    <span style="font-size:10px;background:rgba(255,255,255,0.2);padding:2px 6px;border-radius:20px;">v18</span>
                </div>
                <div style="display:flex;gap:6px;">
                    <button id="topBarOpenBtn" style="background:${theme.accentColor};border:none;padding:4px 12px;border-radius:16px;color:white;cursor:pointer;font-size:11px;">📋 Открыть</button>
                    <button id="topBarCloseBtn" style="background:${theme.deniedColor || '#e74c3c'};border:none;padding:4px 12px;border-radius:16px;color:white;cursor:pointer;font-size:11px;">🔒 Закрыть</button>
                    <button id="topBarUnacceptBtn" style="background:${theme.pendingColor || '#f39c12'};border:none;padding:4px 12px;border-radius:16px;color:white;cursor:pointer;font-size:11px;">❌ Отказать</button>
                    <button id="topBarAcceptBtn" style="background:${theme.approvedColor || '#2ecc71'};border:none;padding:4px 12px;border-radius:16px;color:white;cursor:pointer;font-size:11px;">✅ Принять</button>
                </div>
            </div>
        `;
        $('body').append(topBarHtml);
        $('#topBarOpenBtn').click(() => showCompactWindow());
        $('#topBarCloseBtn').click(() => editThreadDataAndReload(PIN_PREFIX, true, false));
        $('#topBarUnacceptBtn').click(() => editThreadDataAndReload(UNACCEPT_PREFIX, false, false));
        $('#topBarAcceptBtn').click(() => editThreadDataAndReload(ACCEPT_PREFIX, false, false));
        $('body').css('padding-top', '36px');
    }

    // ========== ОСНОВНОЕ ОКНО ==========
    function showCompactWindow() {
        const customTemplates = loadCustomTemplates();
        const quickReplies = loadQuickReplies();
        const settings = loadSettings();
        const stats = loadStats();
        const todayStats = stats[new Date().toDateString()] || { total: 0, templates: {} };
        const favorites = loadFavorites();
        const banlist = loadBanlist();
        const macros = loadMacros();
        const notes = loadNotes();
        const tasks = loadTasks();
        const history = loadTemplateHistory();

        const windowHtml = `
            <div id="compactScriptWindow" style="position:fixed;top:50px;right:20px;width:560px;max-height:85vh;border-radius:16px;box-shadow:0 8px 32px rgba(0,0,0,0.4);z-index:10000;display:flex;flex-direction:column;overflow:hidden;">
                <div style="display:flex;justify-content:space-between;align-items:center;padding:12px 16px;cursor:move;" id="windowHeader">
                    <div style="display:flex;align-items:center;gap:8px;">
                        <span style="font-size:20px;">✨</span>
                        <span style="font-weight:bold;">RAGE Script by Flora</span>
                        <span style="font-size:9px;background:rgba(255,255,255,0.2);padding:2px 6px;border-radius:10px;">❤️</span>
                    </div>
                    <div style="display:flex;gap:8px;">
                        <button id="quoteOfDayBtn" style="background:none;border:none;font-size:16px;cursor:pointer;width:28px;height:28px;border-radius:6px;" title="Цитата дня">💬</button>
                        <button id="minimizeWindowBtn" style="background:none;border:none;font-size:18px;cursor:pointer;width:28px;height:28px;border-radius:6px;">➖</button>
                        <button id="closeWindowBtn" style="background:none;border:none;font-size:18px;cursor:pointer;width:28px;height:28px;border-radius:6px;">✖️</button>
                    </div>
                </div>

                <div style="padding:12px;overflow-y:auto;flex:1;">
                    <div style="display:grid;grid-template-columns:repeat(4,1fr);gap:8px;margin-bottom:16px;">
                        <button id="quickClosedBtn" style="padding:8px;border-radius:8px;border:none;cursor:pointer;font-size:11px;font-weight:bold;">🔒 Закрыть</button>
                        <button id="quickUnacceptBtn" style="padding:8px;border-radius:8px;border:none;cursor:pointer;font-size:11px;font-weight:bold;">❌ Отказать</button>
                        <button id="quickConsiderBtn" style="padding:8px;border-radius:8px;border:none;cursor:pointer;font-size:11px;font-weight:bold;">📋 На рассм.</button>
                        <button id="quickAcceptBtn" style="padding:8px;border-radius:8px;border:none;cursor:pointer;font-size:11px;font-weight:bold;">✅ Принять</button>
                    </div>
                    <div style="display:grid;grid-template-columns:repeat(5,1fr);gap:8px;margin-bottom:16px;">
                        <button id="quickCopyLinkBtn" style="padding:6px;border-radius:6px;border:none;cursor:pointer;font-size:10px;">🔗 Ссылку</button>
                        <button id="quickMentionBtn" style="padding:6px;border-radius:6px;border:none;cursor:pointer;font-size:10px;">@ Упомянуть</button>
                        <button id="quickRefreshBtn" style="padding:6px;border-radius:6px;border:none;cursor:pointer;font-size:10px;">🔄 Обновить</button>
                        <button id="quickCopyIDBtn" style="padding:6px;border-radius:6px;border:none;cursor:pointer;font-size:10px;">🆔 ID темы</button>
                        <button id="quickClearEditorBtn" style="padding:6px;border-radius:6px;border:none;cursor:pointer;font-size:10px;">🗑️ Очистить</button>
                    </div>

                    <div style="display:flex;gap:8px;margin-bottom:12px;">
                        <input type="text" id="templateSearchInput" placeholder="🔍 Поиск шаблонов..." style="flex:2;padding:10px 12px;border-radius:10px;border:1px solid;box-sizing:border-box;">
                        <select id="categoryFilterSelect" style="flex:1;padding:10px;border-radius:10px;border:1px solid;">
                            <option value="all">📋 Все (${allTemplates.length + customTemplates.length})</option>
                            <option value="denied">❌ Отказано</option>
                            <option value="pending">⏳ На рассмотрении</option>
                            <option value="approved">✅ Одобрено</option>
                            <option value="request">📨 Запросы</option>
                            <option value="tech">🔧 Тех раздел</option>
                        </select>
                    </div>
                    <div id="searchStats" style="font-size:10px;margin-bottom:12px;text-align:right;"></div>

                    <div style="display:flex;gap:4px;margin-bottom:12px;border-bottom:1px solid;flex-wrap:wrap;">
                        <button class="tab-btn active" data-tab="all" style="padding:8px 12px;background:none;border:none;cursor:pointer;">📋 Шаблоны</button>
                        <button class="tab-btn" data-tab="favorites" style="padding:8px 12px;background:none;border:none;cursor:pointer;">⭐ Избранное (${favorites.length})</button>
                        <button class="tab-btn" data-tab="custom" style="padding:8px 12px;background:none;border:none;cursor:pointer;">🎨 Мои (${customTemplates.length})</button>
                        <button class="tab-btn" data-tab="quick" style="padding:8px 12px;background:none;border:none;cursor:pointer;">⚡ Быстрые (${quickReplies.length})</button>
                        <button class="tab-btn" data-tab="macros" style="padding:8px 12px;background:none;border:none;cursor:pointer;">🔧 Макросы (${macros.length})</button>
                        <button class="tab-btn" data-tab="tasks" style="padding:8px 12px;background:none;border:none;cursor:pointer;">✅ Задачи (${tasks.filter(t => !t.completed).length})</button>
                        <button class="tab-btn" data-tab="notes" style="padding:8px 12px;background:none;border:none;cursor:pointer;">📝 Заметки (${notes.length})</button>
                        <button class="tab-btn" data-tab="banlist" style="padding:8px 12px;background:none;border:none;cursor:pointer;">📋 Бан-лист (${banlist.length})</button>
                        <button class="tab-btn" data-tab="variables" style="padding:8px 12px;background:none;border:none;cursor:pointer;">📊 Переменные</button>
                        <button class="tab-btn" data-tab="stats" style="padding:8px 12px;background:none;border:none;cursor:pointer;">📊 Статистика</button>
                        <button class="tab-btn" data-tab="settings" style="padding:8px 12px;background:none;border:none;cursor:pointer;">⚙️ Настройки</button>
                    </div>

                    <div id="allTab" class="tab-content" style="display:block;">
                        ${allTemplates.map((btn, idx) => `
                            <button class="template-item-btn" data-template-type="all" data-template-index="${idx}" data-category="${btn.category}" data-tags="${btn.tags.join(' ')}" data-created="${btn.createdAt}" style="display:block;width:100%;text-align:left;padding:10px 12px;margin:6px 0;border-radius:8px;border-left:3px solid;cursor:pointer;transition:all 0.2s;">
                                <span class="template-title">${btn.title}</span>
                                <button class="favorite-star" data-template-id="all_${idx}" style="float:right;background:none;border:none;cursor:pointer;font-size:14px;">${isFavorite(`all_${idx}`) ? '★' : '☆'}</button>
                            </button>
                        `).join('')}
                    </div>

                    <div id="favoritesTab" class="tab-content" style="display:none;"><div id="favoritesList"></div></div>

                    <div id="customTab" class="tab-content" style="display:none;">
                        <button id="createTemplateBtn" style="width:100%;padding:10px;border-radius:10px;border:none;cursor:pointer;margin-bottom:12px;font-weight:bold;">➕ Создать шаблон</button>
                        <div id="customTemplatesList">
                            ${customTemplates.length === 0 ? '<div style="text-align:center;padding:20px;">Нет своих шаблонов</div>' : ''}
                            ${customTemplates.map((tpl, idx) => `
                                <div class="custom-template-item" style="border-radius:8px;margin-bottom:8px;padding:10px;">
                                    <div style="display:flex;justify-content:space-between;align-items:center;">
                                        <span style="font-weight:bold;">${escapeHtml(tpl.title)}</span>
                                        <div><button class="edit-custom-btn" data-index="${idx}" style="border:none;padding:4px 8px;border-radius:4px;cursor:pointer;margin-right:4px;">✏️</button><button class="delete-custom-btn" data-index="${idx}" style="border:none;padding:4px 8px;border-radius:4px;cursor:pointer;">🗑️</button></div>
                                    </div>
                                    <div style="font-size:10px;margin-top:4px;">Префикс: ${tpl.prefix === 2 ? 'Рассмотрено' : (tpl.prefix === 3 ? '❌ Отказано' : '⏳ На рассмотрении')}</div>
                                    <button class="use-custom-btn" data-index="${idx}" style="width:100%;margin-top:6px;padding:6px;border-radius:6px;border:none;cursor:pointer;">Использовать</button>
                                </div>
                            `).join('')}
                        </div>
                    </div>

                    <div id="quickTab" class="tab-content" style="display:none;">
                        <button id="addQuickReplyBtn" style="width:100%;padding:10px;border-radius:10px;border:none;cursor:pointer;margin-bottom:12px;font-weight:bold;">➕ Добавить быстрый ответ</button>
                        <div id="quickRepliesList">
                            ${quickReplies.length === 0 ? '<div style="text-align:center;padding:20px;">Нет быстрых ответов</div>' : ''}
                            ${quickReplies.map((reply, idx) => `
                                <div class="quick-reply-item" style="border-radius:8px;margin-bottom:8px;padding:10px;">
                                    <div style="display:flex;justify-content:space-between;"><span style="font-weight:bold;">⚡ ${escapeHtml(reply.title)}</span><div><button class="edit-quick-reply" data-index="${idx}" style="border:none;padding:4px 8px;border-radius:4px;cursor:pointer;">✏️</button><button class="delete-quick-reply" data-index="${idx}" style="border:none;padding:4px 8px;border-radius:4px;cursor:pointer;">🗑️</button></div></div>
                                    <button class="use-quick-reply" data-index="${idx}" style="width:100%;margin-top:6px;padding:6px;border-radius:6px;border:none;cursor:pointer;">📝 Вставить</button>
                                </div>
                            `).join('')}
                        </div>
                    </div>

                    <div id="macrosTab" class="tab-content" style="display:none;">
                        <div style="display:flex;gap:8px;margin-bottom:12px;">
                            <input type="text" id="macroNameInput" placeholder="Название макроса" style="flex:1;padding:8px;border-radius:6px;border:1px solid;">
                            <input type="text" id="macroContentInput" placeholder="Текст макроса" style="flex:2;padding:8px;border-radius:6px;border:1px solid;">
                            <button id="addMacroBtn" style="padding:8px 12px;border-radius:6px;border:none;cursor:pointer;">➕ Добавить</button>
                        </div>
                        <div id="macrosList">
                            ${macros.length === 0 ? '<div style="text-align:center;padding:20px;">Нет макросов</div>' : ''}
                            ${macros.map((macro, idx) => `
                                <div class="macro-item" style="border-radius:8px;margin-bottom:8px;padding:10px;">
                                    <div style="display:flex;justify-content:space-between;">
                                        <span style="font-weight:bold;">🔧 ${escapeHtml(macro.name)}</span>
                                        <div><button class="use-macro-btn" data-index="${idx}" style="border:none;padding:4px 8px;border-radius:4px;cursor:pointer;margin-right:4px;">📝 Вставить</button><button class="delete-macro-btn" data-index="${idx}" style="border:none;padding:4px 8px;border-radius:4px;cursor:pointer;">🗑️</button></div>
                                    </div>
                                    <div style="font-size:11px;margin-top:4px;color:#aaa;">${escapeHtml(macro.content.substring(0, 50))}...</div>
                                </div>
                            `).join('')}
                        </div>
                    </div>

                    <div id="tasksTab" class="tab-content" style="display:none;">
                        <div style="display:flex;gap:8px;margin-bottom:12px;">
                            <input type="text" id="taskInput" placeholder="Новая задача..." style="flex:2;padding:8px;border-radius:6px;border:1px solid;">
                            <select id="taskPriority" style="flex:1;padding:8px;border-radius:6px;border:1px solid;">
                                <option value="high">🔴 Высокий</option>
                                <option value="normal">🟡 Средний</option>
                                <option value="low">🟢 Низкий</option>
                            </select>
                            <button id="addTaskBtn" style="padding:8px 12px;border-radius:6px;border:none;cursor:pointer;">➕ Добавить</button>
                        </div>
                        <div id="tasksList">
                            ${tasks.length === 0 ? '<div style="text-align:center;padding:20px;">Нет задач</div>' : ''}
                            ${tasks.map(task => `
                                <div class="task-item" style="border-radius:8px;margin-bottom:8px;padding:10px;opacity: ${task.completed ? 0.6 : 1};">
                                    <div style="display:flex;justify-content:space-between;align-items:center;">
                                        <div style="display:flex;align-items:center;gap:8px;">
                                            <button class="toggle-task-btn" data-id="${task.id}" style="border:none;background:none;cursor:pointer;font-size:16px;">${task.completed ? '✅' : '⬜'}</button>
                                            <span style="${task.completed ? 'text-decoration:line-through;' : ''}">${escapeHtml(task.title)}</span>
                                            <span style="font-size:10px;padding:2px 6px;border-radius:10px;background:${task.priority === 'high' ? '#e74c3c' : (task.priority === 'low' ? '#2ecc71' : '#f39c12')}">${task.priority === 'high' ? 'Высокий' : (task.priority === 'low' ? 'Низкий' : 'Средний')}</span>
                                        </div>
                                        <button class="delete-task-btn" data-id="${task.id}" style="border:none;padding:4px 8px;border-radius:4px;cursor:pointer;">🗑️</button>
                                    </div>
                                </div>
                            `).join('')}
                        </div>
                    </div>

                    <div id="notesTab" class="tab-content" style="display:none;">
                        <div style="display:flex;gap:8px;margin-bottom:12px;">
                            <input type="text" id="noteTitleInput" placeholder="Заголовок заметки" style="flex:1;padding:8px;border-radius:6px;border:1px solid;">
                            <button id="addNoteBtn" style="padding:8px 12px;border-radius:6px;border:none;cursor:pointer;">➕ Добавить</button>
                        </div>
                        <textarea id="noteContentInput" placeholder="Текст заметки..." rows="3" style="width:100%;padding:8px;border-radius:6px;border:1px solid;margin-bottom:12px;box-sizing:border-box;"></textarea>
                        <div id="notesList">
                            ${notes.length === 0 ? '<div style="text-align:center;padding:20px;">Нет заметок</div>' : ''}
                            ${notes.map((note, idx) => `
                                <div class="note-item" style="border-radius:8px;margin-bottom:8px;padding:10px;">
                                    <div style="display:flex;justify-content:space-between;">
                                        <span style="font-weight:bold;">📝 ${escapeHtml(note.title)}</span>
                                        <div><button class="copy-note-btn" data-content="${escapeHtml(note.content)}" style="border:none;padding:4px 8px;border-radius:4px;cursor:pointer;margin-right:4px;">📋 Копировать</button><button class="delete-note-btn" data-index="${idx}" style="border:none;padding:4px 8px;border-radius:4px;cursor:pointer;">🗑️</button></div>
                                    </div>
                                    <div style="font-size:11px;margin-top:4px;color:#aaa;">${escapeHtml(note.content.substring(0, 80))}...</div>
                                </div>
                            `).join('')}
                        </div>
                    </div>

                    <div id="banlistTab" class="tab-content" style="display:none;">
                        <div style="display:flex;gap:8px;margin-bottom:12px;">
                            <input type="text" id="banlistNameInput" placeholder="Имя игрока" style="flex:1;padding:8px;border-radius:6px;border:1px solid;">
                            <input type="text" id="banlistIdInput" placeholder="ID" style="flex:1;padding:8px;border-radius:6px;border:1px solid;">
                            <button id="addToBanlistBtn" style="padding:8px 12px;border-radius:6px;border:none;cursor:pointer;">➕ Добавить</button>
                        </div>
                        <div id="banlistItems">
                            ${banlist.length === 0 ? '<div style="text-align:center;padding:20px;">Бан-лист пуст</div>' : ''}
                            ${banlist.map((item, idx) => `
                                <div class="banlist-item" style="border-radius:8px;margin-bottom:8px;padding:10px;">
                                    <div style="display:flex;justify-content:space-between;">
                                        <div><span style="font-weight:bold;">🔴 ${escapeHtml(item.name)}</span>${item.id ? `<span style="font-size:11px;"> (ID: ${item.id})</span>` : ''}<div style="font-size:10px;">${new Date(item.date).toLocaleDateString()}</div></div>
                                        <div><button class="copy-banlist-id" data-id="${item.id || item.name}" style="border:none;padding:4px 8px;border-radius:4px;cursor:pointer;margin-right:4px;">📋 Копировать</button><button class="remove-banlist-item" data-index="${idx}" style="border:none;padding:4px 8px;border-radius:4px;cursor:pointer;">❌</button></div>
                                    </div>
                                </div>
                            `).join('')}
                        </div>
                    </div>

                    <div id="variablesTab" class="tab-content" style="display:none;">
                        <div style="border-radius:8px;padding:12px;">
                            <h4 style="margin:0 0 12px 0;">📊 Переменные для шаблонов</h4>
                            <div style="margin-bottom:12px;">
                                <div style="font-size:12px;color:#aaa;margin-bottom:8px;">Используйте эти переменные в шаблонах:</div>
                                <div style="display:grid;grid-template-columns:1fr 1fr;gap:8px;">
                                    <div><code style="background:rgba(0,0,0,0.3);padding:4px;border-radius:4px;display:block;">\${user.name}</code><span style="font-size:10px;"> - Имя пользователя</span></div>
                                    <div><code style="background:rgba(0,0,0,0.3);padding:4px;border-radius:4px;display:block;">\${user.mention}</code><span style="font-size:10px;"> - Упоминание</span></div>
                                    <div><code style="background:rgba(0,0,0,0.3);padding:4px;border-radius:4px;display:block;">\${date}</code><span style="font-size:10px;"> - Текущая дата</span></div>
                                    <div><code style="background:rgba(0,0,0,0.3);padding:4px;border-radius:4px;display:block;">\${time}</code><span style="font-size:10px;"> - Текущее время</span></div>
                                    <div><code style="background:rgba(0,0,0,0.3);padding:4px;border-radius:4px;display:block;">\${warnCount}</code><span style="font-size:10px;"> - Кол-во предупреждений</span></div>
                                    <div><code style="background:rgba(0,0,0,0.3);padding:4px;border-radius:4px;display:block;">\${banCount}</code><span style="font-size:10px;"> - Кол-во банов</span></div>
                                    <div><code style="background:rgba(0,0,0,0.3);padding:4px;border-radius:4px;display:block;">\${adminName}</code><span style="font-size:10px;"> - Имя администратора</span></div>
                                    <div><code style="background:rgba(0,0,0,0.3);padding:4px;border-radius:4px;display:block;">\${serverName}</code><span style="font-size:10px;"> - Название сервера</span></div>
                                </div>
                            </div>
                            <h4 style="margin:12px 0 8px 0;">⚙️ Управление переменными</h4>
                            <div style="display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-bottom:12px;">
                                <div><label style="font-size:11px;">Кол-во предупреждений:</label><input type="number" id="varWarnCount" value="${userVariables.warnCount}" style="width:100%;padding:6px;border-radius:4px;border:1px solid;margin-top:4px;"></div>
                                <div><label style="font-size:11px;">Кол-во банов:</label><input type="number" id="varBanCount" value="${userVariables.banCount}" style="width:100%;padding:6px;border-radius:4px;border:1px solid;margin-top:4px;"></div>
                                <div><label style="font-size:11px;">Имя администратора:</label><input type="text" id="varAdminName" value="${escapeHtml(userVariables.adminName)}" placeholder="Администратор" style="width:100%;padding:6px;border-radius:4px;border:1px solid;margin-top:4px;"></div>
                                <div><label style="font-size:11px;">Название сервера:</label><input type="text" id="varServerName" value="${escapeHtml(userVariables.serverName)}" placeholder="Екатеринбург" style="width:100%;padding:6px;border-radius:4px;border:1px solid;margin-top:4px;"></div>
                            </div>
                            <button id="saveVariablesBtn" style="width:100%;padding:8px;border-radius:6px;border:none;cursor:pointer;">💾 Сохранить переменные</button>
                        </div>
                    </div>

                    <div id="statsTab" class="tab-content" style="display:none;">
                        <div style="border-radius:8px;padding:12px;text-align:center;">
                            <span style="font-size:24px;">📊</span>
                            <h4 style="margin:5px 0;">Статистика за сегодня</h4>
                            <div style="font-size:32px;font-weight:bold;">${todayStats.total}</div>
                            <div style="font-size:11px;">всего ответов</div>
                            ${Object.keys(todayStats.templates).length > 0 ? `<div style="margin-top:12px;text-align:left;max-height:200px;overflow-y:auto;">${Object.entries(todayStats.templates).slice(0, 10).map(([name, count]) => `<div style="display:flex;justify-content:space-between;font-size:11px;margin:4px 0;"><span>${name.substring(0, 35)}</span><span style="font-weight:bold;">${count}</span></div>`).join('')}</div>` : '<div style="padding:20px;">Нет статистики</div>'}
                            <button id="resetStatsBtn" style="width:100%;margin-top:12px;padding:8px;border-radius:6px;border:none;cursor:pointer;">Сбросить статистику</button>
                        </div>
                        <div style="margin-top:12px;border-radius:8px;padding:12px;">
                            <h4 style="margin:0 0 8px 0;">📜 История использованных шаблонов</h4>
                            ${history.length === 0 ? '<div style="padding:20px;text-align:center;">Нет истории</div>' : history.slice(0, 10).map(item => `<div style="font-size:11px;margin:4px 0;">• ${item.name} — ${new Date(item.date).toLocaleString()}</div>`).join('')}
                        </div>
                    </div>

                    <div id="settingsTab" class="tab-content" style="display:none;">
                        <div style="border-radius:8px;padding:12px;">
                            <h4 style="margin:0 0 12px 0;">🎨 Стиль оформления (${Object.keys(PRESET_THEMES).length}+ стилей)</h4>
                            <div style="margin-bottom:12px;">
                                <select id="themeSelect" style="width:100%;padding:8px;border-radius:6px;border:1px solid;">
                                    <option value="custom" ${settings.useCustomStyle ? 'selected' : ''}>✨ Свой стиль</option>
                                    ${Object.entries(PRESET_THEMES).map(([key, theme]) => `<option value="${key}" ${!settings.useCustomStyle && settings.theme === key ? 'selected' : ''}>${theme.name}</option>`).join('')}
                                </select>
                            </div>

                            <div id="customStylePanel" style="display: ${settings.useCustomStyle ? 'block' : 'none'}; margin-bottom:12px; padding:10px; border-radius:8px; border:1px solid;">
                                <h5 style="margin:0 0 8px 0;">🎨 Расширенная палитра цветов</h5>

                                <div style="margin-bottom:12px;">
                                    <div style="font-size:12px;margin-bottom:4px;">🌈 Градиенты:</div>
                                    <div class="color-palette" style="display:flex;gap:6px;flex-wrap:wrap;margin-bottom:8px;">
                                        ${COLOR_PALETTE.gradient.map((g, i) => `<div class="gradient-option" data-target="customMainBg" style="width:60px;height:40px;border-radius:8px;background:${g};cursor:pointer;border:2px solid transparent;" data-color="${g}"></div>`).join('')}
                                    </div>
                                </div>

                                <div style="margin-bottom:12px;">
                                    <div style="font-size:12px;margin-bottom:4px;">🌑 Тёмные:</div>
                                    <div class="color-palette" style="display:flex;gap:6px;flex-wrap:wrap;margin-bottom:8px;">
                                        ${COLOR_PALETTE.dark.map(c => `<div class="color-option" data-target="customMainBg" style="width:35px;height:35px;border-radius:6px;background:${c};cursor:pointer;border:2px solid transparent;" data-color="${c}"></div>`).join('')}
                                    </div>
                                </div>

                                <div style="margin-bottom:12px;">
                                    <div style="font-size:12px;margin-bottom:4px;">☀️ Светлые:</div>
                                    <div class="color-palette" style="display:flex;gap:6px;flex-wrap:wrap;margin-bottom:8px;">
                                        ${COLOR_PALETTE.light.map(c => `<div class="color-option" data-target="customMainBg" style="width:35px;height:35px;border-radius:6px;background:${c};cursor:pointer;border:2px solid transparent;" data-color="${c}"></div>`).join('')}
                                    </div>
                                </div>

                                <div style="margin-bottom:12px;">
                                    <div style="font-size:12px;margin-bottom:4px;">🎨 Акцентные:</div>
                                    <div class="color-palette" style="display:flex;gap:6px;flex-wrap:wrap;margin-bottom:8px;">
                                        ${COLOR_PALETTE.accent.map(c => `<div class="color-option" data-target="customAccentColor" style="width:35px;height:35px;border-radius:6px;background:${c};cursor:pointer;border:2px solid transparent;" data-color="${c}"></div>`).join('')}
                                    </div>
                                </div>

                                <div style="margin-bottom:12px;">
                                    <div style="font-size:12px;margin-bottom:4px;">🎀 Пастельные:</div>
                                    <div class="color-palette" style="display:flex;gap:6px;flex-wrap:wrap;margin-bottom:8px;">
                                        ${COLOR_PALETTE.pastel.map(c => `<div class="color-option" data-target="customMainBg" style="width:35px;height:35px;border-radius:6px;background:${c};cursor:pointer;border:2px solid transparent;" data-color="${c}"></div>`).join('')}
                                    </div>
                                </div>

                                <hr style="margin:12px 0; border-color:rgba(255,255,255,0.1);">

                                <div style="margin-bottom:12px;">
                                    <div style="font-size:12px;margin-bottom:4px;">🎨 Фон окна (цвет или градиент):</div>
                                    <input type="text" id="customMainBg" placeholder="linear-gradient(135deg, #1a1a2e, #16213e)" value="${settings.customStyle?.mainBg || ''}" style="width:100%;padding:6px;border-radius:4px;border:1px solid;margin-bottom:8px;">
                                </div>
                                <div style="margin-bottom:12px;">
                                    <div style="font-size:12px;margin-bottom:4px;">📦 Цвет карточек:</div>
                                    <input type="text" id="customCardBg" placeholder="#0f0f1a" value="${settings.customStyle?.cardBg || ''}" style="width:100%;padding:6px;border-radius:4px;border:1px solid;margin-bottom:8px;">
                                </div>
                                <div style="margin-bottom:12px;">
                                    <div style="font-size:12px;margin-bottom:4px;">✏️ Цвет текста:</div>
                                    <input type="text" id="customTextColor" placeholder="#ecf0f1" value="${settings.customStyle?.textColor || ''}" style="width:100%;padding:6px;border-radius:4px;border:1px solid;margin-bottom:8px;">
                                </div>
                                <div style="margin-bottom:12px;">
                                    <div style="font-size:12px;margin-bottom:4px;">💜 Акцентный цвет:</div>
                                    <input type="text" id="customAccentColor" placeholder="#9b59b6" value="${settings.customStyle?.accentColor || ''}" style="width:100%;padding:6px;border-radius:4px;border:1px solid;margin-bottom:8px;">
                                </div>
                                <button id="applyCustomStyleBtn" style="width:100%;padding:10px;border-radius:6px;border:none;cursor:pointer;font-weight:bold;">✨ Применить свой стиль</button>
                                <button id="resetCustomStyleBtn" style="width:100%;margin-top:8px;padding:10px;border-radius:6px;border:1px solid;background:none;cursor:pointer;">🔄 Сбросить на стандартный</button>
                            </div>

                            <h4 style="margin:12px 0 12px 0;">🔍 Расширенный поиск</h4>
                            <div style="margin-bottom:12px;">
                                <div style="display:flex;gap:8px;margin-bottom:8px;">
                                    <select id="sortBySelect" style="flex:1;padding:8px;border-radius:6px;border:1px solid;">
                                        <option value="default">📌 По умолчанию</option>
                                        <option value="alphabet">🔤 По алфавиту (А-Я)</option>
                                        <option value="alphabet-desc">🔤 По алфавиту (Я-А)</option>
                                        <option value="date-asc">📅 Сначала старые</option>
                                        <option value="date-desc">📅 Сначала новые</option>
                                    </select>
                                    <select id="dateFilterSelect" style="flex:1;padding:8px;border-radius:6px;border:1px solid;">
                                        <option value="all">📅 Все время</option>
                                        <option value="week">📆 За неделю</option>
                                        <option value="month">📅 За месяц</option>
                                        <option value="old">🕰️ Старые (>30 дней)</option>
                                    </select>
                                </div>
                                <div style="font-size:11px;color:#aaa;margin-top:4px;">
                                    💡 Подсказка: можно искать по названию, категории и ключевым словам
                                </div>
                            </div>

                            <h4 style="margin:12px 0 12px 0;">⚙️ Основные</h4>
                            <div style="display:flex;justify-content:space-between;margin-bottom:12px;">
                                <span>🎨 Верхняя панель</span>
                                <label class="switch"><input type="checkbox" id="topBarToggle" ${settings.topBarEnabled ? 'checked' : ''}><span class="slider"></span></label>
                            </div>
                            <div style="display:flex;justify-content:space-between;margin-bottom:12px;">
                                <span>🔊 Звук уведомлений</span>
                                <label class="switch"><input type="checkbox" id="soundToggle" ${settings.soundEnabled !== false ? 'checked' : ''}><span class="slider"></span></label>
                            </div>
                            <div style="display:flex;justify-content:space-between;margin-bottom:12px;">
                                <span>🔄 Авто-перезагрузка</span>
                                <label class="switch"><input type="checkbox" id="autoReloadToggle" ${settings.autoReload ? 'checked' : ''}><span class="slider"></span></label>
                            </div>
                            <div style="display:flex;justify-content:space-between;margin-bottom:12px;">
                                <span>💾 Авто-сохранение</span>
                                <label class="switch"><input type="checkbox" id="autoSaveToggle" ${settings.autoSaveDrafts !== false ? 'checked' : ''}><span class="slider"></span></label>
                            </div>
                            <div style="display:flex;justify-content:space-between;margin-bottom:12px;">
                                <span>💬 Цитата дня</span>
                                <label class="switch"><input type="checkbox" id="showQuotesToggle" ${settings.showQuotes !== false ? 'checked' : ''}><span class="slider"></span></label>
                            </div>

                            <button id="loadDraftBtn" style="width:100%;padding:8px;border-radius:6px;border:none;cursor:pointer;margin-top:8px;">📂 Загрузить черновик</button>
                            <button id="clearDraftBtn" style="width:100%;padding:8px;border-radius:6px;border:none;cursor:pointer;margin-top:8px;">🗑️ Очистить черновик</button>
                            <button id="resetTemplatesBtn" style="width:100%;padding:8px;border-radius:6px;border:1px solid;background:none;cursor:pointer;margin-top:12px;">🗑️ Сбросить свои шаблоны</button>
                            <button id="exportAllDataBtn" style="width:100%;padding:8px;border-radius:6px;border:1px solid;background:none;cursor:pointer;margin-top:8px;">💾 Экспорт всех данных</button>
                            <button id="importAllDataBtn" style="width:100%;padding:8px;border-radius:6px;border:1px solid;background:none;cursor:pointer;margin-top:8px;">📥 Импорт данных</button>
                        </div>
                    </div>
                </div>
            </div>
        `;

        $('body').append(windowHtml);
        isWindowOpen = true;

        applyCustomStyle(getCurrentTheme());

        if (settings.showQuotes !== false) {
            setTimeout(() => { showNotification(`💬 ${getRandomQuote()}`, 'info'); }, 500);
        }

        // Перетаскивание
        let isDragging = false, dragOffsetX, dragOffsetY;
        $('#windowHeader').on('mousedown', function(e) {
            if (e.target.closest('#minimizeWindowBtn') || e.target.closest('#closeWindowBtn') || e.target.closest('#quoteOfDayBtn')) return;
            isDragging = true;
            dragOffsetX = e.clientX - $('#compactScriptWindow').offset().left;
            dragOffsetY = e.clientY - $('#compactScriptWindow').offset().top;
            $('#compactScriptWindow').css('cursor', 'grabbing');
        });
        $(document).on('mousemove', function(e) {
            if (!isDragging) return;
            let newLeft = e.clientX - dragOffsetX;
            let newTop = e.clientY - dragOffsetY;
            newLeft = Math.max(0, Math.min(newLeft, $(window).width() - $('#compactScriptWindow').outerWidth()));
            newTop = Math.max(0, Math.min(newTop, $(window).height() - $('#compactScriptWindow').outerHeight()));
            $('#compactScriptWindow').css({ left: newLeft, right: 'auto', top: newTop });
        });
        $(document).on('mouseup', function() { isDragging = false; $('#compactScriptWindow').css('cursor', ''); });

        $('#closeWindowBtn').click(() => toggleCompactWindow());
        $('#quoteOfDayBtn').click(() => showNotification(`💬 ${getRandomQuote()}`, 'info'));

        let isMinimized = false;
        $('#minimizeWindowBtn').click(function() {
            if (!isMinimized) {
                $('#compactScriptWindow .tab-content, #compactScriptWindow > div:not(#windowHeader)').hide();
                $('#compactScriptWindow').css({ width: 'auto', minWidth: '200px' });
                $(this).text('🔽');
                isMinimized = true;
            } else {
                $('#compactScriptWindow .tab-content, #compactScriptWindow > div:not(#windowHeader)').show();
                $('#compactScriptWindow').css({ width: '560px', minWidth: '' });
                $(this).text('➖');
                isMinimized = false;
            }
        });

        $('.tab-btn').click(function() {
            $('.tab-btn').removeClass('active').css('border-bottom', 'none');
            $(this).addClass('active');
            const theme = getCurrentTheme();
            $(this).css('border-bottom', `2px solid ${theme.accentColor}`);
            const tab = $(this).data('tab');
            $('.tab-content').hide();
            $(`#${tab}Tab`).show();
            if (tab === 'favorites') updateFavoritesList();
            filterTemplates();
        });

        $('#categoryFilterSelect').on('change', filterTemplates);
        $('#templateSearchInput').on('input', filterTemplates);
        $('#sortBySelect, #dateFilterSelect').on('change', filterTemplates);

        $('#quickClearEditorBtn').click(() => {
            $('div.fr-element.fr-view').html('');
            showNotification('🗑️ Редактор очищен', 'success');
        });

        $('#quickClosedBtn').click(() => editThreadDataAndReload(PIN_PREFIX, true, false));
        $('#quickUnacceptBtn').click(() => editThreadDataAndReload(UNACCEPT_PREFIX, false, false));
        $('#quickConsiderBtn').click(() => editThreadDataAndReload(CLOSED_PREFIX, false, false));
        $('#quickAcceptBtn').click(() => editThreadDataAndReload(ACCEPT_PREFIX, false, false));
        $('#quickCopyLinkBtn').click(() => copyToClipboard(window.location.href, '✅ Ссылка скопирована!'));
        $('#quickRefreshBtn').click(() => location.reload());
        $('#quickCopyIDBtn').click(() => {
            const threadId = window.location.pathname.split('/').pop();
            copyToClipboard(threadId, '🆔 ID темы скопирован!');
        });
        $('#quickMentionBtn').click(() => {
            pasteContent(user.mention);
            showNotification('👤 Упоминание добавлено', 'success');
        });

        $(document).on('click', '.favorite-star', function(e) {
            e.stopPropagation();
            const templateId = $(this).data('template-id');
            toggleFavorite(templateId);
            $(this).text(isFavorite(templateId) ? '★' : '☆');
            updateFavoritesList();
        });

        async function handleTemplate(template, prefix, title) {
            updateStats(title);
            const processedContent = processTemplateContent(template.content);
            pasteContent(processedContent);
            if (prefix !== undefined) await editThreadDataAsync(prefix, false);
            if (template.close) await closeThreadAsync();
            $('.button--icon.button--icon--reply.rippleButton').trigger('click');
            if (loadSettings().autoReload) setTimeout(() => location.reload(), 1000);
            else toggleCompactWindow();
        }

        $('.template-item-btn[data-template-type="all"]').click(async function() {
            const idx = $(this).data('template-index');
            const template = allTemplates[idx];
            if (template) await handleTemplate(template, template.prefix, template.title);
        });

        function updateFavoritesList() {
            const favorites = loadFavorites();
            const favTemplates = favorites.map(id => {
                if (id.startsWith('all_')) {
                    const idx = parseInt(id.split('_')[1]);
                    return allTemplates[idx] ? { ...allTemplates[idx], index: idx } : null;
                }
                return null;
            }).filter(t => t);

            const container = $('#favoritesList');
            if (favTemplates.length === 0) {
                container.html('<div style="text-align:center;padding:20px;">⭐ Нет избранных шаблонов</div>');
            } else {
                container.html(favTemplates.map(tpl => `
                    <button class="template-item-btn" data-template-type="all" data-template-index="${tpl.index}" data-category="${tpl.category}" style="display:block;width:100%;text-align:left;padding:10px 12px;margin:6px 0;border-radius:8px;border-left:3px solid;cursor:pointer;">
                        ⭐ ${tpl.title}
                    </button>
                `).join(''));
                $('#favoritesTab .template-item-btn').click(async function() {
                    const idx = $(this).data('template-index');
                    const template = allTemplates[idx];
                    if (template) await handleTemplate(template, template.prefix, template.title);
                });
            }
        }

        $('#createTemplateBtn').click(() => { toggleCompactWindow(); showTemplateEditor(); });
        $('.edit-custom-btn').click(function() {
            const idx = $(this).data('index');
            const templates = loadCustomTemplates();
            toggleCompactWindow();
            showTemplateEditor(templates[idx], idx);
        });
        $('.delete-custom-btn').click(function() {
            const idx = $(this).data('index');
            if (confirm('Удалить шаблон?')) { deleteCustomTemplate(idx); toggleCompactWindow(); showCompactWindow(); }
        });
        $('.use-custom-btn').click(async function() {
            const idx = $(this).data('index');
            const templates = loadCustomTemplates();
            const template = templates[idx];
            if (template) await handleTemplate(template, template.prefix, template.title);
        });

        $('#addQuickReplyBtn').click(() => { toggleCompactWindow(); showQuickReplyEditor(); });
        $('.edit-quick-reply').click(function() {
            const idx = $(this).data('index');
            const replies = loadQuickReplies();
            toggleCompactWindow();
            showQuickReplyEditor(replies[idx], idx);
        });
        $('.delete-quick-reply').click(function() {
            const idx = $(this).data('index');
            if (confirm('Удалить быстрый ответ?')) {
                const replies = loadQuickReplies();
                replies.splice(idx, 1);
                saveQuickReplies(replies);
                toggleCompactWindow();
                showCompactWindow();
            }
        });
        $('.use-quick-reply').click(function() {
            const idx = $(this).data('index');
            const replies = loadQuickReplies();
            const reply = replies[idx];
            if (reply) {
                pasteContent(processTemplateContent(reply.content));
                showNotification(`⚡ Быстрый ответ вставлен`, 'success');
                toggleCompactWindow();
            }
        });

        $('#addMacroBtn').click(() => {
            const name = $('#macroNameInput').val().trim();
            const content = $('#macroContentInput').val().trim();
            if (name && content) {
                addMacro(name, content);
                $('#macroNameInput').val('');
                $('#macroContentInput').val('');
                toggleCompactWindow();
                showCompactWindow();
                showNotification(`✅ Макрос "${name}" добавлен`, 'success');
            } else {
                showNotification('❌ Введите название и текст макроса', 'error');
            }
        });
        $(document).on('click', '.use-macro-btn', function() {
            const idx = $(this).data('index');
            const macros = loadMacros();
            const macro = macros[idx];
            if (macro) {
                pasteContent(macro.content);
                showNotification(`🔧 Макрос "${macro.name}" вставлен`, 'success');
                toggleCompactWindow();
            }
        });
        $(document).on('click', '.delete-macro-btn', function() {
            const idx = $(this).data('index');
            if (confirm('Удалить макрос?')) {
                deleteMacro(idx);
                toggleCompactWindow();
                showCompactWindow();
            }
        });

        $('#addTaskBtn').click(() => {
            const title = $('#taskInput').val().trim();
            const priority = $('#taskPriority').val();
            if (title) {
                addTask(title, priority);
                $('#taskInput').val('');
                toggleCompactWindow();
                showCompactWindow();
                showNotification(`✅ Задача "${title}" добавлена`, 'success');
            } else {
                showNotification('❌ Введите задачу', 'error');
            }
        });
        $(document).on('click', '.toggle-task-btn', function() {
            const id = parseInt($(this).data('id'));
            toggleTask(id);
            toggleCompactWindow();
            showCompactWindow();
        });
        $(document).on('click', '.delete-task-btn', function() {
            const id = parseInt($(this).data('id'));
            if (confirm('Удалить задачу?')) {
                deleteTask(id);
                toggleCompactWindow();
                showCompactWindow();
            }
        });

        $('#addNoteBtn').click(() => {
            const title = $('#noteTitleInput').val().trim();
            const content = $('#noteContentInput').val().trim();
            if (title && content) {
                addNote(title, content);
                $('#noteTitleInput').val('');
                $('#noteContentInput').val('');
                toggleCompactWindow();
                showCompactWindow();
                showNotification(`📝 Заметка "${title}" добавлена`, 'success');
            } else {
                showNotification('❌ Введите заголовок и текст заметки', 'error');
            }
        });
        $(document).on('click', '.copy-note-btn', function() {
            const content = $(this).data('content');
            copyToClipboard(content, '📝 Текст заметки скопирован!');
        });
        $(document).on('click', '.delete-note-btn', function() {
            const idx = $(this).data('index');
            if (confirm('Удалить заметку?')) {
                deleteNote(idx);
                toggleCompactWindow();
                showCompactWindow();
            }
        });

        $('#addToBanlistBtn').click(() => {
            const name = $('#banlistNameInput').val().trim();
            const id = $('#banlistIdInput').val().trim();
            if (name) {
                addToBanlist(id || name, name, '');
                $('#banlistNameInput').val('');
                $('#banlistIdInput').val('');
                toggleCompactWindow();
                showCompactWindow();
            } else {
                showNotification('❌ Введите имя игрока', 'error');
            }
        });
        $(document).on('click', '.copy-banlist-id', function() {
            const id = $(this).data('id');
            copyToClipboard(id, `✅ "${id}" скопирован!`);
        });
        $(document).on('click', '.remove-banlist-item', function() {
            const idx = $(this).data('index');
            if (confirm('Удалить из бан-листа?')) {
                removeFromBanlist(idx);
                toggleCompactWindow();
                showCompactWindow();
            }
        });

        $('#saveVariablesBtn').click(() => {
            updateUserVariable('warnCount', parseInt($('#varWarnCount').val()) || 0);
            updateUserVariable('banCount', parseInt($('#varBanCount').val()) || 0);
            updateUserVariable('adminName', $('#varAdminName').val().trim());
            updateUserVariable('serverName', $('#varServerName').val().trim());
            showNotification('💾 Переменные сохранены!', 'success');
        });

        $('.color-option, .gradient-option').click(function() {
            const color = $(this).data('color');
            const target = $(this).data('target');
            if (target) {
                $(`#${target}`).val(color);
            }
            $(this).css('border', `2px solid white`);
            setTimeout(() => $(this).css('border', '2px solid transparent'), 300);
        });

        $('#resetStatsBtn').click(() => { if (confirm('Сбросить статистику?')) { saveStats({}); toggleCompactWindow(); showCompactWindow(); } });

        $('#themeSelect').change(function() {
            const settings = loadSettings();
            const value = $(this).val();
            if (value === 'custom') {
                settings.useCustomStyle = true;
                $('#customStylePanel').slideDown();
            } else {
                settings.useCustomStyle = false;
                settings.theme = value;
                $('#customStylePanel').slideUp();
            }
            saveSettings(settings);
            applyCustomStyle(getCurrentTheme());
            showTopBar();
        });

        $('#applyCustomStyleBtn').click(() => {
            const customStyle = {
                mainBg: $('#customMainBg').val(),
                cardBg: $('#customCardBg').val(),
                textColor: $('#customTextColor').val(),
                accentColor: $('#customAccentColor').val(),
                deniedColor: $('#customDeniedColor')?.val() || '#e74c3c',
                pendingColor: $('#customPendingColor')?.val() || '#f39c12',
                approvedColor: $('#customApprovedColor')?.val() || '#2ecc71',
                techColor: $('#customTechColor')?.val() || '#1abc9c',
                headerBg: `linear-gradient(135deg, ${$('#customAccentColor').val() || '#9b59b6'}, ${$('#customAccentColor').val() || '#6a3ad5'})`,
                borderColor: 'rgba(155,89,182,0.3)'
            };
            const settings = loadSettings();
            settings.customStyle = customStyle;
            saveSettings(settings);
            applyCustomStyle(customStyle);
            showNotification('✨ Свой стиль применён!', 'success');
        });

        $('#resetCustomStyleBtn').click(() => {
            const defaultStyle = {
                mainBg: 'linear-gradient(135deg, #1a1a2e, #16213e)',
                cardBg: '#0f0f1a',
                textColor: '#ecf0f1',
                accentColor: '#9b59b6',
                deniedColor: '#e74c3c',
                pendingColor: '#f39c12',
                approvedColor: '#2ecc71',
                techColor: '#1abc9c'
            };
            $('#customMainBg').val(defaultStyle.mainBg);
            $('#customCardBg').val(defaultStyle.cardBg);
            $('#customTextColor').val(defaultStyle.textColor);
            $('#customAccentColor').val(defaultStyle.accentColor);
            showNotification('🔄 Стиль сброшен на стандартный', 'info');
        });

        $('#topBarToggle').change(function() {
            const settings = loadSettings();
            settings.topBarEnabled = $(this).is(':checked');
            saveSettings(settings);
            if (settings.topBarEnabled) showTopBar(); else $('#topBarScript').remove();
        });

        $('#soundToggle').change(function() {
            const settings = loadSettings();
            settings.soundEnabled = $(this).is(':checked');
            saveSettings(settings);
        });

        $('#autoReloadToggle').change(function() {
            const settings = loadSettings();
            settings.autoReload = $(this).is(':checked');
            saveSettings(settings);
        });

        $('#autoSaveToggle').change(function() {
            const settings = loadSettings();
            settings.autoSaveDrafts = $(this).is(':checked');
            saveSettings(settings);
        });

        $('#showQuotesToggle').change(function() {
            const settings = loadSettings();
            settings.showQuotes = $(this).is(':checked');
            saveSettings(settings);
        });

        $('#loadDraftBtn').click(() => {
            const draft = loadDraft();
            if (draft) { pasteContent(draft); showNotification('📂 Черновик загружен', 'success'); toggleCompactWindow(); }
            else showNotification('❌ Нет черновика', 'error');
        });

        $('#clearDraftBtn').click(() => { clearDraft(); showNotification('🗑️ Черновик очищен', 'success'); });

        $('#resetTemplatesBtn').click(() => { if (confirm('Удалить все свои шаблоны?')) { saveCustomTemplates([]); toggleCompactWindow(); showCompactWindow(); } });

        $('#exportAllDataBtn').click(() => {
            const exportData = {
                templates: loadCustomTemplates(),
                quickReplies: loadQuickReplies(),
                macros: loadMacros(),
                notes: loadNotes(),
                tasks: loadTasks(),
                banlist: loadBanlist(),
                settings: loadSettings(),
                variables: userVariables
            };
            const dataStr = JSON.stringify(exportData, null, 2);
            const blob = new Blob([dataStr], {type: 'application/json'});
            const url = URL.createObjectURL(blob);
            const a = document.createElement('a');
            a.href = url;
            a.download = `rage_script_backup_${Date.now()}.json`;
            a.click();
            URL.revokeObjectURL(url);
            showNotification('💾 Все данные экспортированы!', 'success');
        });

        $('#importAllDataBtn').click(() => {
            const input = document.createElement('input');
            input.type = 'file';
            input.accept = 'application/json';
            input.onchange = (e) => {
                const file = e.target.files[0];
                const reader = new FileReader();
                reader.onload = (event) => {
                    try {
                        const imported = JSON.parse(event.target.result);
                        if (imported.templates) saveCustomTemplates(imported.templates);
                        if (imported.quickReplies) saveQuickReplies(imported.quickReplies);
                        if (imported.macros) saveMacros(imported.macros);
                        if (imported.notes) saveNotes(imported.notes);
                        if (imported.tasks) saveTasks(imported.tasks);
                        if (imported.banlist) saveBanlist(imported.banlist);
                        if (imported.variables) {
                            userVariables = { ...userVariables, ...imported.variables };
                            saveUserVariables();
                        }
                        showNotification(`✅ Импортировано!`, 'success');
                        toggleCompactWindow();
                        showCompactWindow();
                    } catch(e) { showNotification('❌ Ошибка импорта', 'error'); }
                };
                reader.readAsText(file);
            };
            input.click();
        });

        filterTemplates();
    }

    function showQuickReplyEditor(reply = null, index = -1) {
        const isEdit = reply !== null;
        const modalHtml = `
            <div class="quick-reply-editor-overlay" style="position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.85);z-index:10001;display:flex;align-items:center;justify-content:center;">
                <div style="background:#1a1a2e;border-radius:16px;width:90%;max-width:500px;padding:20px;border:1px solid #9b59b6;">
                    <h3 style="margin:0 0 15px 0;color:white;">${isEdit ? '✏️ Редактировать' : '➕ Добавить быстрый ответ'}</h3>
                    <input type="text" id="quickReplyTitle" placeholder="Название" value="${isEdit ? escapeHtml(reply.title) : ''}" style="width:100%;padding:10px;margin-bottom:12px;border-radius:8px;border:1px solid #9b59b6;background:#0f0f1a;color:white;box-sizing:border-box;">
                    <textarea id="quickReplyContent" placeholder="Содержание (BB-код)" rows="6" style="width:100%;padding:10px;margin-bottom:12px;border-radius:8px;border:1px solid #9b59b6;background:#0f0f1a;color:white;font-family:monospace;box-sizing:border-box;">${isEdit ? escapeHtml(reply.content) : ''}</textarea>
                    <div style="display:flex;gap:10px;justify-content:flex-end;">
                        <button id="cancelQuickReplyBtn" style="padding:8px 20px;border-radius:8px;border:none;background:#7f8c8d;color:white;cursor:pointer;">Отмена</button>
                        <button id="saveQuickReplyBtn" style="padding:8px 20px;border-radius:8px;border:none;background:#9b59b6;color:white;cursor:pointer;">${isEdit ? 'Сохранить' : 'Добавить'}</button>
                    </div>
                </div>
            </div>
        `;
        $('body').append(modalHtml);
        const $overlay = $('.quick-reply-editor-overlay');
        $('#cancelQuickReplyBtn').click(() => $overlay.remove());
        $('#saveQuickReplyBtn').click(() => {
            const title = $('#quickReplyTitle').val().trim();
            const content = $('#quickReplyContent').val();
            if (!title) { alert('Введите название!'); return; }
            if (!content) { alert('Введите содержание!'); return; }
            const replies = loadQuickReplies();
            if (isEdit) replies[index] = { title, content };
            else replies.push({ title, content });
            saveQuickReplies(replies);
            $overlay.remove();
            showCompactWindow();
        });
        $overlay.click((e) => { if ($(e.target).is('.quick-reply-editor-overlay')) $overlay.remove(); });
    }

    function showTemplateEditor(template = null, index = -1) {
        const isEdit = template !== null;
        const modalHtml = `
            <div class="template-editor-overlay" style="position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.85);z-index:10001;display:flex;align-items:center;justify-content:center;">
                <div style="background:#1a1a2e;border-radius:16px;width:90%;max-width:550px;padding:20px;border:1px solid #9b59b6;">
                    <h3 style="margin:0 0 15px 0;color:white;">${isEdit ? '✏️ Редактировать шаблон' : '➕ Создать шаблон'}</h3>
                    <input type="text" id="editorTitle" placeholder="Название" value="${isEdit ? escapeHtml(template.title) : ''}" style="width:100%;padding:10px;margin-bottom:12px;border-radius:8px;border:1px solid #9b59b6;background:#0f0f1a;color:white;box-sizing:border-box;">
                    <textarea id="editorContent" placeholder="Содержание (BB-код)" rows="8" style="width:100%;padding:10px;margin-bottom:12px;border-radius:8px;border:1px solid #9b59b6;background:#0f0f1a;color:white;font-family:monospace;box-sizing:border-box;">${isEdit ? escapeHtml(template.content) : ''}</textarea>
                    <div style="margin-bottom:12px;">
                        <div style="font-size:11px;color:#aaa;">📋 Доступные переменные: \${user.name}, \${date}, \${time}, \${warnCount}, \${banCount}</div>
                    </div>
                    <select id="editorPrefix" style="width:100%;padding:10px;margin-bottom:12px;border-radius:8px;border:1px solid #9b59b6;background:#0f0f1a;color:white;">
                        <option value="2" ${isEdit && template.prefix == 2 ? 'selected' : ''}>Рассмотрено</option>
                        <option value="3" ${isEdit && template.prefix == 3 ? 'selected' : ''}>Отказано</option>
                        <option value="4" ${isEdit && template.prefix == 4 ? 'selected' : ''}>На рассмотрении</option>
                    </select>
                    <label style="display:flex;align-items:center;gap:8px;margin-bottom:12px;color:white;">
                        <input type="checkbox" id="editorClose" ${isEdit && template.close ? 'checked' : ''}> Закрыть тему после ответа
                    </label>
                    <div style="display:flex;gap:10px;justify-content:flex-end;">
                        <button id="cancelEditorBtn" style="padding:8px 20px;border-radius:8px;border:none;background:#7f8c8d;color:white;cursor:pointer;">Отмена</button>
                        <button id="saveEditorBtn" style="padding:8px 20px;border-radius:8px;border:none;background:#9b59b6;color:white;cursor:pointer;">${isEdit ? 'Сохранить' : 'Создать'}</button>
                    </div>
                </div>
            </div>
        `;
        $('body').append(modalHtml);
        const $overlay = $('.template-editor-overlay');

        $('#cancelEditorBtn').click(() => $overlay.remove());
        $('#saveEditorBtn').click(() => {
            const title = $('#editorTitle').val().trim();
            const content = $('#editorContent').val();
            const prefix = parseInt($('#editorPrefix').val());
            const close = $('#editorClose').is(':checked');
            if (!title) { alert('Введите название!'); return; }
            if (!content) { alert('Введите содержание!'); return; }
            if (isEdit) updateCustomTemplate(index, title, content, prefix, close, '', 'complaints');
            else addCustomTemplate(title, content, prefix, close, '', 'complaints');
            $overlay.remove();
            showCompactWindow();
        });
        $overlay.click((e) => { if ($(e.target).is('.template-editor-overlay')) $overlay.remove(); });
    }

  
    $(document).ready(() => {
        $('head').append(`
            <style>
                .switch { position:relative; display:inline-block; width:50px; height:24px; }
                .switch input { opacity:0; width:0; height:0; }
                .slider { position:absolute; cursor:pointer; top:0; left:0; right:0; bottom:0; background-color:#ccc; transition:0.3s; border-radius:24px; }
                .slider:before { position:absolute; content:""; height:18px; width:18px; left:3px; bottom:3px; background-color:white; transition:0.3s; border-radius:50%; }
                input:checked + .slider { background-color:#9b59b6; }
                input:checked + .slider:before { transform:translateX(26px); }
                .template-item-btn:hover, .custom-template-item:hover, .quick-reply-item:hover { transform:translateY(-2px); filter:brightness(1.05); }
                .favorite-star:hover { transform:scale(1.1); }
                .color-option:hover, .gradient-option:hover { transform:scale(1.05); border-color:white !important; }
                @keyframes slideIn { from { transform:translateX(100%); opacity:0; } to { transform:translateX(0); opacity:1; } }
                .tab-btn { transition: all 0.2s; }
                .tab-btn:hover { opacity:0.8; }
                code { font-family: monospace; font-size: 11px; }
                #searchStats { font-size: 11px; padding: 4px 8px; background: rgba(0,0,0,0.1); border-radius: 6px; }
            </style>
        `);
        if (loadSettings().topBarEnabled) showTopBar();
        $('body').append(`<div id="floatingScriptBtn" style="position:fixed;bottom:20px;right:20px;width:45px;height:45px;border-radius:50%;background:linear-gradient(135deg,#9b59b6,#6a3ad5);border:2px solid rgba(255,255,255,0.3);color:white;font-size:22px;cursor:pointer;z-index:9998;display:flex;align-items:center;justify-content:center;box-shadow:0 4px 15px rgba(0,0,0,0.3);">✨</div>`);
        $('#floatingScriptBtn').click(() => showCompactWindow());
        const draft = loadDraft();
        if (draft && loadSettings().autoSaveDrafts !== false) {
            setTimeout(() => { if (confirm('📝 Найден черновик. Загрузить?')) { pasteContent(draft); showNotification('📂 Черновик загружен', 'success'); } }, 1000);
        }
    });
})();