Jump to content

MediaWiki:Common.js: Difference between revisions

No edit summary
Tag: Replaced
 
Line 1: Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
/* 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);
    }
});