[GC] UL Trophy ordering

Order trophies by gold/silver/bronze in every userlookup and also shows the CSS code used in the browser's console

当前为 2023-12-08 提交的版本,查看 最新版本

// ==UserScript==
// @name         [GC] UL Trophy ordering
// @version      1.0
// @description  Order trophies by gold/silver/bronze in every userlookup and also shows the CSS code used in the browser's console
// @author       Berna
// @match        https://www.grundos.cafe/userlookup/?user=*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=grundos.cafe
// @license      MIT
// @namespace https://gf.qytechs.cn/users/1230396
// ==/UserScript==

// Wrap the script in a function to avoid polluting the global scope
function generateCondensedCssCode() {
    // Select all elements with class "ul__gametrophy"
    var elements = document.querySelectorAll('.ul__gametrophy');

    // Initialize an object to store orders and corresponding CSS rules
    var cssRulesByOrder = {};

    // Iterate through each element
    elements.forEach(function (element) {
        // Find the img element
        var imgElement = element.querySelector('img');

        // If img element is found
        if (imgElement) {
            // Extract the src attribute
            var srcAttribute = imgElement.getAttribute('src');

            // Extract the URL end
            var urlEnd = srcAttribute.substring(srcAttribute.lastIndexOf('/') + 1);

            // Extract the order from the URL end
            var orderMatch = urlEnd.match(/_(\d+)\.gif/);
            var order = orderMatch ? orderMatch[1] : '';

            // Initialize CSS rule array for the order if not already present
            if (!cssRulesByOrder[order]) {
                cssRulesByOrder[order] = [];
            }

            // Add the CSS rule to the array for the order
            cssRulesByOrder[order].push('.' + element.classList[element.classList.length - 1]);
        }
    });

    // Log the condensed CSS rules for each order
    for (var order in cssRulesByOrder) {
        var cssRules = cssRulesByOrder[order].join(', ') + ' { order: ' + order + '; }';
        console.log(cssRules);
    }
}

// Call the function
generateCondensedCssCode();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址