// ==UserScript==
// @name         Dexujizer - diskusia
// @namespace    https://gulas.sme.sk
// @version      1.5
// @description  Skryje komentáre od používateľov podľa mena účtu alebo anonymné komentáre na gulas.sme.sk
// @match        https://*.gulas.sme.sk/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    // 👉 Zoznam používateľských mien podľa URL (napr. https://meno.gulas.sme.sk/)
    const blockedUsernames = [
        'kolotociaredo',
        'abortmachtfrei',
        'tatok',
        'tatokr',
        'tato',
        'nepochop',
        'jojko',
        'chronozom',
        'bratkur',
        'kolt2',
        'franta-vana'
    ];

    // 👉 Voliteľné skrytie anonymných komentárov (tých bez mena/účtu)
    const hideAnonymousPosts = true;

    function extractUsernameFromUrl(url) {
        const match = url.match(/^https:\/\/([^.]+)\.gulas\.sme\.sk\/?/);
        return match ? match[1] : null;
    }

    function hideBlockedComments() {
        document.querySelectorAll('.post_discusion_row').forEach(post => {
            const nickAnchor = post.querySelector('.disc_nick a[href]');
            const profileUrl = nickAnchor?.getAttribute('href')?.trim();

            if (profileUrl) {
                const username = extractUsernameFromUrl(profileUrl);
                if (username && blockedUsernames.includes(username)) {
                    post.style.display = 'none';
                }
            } else if (hideAnonymousPosts) {
                post.style.display = 'none';
            }
        });
    }

    hideBlockedComments();

    const observer = new MutationObserver(hideBlockedComments);
    observer.observe(document.body, { childList: true, subtree: true });
})();