MenelGame - Interface

Poprawki wizualne: Ekwipunek, PVP, Zęby.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey, Greasemonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да инсталирате разширение, като например Tampermonkey .

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Userscripts.

За да инсталирате скрипта, трябва да инсталирате разширение като Tampermonkey.

За да инсталирате този скрипт, трябва да имате инсталиран скриптов мениджър.

(Вече имам скриптов мениджър, искам да го инсталирам!)

Advertisement:

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

(Вече имам инсталиран мениджър на стиловете, искам да го инсталирам!)

Advertisement:

// ==UserScript==
// @name          MenelGame - Interface
// @namespace     https://greasyfork.org/en/scripts/575758-menelgame-interface-tweaks
// @version       2.8.6
// @description   Poprawki wizualne: Ekwipunek, PVP, Zęby.
// @author        Arctos + Gemini + ChatGPT
// @match         *://*.menelgame.online/*
// @grant         none
// @license       MIT
// ==/UserScript==

(function() {
    'use strict';

    const SCRIPT_ID = 'MG_interfacetweaks';
    const costTable = { 0: 15, 5: 40, 10: 65, 15: 90, 20: 115, 25: 140, 30: 165, 35: 190, 40: 215, 45: 240 };

    // Funkcja sprawdzająca czy dany moduł powinien działać
    function isModEnabled(key) {
        const globalny = localStorage.getItem(SCRIPT_ID) !== 'false';
        if (!globalny) return false;
        if (key === 'globalny') return true;
        return localStorage.getItem(SCRIPT_ID + '_' + key) !== 'false';
    }

    const style = document.createElement('style');
    document.head.appendChild(style);

    function updateStyles() {
        if (localStorage.getItem(SCRIPT_ID) === 'false') { style.innerHTML = ''; return; }

        let css = '';
        if (isModEnabled('ekwipunek')) {
            css += `
                .avatar-jacket-badge { width: 48px !important; height: 48px !important; }
                .avatar-jacket-icon { width: 100% !important; height: 100% !important; }
                .equipment-tabs { margin-bottom: 0px !important; }
                .equipment-presets-section { margin-top: 0px !important; }
                .equipment-slot-row.row-hustling { display: block !important; text-align: center !important; width: 100% !important; overflow: visible !important; clear: both !important; margin-top: -65px !important; position: relative !important; z-index: 10 !important; line-height: 0 !important; pointer-events: none !important; }
                .equipment-slot-row.row-hustling .equipment-slot { display: inline-block !important; float: none !important; position: relative !important; margin: 0 1% !important; vertical-align: top !important; pointer-events: auto !important; }
                .equipment-slot-row.row-hustling .equipment-slot:nth-child(1), .equipment-slot-row.row-hustling .equipment-slot:nth-child(2) { left: -14% !important; }
                .equipment-slot-row.row-hustling .equipment-slot:nth-child(3), .equipment-slot-row.row-hustling .equipment-slot:nth-child(4) { left: 14% !important; }
                .equipment-slot { z-index: 5 !important; pointer-events: auto !important; }
                [title*="buty"], [title*="Buty"], .equipment-slot { pointer-events: auto !important; }
            `;
        }
        if (isModEnabled('zeby')) {
            css += `
                div[style*="background-color: rgba(74, 58, 42, 0.9)"] { justify-content: flex-start !important; gap: 10px !important; }
                div[style*="background-color: rgba(74, 58, 42, 0.9)"] > div:nth-child(2) { margin-left: auto !important; }
            `;
        }
        if (isModEnabled('pvp')) {
            css += `
                .pvp-attribute-cost-info { color: #000000 !important; font-weight: bold; font-size: 12px; padding: 2px 5px; border-radius: 4px; display: inline-block; margin-left: auto !important; margin-right: 10% !important; }
                .pvp-attribute-row[data-attr-type="str"] .pvp-attribute-cost-info { background: rgba(192, 57, 43, 0.4); }
                .pvp-attribute-row[data-attr-type="end"] .pvp-attribute-cost-info { background: rgba(127, 140, 141, 0.4); }
                .pvp-attribute-row[data-attr-type="agi"] .pvp-attribute-cost-info { background: rgba(39, 174, 96, 0.4); }
                .pvp-attribute-row[data-attr-type="vit"] .pvp-attribute-cost-info { background: rgba(231, 76, 60, 0.4); }
                .pvp-attribute-row[data-attr-type="prc"] .pvp-attribute-cost-info { background: rgba(243, 156, 18, 0.4); }
            `;
        }
        if (isModEnabled('paser')) {
            css += `
                @media screen and (max-width: 600px) {
                    /* Czyścimy marginesy nadrzędnego kontenera */
                    .shop-content {
                        padding: 0 5px !important; /* Minimalny margines dla estetyki */
                    }
                    .shop-slots-grid {
                        display: grid !important;
                        grid-template-columns: repeat(4, 1fr) !important;
                        gap: 4px !important;
                        padding: 0 !important;
                        margin: 0 !important;
                        width: 100% !important;
                    }
                    .shop-slot {
                        margin: 0 !important;
                        width: 100% !important;
                        /* Opcjonalnie: jeśli sloty mają wciąż za dużo miejsca w środku */
                        box-sizing: border-box !important;
                    }
                }
            `;
        }
        if (isModEnabled('pw')) {
            css += `
                .sidebar-open.sidebar .sidebar-content {
                        display: flex !important;
                        flex-direction: column !important;
                        height: 100vh !important;
                }
                .sidebar-open.sidebar .sidebar-content > div {
                        display: flex !important;
                        flex-direction: column !important;
                        flex: 1 !important;
                        min-height: 0 !important;
                }
                .sidebar-open.sidebar .sidebar-content div[style*="max-height: 350px"][style*="overflow-y: auto"] {
                        flex: 1 !important;
                        min-height: 0 !important;
                        max-height: none !important;
                        overflow-y: auto !important;
                }
                .sidebar-open.sidebar .sidebar-content div[style*="max-height: 300px"][style*="min-height: 100px"] {
                        flex: 1 !important;
                        min-height: 0 !important;
                        max-height: none !important;
                        overflow-y: auto !important;
                }
                .sidebar-open.sidebar .sidebar-content div[style*="max-height: 350px"][style*="overflow-y: auto"] {
                        overscroll-behavior: contain;
                }
            `;
        }
        style.innerHTML = css;
    }

    function processPVP() {
        if (!isModEnabled('pvp')) {
            document.querySelectorAll('.pvp-attribute-cost-info').forEach(el => el.remove());
            return;
        }
        document.querySelectorAll('.pvp-attribute-row').forEach(row => {
            const valSpan = row.querySelector('div[style*="flex: 1"] div:first-child span:last-child');
            if (!valSpan || row.querySelector('.pvp-attribute-cost-info')) return;
            const val = parseInt(valSpan.textContent);
            if (isNaN(val)) return;

            const next = (() => {
                const arr = Object.keys(costTable).map(Number).sort((a,b) => b-a);
                for(let t of arr) if(val >= t) return costTable[t];
                return costTable[0];
            })();

            const img = row.querySelector('img[alt]');
            const type = img ? img.getAttribute('alt').toLowerCase() : 'unknown';
            row.setAttribute('data-attr-type', type);

            const span = document.createElement('span');
            span.className = 'pvp-attribute-cost-info';
            span.innerHTML = `${next}<img src="/images/icons/premium.png" style="width:12px; height:12px; vertical-align:middle;"><`;
            valSpan.insertAdjacentElement('beforebegin', span);
        });
    }

// Komunikacja z Panelem
    window.addEventListener('scriptStateChanged', (e) => {
        if (e.detail && e.detail.scriptId.startsWith(SCRIPT_ID)) {
            localStorage.setItem(e.detail.scriptId, e.detail.enabled);
            updateStyles();
            processPVP();
        }
    });

    function pingPanel() {
        const wersja = (typeof GM_info !== 'undefined' && GM_info.script) ? GM_info.script.version : '2.7.6';

        window.dispatchEvent(new CustomEvent('scriptPingFromSub', {
            detail: {
                scriptId: SCRIPT_ID,
                version: wersja
            }
        }));
    }

    // Pierwszy ping po 500ms
    setTimeout(pingPanel, 500);

    // Odpowiedź na zapytanie panelu
    window.addEventListener('scriptPingFromPanel', pingPanel);

    new MutationObserver(() => {
        if (localStorage.getItem(SCRIPT_ID) !== 'false') {
            requestAnimationFrame(processPVP);
        }
    }).observe(document.body, { childList: true, subtree: true });

    updateStyles();
    processPVP();
})();