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 to strip "Category:" prefix from links
    function stripCategoryPrefix(container) {
        container.querySelectorAll('a').forEach(function(link) {
            if (link.href.includes('/Category:') && link.textContent.startsWith('Category:')) {
                link.textContent = link.textContent.replace(/^Category:/, '');
            }
        });
    }

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

    // Run immediately for already loaded content
    stripCategoryPrefix(document);

    // Hide "Category:" namespace labels 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 the body for dynamically added content (Minerva can re-render headers)
    const observer = new MutationObserver(function() {
        hideNamespace();
        stripCategoryPrefix(document);
    });
    observer.observe(document.body, { childList: true, subtree: true });

});