Jump to content
Health NZ Taranaki Lab Manual

MediaWiki:Common.js

Revision as of 15:39, 18 September 2025 by Chris Greenwood (Cge) (talk | contribs) (Created page with "→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 searc...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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);