No edit summary
No edit summary
Line 30: Line 30:
     observer.observe(document.body, { childList: true, subtree: true });
     observer.observe(document.body, { childList: true, subtree: true });
}
}
mw.hook('wikipage.content').add(function($content) {
    $content.find('a[href*="/Category:"]').each(function() {
        $(this).text($(this).text().replace(/^Category:/, ''));
    });
});

Revision as of 03:47, 9 October 2025

// Only run for MinervaNeue
if ( mw.config.get('skin') === 'minerva' ) {
    mw.hook('wikipage.content').add(function($content) {
        // Remove "Category:" prefix from all links inside content
        $content.find('a').each(function() {
            var $link = $(this);
            if ( $link.attr('href') && $link.attr('href').includes('/Category:') ) {
                $link.text($link.text().replace(/^Category:/, ''));
            }
        });
    });

    // Remove prefix from category page headers
    $(document).ready(function() {
        $('.minerva-header .ns-category, .page-heading .ns-category, .mw-page-title-namespace').hide();
    });

    // Observe for dynamically injected content (e.g., forms/templates)
    const observer = new MutationObserver(function(mutations) {
        mutations.forEach(function() {
            $('.minerva-header .ns-category, .page-heading .ns-category, .mw-page-title-namespace').hide();
            $('a').each(function() {
                var $link = $(this);
                if ($link.attr('href') && $link.attr('href').includes('/Category:')) {
                    $link.text($link.text().replace(/^Category:/, ''));
                }
            });
        });
    });
    observer.observe(document.body, { childList: true, subtree: true });
}

mw.hook('wikipage.content').add(function($content) {
    $content.find('a[href*="/Category:"]').each(function() {
        $(this).text($(this).text().replace(/^Category:/, ''));
    });
});