Greasy Fork

Greasy Fork is available in English.

LZT_Trophy

Отображение всех трофеев в профиле пользователя

当前为 2025-10-20 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         LZT_Trophy
// @namespace    http://greasyfork.icu/ru/users/1142494-llimonix
// @version      0.12
// @description  Отображение всех трофеев в профиле пользователя
// @author       llimonix
// @match        https://zelenka.guru/*
// @match        https://lolz.live/*
// @icon         https://cdn-icons-png.flaticon.com/512/2830/2830919.png
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    let pageCounter = $('.page_counter');

    if (pageCounter.length > 0) {
        let urlbase = window.location.hostname;
        let hrefValue = pageCounter.attr('href');
        let parts = hrefValue.replace('members/', '').split("/");
        let value = parts[0];
        let trophy;
        if (~hrefValue.indexOf("members/")) {
            value = `members/${value}`;
        }
        XenForo.ajax(`https://${urlbase}/${value}/trophies`, {}).then(data => {
            trophy = data.templateHtml;
            let parser = new DOMParser();
            trophy = parser.parseFromString(trophy, 'text/html');
            let overlayScrollElements = $(trophy).find('.overlayScroll');
            let totalCount = overlayScrollElements.length;
            if (totalCount > 1) {
                overlayScrollElements.first().remove();
            }

            let trophies = $(trophy).find('.trophy');
            let trophiesList = trophies.map((_, trophy) => trophy.id).get();

            let trophiesstyle = $(trophy).find('.trophy-icon');
            let trophystyleList = trophiesstyle.map((_, trophy) => {
                const style = trophy.style.cssText;
                const match = style.match(/url\((.*?)\)/);
                return match ? match[1].replace(/['"]/g, '') : null;
            }).get();
            console.log(trophystyleList)

            let titletrophy = $(trophy).find('.title');
            let titleTexttrophyList = titletrophy.map((_, trophy) => trophy.textContent).get();

            let trophyLinks = {};

            for (let i = 0; i < titleTexttrophyList.length; i++) {
                let element = titleTexttrophyList[i];
                $(trophy).find('.title:contains(' + element + ')').each(function () {
                    let href = $(this).closest('.trophy').find('.trophy-icon').attr('href');
                    if (href) {
                        trophyLinks[element] = href;
                    } else {
                        trophyLinks[element] = "None";
                    }
                });
            }


            let htmlTrophy = "<ol>";
            let titles = [];
            for (let index = 0; index < trophystyleList.length; index++) {
                let trophyLink = trophyLinks[titleTexttrophyList[index]];
                let trophyStyle = `background-image: url('${trophystyleList[index]}'); --mask: url('${trophystyleList[index]}')`
                if (trophyLink == "None") {
                    htmlTrophy += `<li class="trophy DelayedTooltip" id="${trophiesList[index]}" tabindex="0"><div class="trophy-icon" style="${trophyStyle}"></div></li>`;
                } else {
                    htmlTrophy += `<li class="trophy DelayedTooltip" id="${trophiesList[index]}" tabindex="0"><a href="${trophyLink}" class="trophy-icon" style="${trophyStyle}"></a></li>`;
                }
                titles.push(titleTexttrophyList[index]);
            }
            htmlTrophy += "</ol>";

            if (screen.width <= 480) {
                $('.memberViewTrophies').html(htmlTrophy);
                $('.Responsive .memberViewTrophies').css('display', 'block');
                $('.memberViewTrophies').css({
                    'position': 'relative',
                    'margin': '20px 0 0',
                    'overflow-x': 'scroll',
                    'white-space': 'nowrap'
                });

                $('.memberViewTrophies .trophy').hover(function() {
                    $(this).css({
                        '-webkit-transform': 'none',
                        'transform': 'none',
                        '-ms-transform': 'none'
                    });
                });
            } else {
                $('.memberViewTrophies').html(htmlTrophy);
            }

            $('.DelayedTooltip').each(function(index, element) {
                tippy(element, {
                    content: titles[index],
                    arrow: true,
                    onShow(instance) {
                        instance.popper.style.border = '10px solid transparent';
                    }
                });
            });
        });
    }
})();