Extensions Manager

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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}`, 'Менеджер расширений'
    )
}