MZ - Clasificación

Inserta escudos en la clasificación y mejora el diseño de las tablas en ManagerZone

// ==UserScript==
// @name         MZ - Clasificación
// @namespace    http://tampermonkey.net/
// @version      1.7
// @description  Inserta escudos en la clasificación y mejora el diseño de las tablas en ManagerZone
// @author       ChatGPT
// @license      MIT
// @match        https://www.managerzone.com/*
// @grant        GM_addStyle
// ==/UserScript==

(function() {
    'use strict';

    function agregarEscudos() {
        document.querySelectorAll('.nice_table td:nth-child(2)').forEach(td => {
            let equipoLink = td.querySelector('a[href*="tid="]') || td.querySelector('a');
            if (equipoLink) {
                let equipoID = obtenerIDdesdeURL(equipoLink.href) || obtenerIDdesdeData(td);

                if (equipoID && !td.querySelector('.escudo-equipo')) {
                    let imgEscudo = document.createElement('img');
                    imgEscudo.src = `https://www.managerzone.com/dynimg/badge.php?team_id=${equipoID}&sport=soccer&location=team_main`;
                    imgEscudo.classList.add('escudo-equipo');
                    imgEscudo.style.width = '20px';
                    imgEscudo.style.height = '25px';
                    imgEscudo.style.marginRight = '5px';
                    imgEscudo.style.verticalAlign = 'middle';

                    let bandera = td.querySelector('img[src*="flags"]');

                    if (bandera) {
                        bandera.parentNode.insertBefore(imgEscudo, bandera);
                    } else {
                        td.insertBefore(imgEscudo, td.firstChild);
                    }
                }
            }
        });
    }

    function obtenerIDdesdeURL(url) {
        let match = url.match(/tid=(\d+)/);
        return match ? match[1] : null;
    }

    function obtenerIDdesdeData(td) {
        let posibleID = td.innerHTML.match(/team_id=(\d+)/);
        return posibleID ? posibleID[1] : null;
    }

    function iniciarObservador() {
        const targetNode = document.body;
        const config = { childList: true, subtree: true };

        const observer = new MutationObserver(() => {
            agregarEscudos();
        });

        observer.observe(targetNode, config);
    }

    // Estilos para mejorar la tabla
    GM_addStyle(`
        .nice_table_container {
            width: 100% !important;
            overflow-x: auto !important;
        }

        .nice_table td:first-child {
            text-align: left !important;
            padding-left: 12px !important;
        }

        .nice_table tr:nth-child(even) {
            background-color: #ffffff !important;
        }
        .nice_table tr:nth-child(odd) {
            background-color: #eeeeee !important;
        }

        .nice_table tr:nth-child(1) {
            background-color: #ffdd57 !important;
            font-weight: bold !important;
            color: #000 !important;
        }

        .nice_table td, .nice_table th {
            padding: 9px 12px !important;
        }

        .nice_table th:nth-child(4)::before { content: "V" !important; }
        .nice_table th:nth-child(5)::before { content: "E" !important; }
        .nice_table th:nth-child(6)::before { content: "D" !important; }

        .nice_table th:nth-child(4),
        .nice_table th:nth-child(5),
        .nice_table th:nth-child(6) {
            color: transparent !important;
            position: relative;
        }

        .nice_table th:nth-child(4)::before,
        .nice_table th:nth-child(5)::before,
        .nice_table th:nth-child(6)::before {
            color: black !important;
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
        }

        .nice_table td:nth-child(2) {
            text-align: left !important;
            padding-left: 7px !important;
            font-weight: normal !important;
            white-space: nowrap !important;
            text-transform: uppercase !important;
        }

        .nice_table, .nice_table th, .nice_table td {
            border: none !important;
        }

        .nice_table th, .nice_table td {
            padding: 7px !important;
            text-align: center !important;
        }
    `);

    // Ejecutar la función al inicio y activar el observador
    agregarEscudos();
    iniciarObservador();
})();

QingJ © 2025

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