Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
mw.loader.using('mediawiki.util').then(function () {

    function removeCategoryPrefixFromNode(node) {
        // If the node itself is a link or contains links
        const links = node.querySelectorAll ? node.querySelectorAll('a') : [];
        links.forEach(function(link) {
            // Skip if already processed
            if (link.dataset.cleaned) return;
            if (link.href && link.href.includes('/Category:') && link.textContent.startsWith('Category:')) {
                link.textContent = link.textContent.replace(/^Category:/, '');
                link.dataset.cleaned = true;
            }
        });

        // Additionally, check if the node itself is a link
        if (node.nodeType === Node.ELEMENT_NODE && node.tagName === 'A' &&
            node.href.includes('/Category:') && node.textContent.startsWith('Category:')) {
            node.textContent = node.textContent.replace(/^Category:/, '');
            node.dataset.cleaned = true;
        }
    }

    function cleanCategoryLinks(root = document) {
        removeCategoryPrefixFromNode(root);
        if (root.querySelectorAll) {
            root.querySelectorAll('a[href*="/Category:"]').forEach(removeCategoryPrefixFromNode);
        }
    }

    // Initial clean
    cleanCategoryLinks();

    // Observe the body for dynamically added content
    const observer = new MutationObserver(function(mutations) {
        mutations.forEach(function(mutation) {
            mutation.addedNodes.forEach(cleanCategoryLinks);
        });
    });

    observer.observe(document.body, { childList: true, subtree: true });

    // Hide "Category:" in headers
    const hideNamespace = () => {
        document.querySelectorAll('.minerva-header .ns-category, .mw-page-title-namespace, .page-heading .ns-category')
            .forEach(el => el.style.display = 'none');
    };
    hideNamespace();

    // Observe headers too
    const headerObserver = new MutationObserver(hideNamespace);
    headerObserver.observe(document.body, { childList: true, subtree: true });

});