MediaWiki:Common.js: Difference between revisions
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
mw. | // 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() { | |||
if (link. | var $link = $(this); | ||
link. | 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(); | |||
const | $('a').each(function() { | ||
var $link = $(this); | |||
'.minerva-header .ns-category, | if ($link.attr('href') && $link.attr('href').includes('/Category:')) { | ||
$link.text($link.text().replace(/^Category:/, '')); | |||
'. | } | ||
}); | |||
}); | |||
}); | }); | ||
observer.observe(document.body, { childList: true, subtree: true }); | observer.observe(document.body, { childList: true, subtree: true }); | ||
} | |||
} | |||
Revision as of 03:45, 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 });
}