Extensions Manager

Сделай свой жизнь на LolzTeam проще!

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Extensions Manager
// @namespace    Openresty
// @version      v1.0.0
// @description  Сделай свой жизнь на LolzTeam проще!
// @author       https://zelenka.guru/lays (openresty)
// @match        https://zelenka.guru/*
// @grant        GM_xmlhttpRequest
// @grant        GM.setValue
// @grant        GM.getValue
// @grant        unsafeWindow
// @connect      lzt.hasanbek.ru
// @run-at       document-body
// @license MIT
// ==/UserScript==

const
    ext_version         = "1.0.0"

let nickname,
    userid;

(async function() {
    window.addEventListener("DOMContentLoaded",async (event) => {
        renderSettings();
        userid   = document.querySelector("input[name=_xfToken").value.split(",")[0];
        nickname = document.querySelector(".accountUsername.username").firstElementChild.innerText.trim();
    })
    renderFunctions();
})();


function request(url) {
    return new Promise((resolve, reject) => GM_xmlhttpRequest({
        method: "GET",
        url: url,
        onload: response => resolve(response.responseText),
        onerror: error => resolve(error)
    }));
}

function getUID() {
    return document.querySelector("input[name=_xfToken").value.split(",")[0];
}


function renderSettings() {
    if (document.querySelector(".secondaryContent a.button.block[href='account/personal-details']")) {
        let profileeditbtn = document.createElement('a')
        profileeditbtn.classList.add('block');
        profileeditbtn.classList.add('button');
        profileeditbtn.onclick = function () {
            dialogWindow();
        };
        profileeditbtn.innerHTML = 'Магазин расширений';
        document.querySelector(".topblock .secondaryContent").append(profileeditbtn)
    }
}

function renderFunctions() {
    unsafeWindow.nickname = nickname;
    unsafeWindow.ext_version = ext_version;
    unsafeWindow.request = request;
    unsafeWindow.extmanager = true;
    let torender = [dialogWindow];
    let funcs = torender.map(e => e.toString());
    let script = document.createElement('script');
    script.appendChild(document.createTextNode(funcs.join("")));
    document.head.appendChild(script);
}

async function dialogWindow() {
    nickname = document.querySelector(".accountUsername.username").firstElementChild.innerText.trim().replace(/<[^>]*>/g, ' ').replace(/\s{2,}/g, ' ').trim().replace(" Premium", "").trim();

    let htmlall = `
        <iframe src='https://lzt.hasanbek.ru/extmanager/index.html' frameborder='0' width='100%' height='100%' id='areaext'>
        <script>
            window.addEventListener('message', function(event) {
                if (event.data == 'auth') {
                    iframe = document.querySelectorAll('#areaext');  
                    iframe.forEach(function (e){
                        e.contentWindow.postMessage(XenForo.visitor.user_id, "*");
                    })
                }else {

                }
            });
        </script>
        <style>
        .errorOverlay>.baseHtml {
            padding: 0px;
            height: 350px;
        }
        .xenOverlay .errorOverlay .errorDetails {
            padding: 0px;
            white-space: normal
        }
        </style>
    `
    let html_prem = `
    ${htmlall}
    `;
    return  XenForo.alert(
        `${html_prem}`, 'Менеджер расширений'
    )
}