MediaWiki:Minerva.js
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 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 });
});