MediaWiki:Common.js
Jump to navigation
Jump to search
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)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */
// Strip "Tests:" namespace prefix from search result titles
function stripTestsPrefix($scope) {
$scope.find('a[title^="Tests:"]').each(function() {
const currentText = $(this).text();
const newText = currentText.replace(/^Tests:/, '');
$(this).text(newText);
});
}
// Run on initial page load
mw.hook('wikipage.content').add(stripTestsPrefix);
// Run again if search results are loaded dynamically (e.g., infinite scroll)
mw.hook('searchResultsReady').add(stripTestsPrefix);
// Remove all page text snippets from search results
function stripSearchSnippets($scope) {
$scope.find('.searchresult').remove(); // Removes the snippet paragraph
$scope.find('.mw-search-result-data').remove(); // Optional: removes size/date line
}
mw.hook('wikipage.content').add(stripSearchSnippets);
mw.hook('searchResultsReady').add(stripSearchSnippets);