Jump to content

MediaWiki:Common.js

From Wyld West Wiki
Revision as of 18:13, 27 February 2025 by RobAdmin (talk | contribs) (Created page with "mw.loader.using('mediawiki.util').then(function () { if (!mw.config.get('wgUserName')) { // Only for non-logged-in users console.log('Non-logged-in user detected'); // Automatically tick the checkbox to expand the Main menu var mainMenuCheckbox = document.getElementById('vector-main-menu-dropdown-checkbox'); if (mainMenuCheckbox) { mainMenuCheckbox.checked = true; // Check the checkbox to expand the menu cons...")
(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.
mw.loader.using('mediawiki.util').then(function () {
    if (!mw.config.get('wgUserName')) {  // Only for non-logged-in users
        console.log('Non-logged-in user detected');

        // Automatically tick the checkbox to expand the Main menu
        var mainMenuCheckbox = document.getElementById('vector-main-menu-dropdown-checkbox');
        if (mainMenuCheckbox) {
            mainMenuCheckbox.checked = true;  // Check the checkbox to expand the menu
            console.log('Main menu checkbox checked');
        }

        // Delay the "Move to Sidebar" button click to ensure the button is clickable
        setTimeout(function() {
            // Target the "Move to Sidebar" button by the 'data-event-name' attribute
            var moveToSidebarButton = document.querySelector('[data-event-name="pinnable-header.vector-main-menu.pin"]');
            if (moveToSidebarButton) {
                moveToSidebarButton.click();  // Click the button
                console.log('Move to sidebar button clicked');
            }
        }, 50);  // Delay of 50ms to allow elements to load
    }
});


mw.loader.using('mediawiki.user').then(function() {
    if (!mw.config.get('wgUserName')) {  // If the user is NOT logged in
        document.body.classList.add('not-logged-in');  // Manually add the not-logged-in class
    }
});


mw.loader.using('mediawiki.user').then(function() {
    if (!mw.config.get('wgUserName')) {  // If the user is NOT logged in
        document.body.classList.add('not-logged-in');  // Manually add the not-logged-in class
    }
});