FORUM SCRIPT EKB 03 | HELP

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         FORUM SCRIPT EKB 03 | HELP
// @namespace    http://tampermonkey.net/
// @version      3
// @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 data = await getThreadData();
    const user = data.user;

    const complaintButtons = [
        {
            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,
            status: false,
            close: false,
            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,
            status: false,
            close: false,
            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,
            status: false,
            close: false,
            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,
            status: false,
            close: false,
            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,
            status: false,
            close: false,
            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,
            status: false,
            close: false,
            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,
            status: false,
            close: false,
            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,
            status: false,
            close: false,
            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,
            status: false,
            close: false,
            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,
            status: false,
            close: false,
            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,
            status: false,
            close: false,
            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,
            status: false,
            close: false,
            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,
            status: false,
            close: false,
            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,
            status: false,
            close: false,
            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,
            status: false,
            close: false,
            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,
            status: false,
            close: false,
            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,
            status: false,
            close: false,
            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,
            status: false,
            close: false,
            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,
            status: false,
            close: false,
            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,
            status: false,
            close: false,
            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,
            status: false,
            close: false,
            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,
            status: false,
            close: false,
            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,
            status: false,
            close: false,
            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,
            status: false,
            close: false,
            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,
            status: false,
            close: false,
            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,
            status: false,
            close: false,
            category: 'complaints'
        },
    ];

    const requestButtons = [
        {
            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,
            status: false,
            close: false,
            category: 'complaints'
        },
    ];

    const allButtons = [...complaintButtons, ...requestButtons];

    $(document).ready(() => {
        
        $('head').append(`
            <style>
                .floating-btn-container {
                    position: fixed;
                    bottom: 30px;
                    right: 30px;
                    z-index: 9999;
                }
                .floating-btn-main {
                    width: 56px;
                    height: 56px;
                    border-radius: 50%;
                    background: linear-gradient(135deg, #6a3ad5, #9b59b6);
                    border: none;
                    color: white;
                    font-size: 20px;
                    cursor: pointer;
                    box-shadow: 0 4px 15px rgba(106, 58, 213, 0.5);
                    transition: all 0.3s ease;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    position: relative;
                }
                .floating-btn-main:hover {
                    transform: scale(1.1);
                    box-shadow: 0 6px 20px rgba(106, 58, 213, 0.7);
                }
                .floating-btn-main:active {
                    transform: scale(0.95);
                }
                .floating-submenu {
                    position: absolute;
                    bottom: 70px;
                    right: 0;
                    display: flex;
                    flex-direction: column;
                    gap: 8px;
                    opacity: 0;
                    visibility: hidden;
                    transform: translateY(10px);
                    transition: all 0.3s ease;
                }
                .floating-submenu.active {
                    opacity: 1;
                    visibility: visible;
                    transform: translateY(0);
                }
                .floating-sub-btn {
                    width: 44px;
                    height: 44px;
                    border-radius: 50%;
                    border: none;
                    cursor: pointer;
                    font-size: 13px;
                    font-weight: bold;
                    color: white;
                    transition: all 0.2s ease;
                    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
                    display: flex;
                    align-items: center;
                    justify-content: center;
                }
                .floating-sub-btn:hover {
                    transform: scale(1.1);
                }
                .floating-sub-btn.closed-btn {
                    background: linear-gradient(135deg, #e74c3c, #c0392b);
                }
                .floating-sub-btn.unaccept-btn {
                    background: linear-gradient(135deg, #f39c12, #e67e22);
                }
                .floating-sub-btn.template-btn {
                    background: linear-gradient(135deg, #2ecc71, #27ae60);
                }
                .floating-overlay {
                    position: fixed;
                    top: 0;
                    left: 0;
                    width: 100%;
                    height: 100%;
                    background: rgba(0,0,0,0.5);
                    z-index: 9998;
                    display: none;
                }
                .floating-overlay.active {
                    display: block;
                }
            </style>
        `);

        
        $('body').append(`
            <div class="floating-overlay" id="floatingOverlay"></div>
            <div class="floating-btn-container">
                <div class="floating-submenu" id="floatingSubmenu">
                    <button class="floating-sub-btn closed-btn" id="closedFloat" title="Закрыто">😋</button>
                    <button class="floating-sub-btn unaccept-btn" id="unacceptFloat" title="Отказано">👑</button>
                    <button class="floating-sub-btn template-btn" id="selectAnswerFloat" title="Шаблоны">❤️</button>
                </div>
                <button class="floating-btn-main" id="floatingMainBtn" title="Script by Flora❤️">
                    ❤️
                </button>
            </div>
        `);

        
        let submenuActive = false;
        $('#floatingMainBtn').click(function(e) {
            e.stopPropagation();
            submenuActive = !submenuActive;
            $('#floatingSubmenu').toggleClass('active', submenuActive);
            $('#floatingOverlay').toggleClass('active', submenuActive);
        });

        
        $('#floatingOverlay').click(function() {
            submenuActive = false;
            $('#floatingSubmenu').removeClass('active');
            $('#floatingOverlay').removeClass('active');
        });

        
        $('#closedFloat').click(() => editThreadDataAndReload(PIN_PREFIX, true, false));
        $('#unacceptFloat').click(() => editThreadDataAndReload(UNACCEPT_PREFIX, false, false));

        $('#selectAnswerFloat').click(() => {
            
            submenuActive = false;
            $('#floatingSubmenu').removeClass('active');
            $('#floatingOverlay').removeClass('active');

            XF.alert(buttonsMarkup(allButtons), null, `Выберите шаблон:`);

            allButtons.forEach((btn, id) => {
                $(`button#answers-${id}`).click(async () => {
                    $(`a.overlay-titleCloser`).trigger(`click`);
                    pasteContent(btn.content);

                    if (btn.prefix !== undefined) {
                        await editThreadDataAsync(btn.prefix, btn.status);
                    }

                    if (btn.close) {
                        await closeThreadAsync();
                    }

                    setTimeout(() => {
                        $(`.button--icon.button--icon--reply.rippleButton`).trigger(`click`);
                    }, 500);
                });
            });
        });
    });

    function buttonsMarkup(buttons) {
        let html = `<div class="select_answer" style="max-height: 600px; overflow-y: auto;">`;

        html += `<div style="padding: 10px; background: #06f9d0; color: black; font-weight: bold; margin: 5px 0; border-radius: 4px;">Выбирай какафку</div>`;

        buttons.filter(b => b.category === 'complaints').forEach((btn, i) => {
            const originalIndex = buttons.indexOf(btn);
            html += `<button id="answers-${originalIndex}" class="button--primary button rippleButton" style="margin:3px; width:100%; text-align:left; padding:8px;"><span class="button-text">${btn.title}</span></button>`;
        });

        html += `<div style="padding: 10px; background: #1e3a5f; color: #fff; font-weight: bold; margin: 15px 0 5px 0; border-radius: 4px;"></div>`;

        buttons.filter(b => b.category === 'requests').forEach((btn, i) => {
            const originalIndex = buttons.indexOf(btn);
            html += `<button id="answers-${originalIndex}" class="button--primary button rippleButton" style="margin:3px; width:100%; text-align:left; padding:8px; background: #1e3a5f;"><span class="button-text">${btn.title}</span></button>`;
        });

        html += `</div>`;
        return html;
    }

    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>`);
            editor.append(content);
        }
    }

    async function getThreadData() {
        const authorID = $(`a.username`)[0].attributes[`data-user-id`].nodeValue;
        const authorName = $(`a.username`).html();
        return {
            user: {
                id: authorID,
                name: authorName,
                mention: `[USER=${authorID}]${authorName}[/USER]`,
            },
        };
    }

    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 => {
                if (data.status === 'ok') {
                    console.log('[GOSS] Тема закрыта');
                    resolve(data);
                } else {
                    console.error('[GOSS] Ошибка закрытия:', data);
                    reject(data);
                }
            })
            .catch(e => reject(e));
        });
    }

    function editThreadDataAsync(prefix, closed = false) {
        return new Promise((resolve, reject) => {
            const threadTitle = $(`.p-title-value`)[0].lastChild.textContent;

            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 => {
                if (data.status === 'ok') {
                    console.log('[GOSS] Префикс:', prefix);
                    resolve(data);
                } else {
                    reject(data);
                }
            })
            .catch(e => reject(e));
        });
    }

    function editThreadDataAndReload(prefix, closed, close) {
        editThreadDataAsync(prefix, closed).then(async () => {
            if (close) await closeThreadAsync();
            location.reload();
        });
    }
})();