(Created page with "→‎All JavaScript here will be loaded for users of the MinervaNeue skin: document.addEventListener('DOMContentLoaded', function() { // Remove "Category:" prefix from visible link text document.querySelectorAll('a[href*="/Category:"]').forEach(function(link) { if (link.textContent.startsWith('Category:')) { link.textContent = link.textContent.replace(/^Category:/, ''); } }); // Remove "Category:" from page title namespace la...")
 
No edit summary
 
Line 1: Line 1:
/* All JavaScript here will be loaded for users of the MinervaNeue skin */
mw.loader.using('mediawiki.util').then(function () {
    function stripCategoryPrefix(container) {
        container.querySelectorAll('a').forEach(function(link) {
            // Only process links to categories
            if (link.href.includes('/Category:') && link.textContent.startsWith('Category:')) {
                link.textContent = link.textContent.replace(/^Category:/, '');
            }
        });
    }


document.addEventListener('DOMContentLoaded', function() {
     // Hook into Minerva page rendering
     // Remove "Category:" prefix from visible link text
     mw.hook('wikipage.content').add(function($content) {
     document.querySelectorAll('a[href*="/Category:"]').forEach(function(link) {
         stripCategoryPrefix($content[0]);
         if (link.textContent.startsWith('Category:')) {
            link.textContent = link.textContent.replace(/^Category:/, '');
        }
     });
     });


     // Remove "Category:" from page title namespace label
     // Also run immediately for already loaded content
     const ns = document.querySelector('.mw-page-title-namespace');
    stripCategoryPrefix(document);
    if (ns && ns.textContent.includes('Category')) {
   
        ns.style.display = 'none';
    // Hide "Category:" in page headers
     }
     const hideNamespace = () => {
        document.querySelectorAll('.minerva-header .ns-category, .mw-page-title-namespace, .page-heading .ns-category')
            .forEach(el => el.style.display = 'none');
    };
    hideNamespace();
    const observer = new MutationObserver(hideNamespace);
     observer.observe(document.body, { childList: true, subtree: true });
});
});

Latest revision as of 03:42, 9 October 2025

mw.loader.using('mediawiki.util').then(function () {
    function stripCategoryPrefix(container) {
        container.querySelectorAll('a').forEach(function(link) {
            // Only process links to categories
            if (link.href.includes('/Category:') && link.textContent.startsWith('Category:')) {
                link.textContent = link.textContent.replace(/^Category:/, '');
            }
        });
    }

    // Hook into Minerva page rendering
    mw.hook('wikipage.content').add(function($content) {
        stripCategoryPrefix($content[0]);
    });

    // Also run immediately for already loaded content
    stripCategoryPrefix(document);
    
    // Hide "Category:" in page headers
    const hideNamespace = () => {
        document.querySelectorAll('.minerva-header .ns-category, .mw-page-title-namespace, .page-heading .ns-category')
            .forEach(el => el.style.display = 'none');
    };
    hideNamespace();
    const observer = new MutationObserver(hideNamespace);
    observer.observe(document.body, { childList: true, subtree: true });
});