Jump to content

MediaWiki:Common.js

From inZOI Wiki
Revision as of 13:43, 26 March 2025 by Zoi (talk | contribs)

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. */
// Wait for the document to be fully loaded
mw.hook('wikipage.content').add(function() {
    // Check if we're on a search results page
    if (mw.config.get('wgCanonicalSpecialPageName') === 'Search') {
        // Small delay to ensure all search elements are loaded
        setTimeout(function() {
            // Target the Content pages tab specifically
            var contentPagesTab = document.querySelector('.search-types a[data-target="mw-search-content"]') ||
                                 document.querySelector('.search-types a:nth-child(1)');
            
            // Click the tab if found
            if (contentPagesTab) {
                contentPagesTab.click();
                console.log('Search tab switched to Content pages');
            } else {
                console.log('Content pages tab not found');
            }
        }, 100);
    }
});