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.
/* All JavaScript here will be loaded for users of the MinervaNeue skin */

/* likeMarioWiki: Custom menu - Version 5 (Intentional No-Icon, Left-Aligned Text) */
// This version intentionally creates plain text menu items aligned to the left,
// removing icon elements and aiming for the layout observed accidentally in V3.
$.when(mw.loader.using(['mediawiki.util']), $.ready).then(function() {

    var menuId = 'p-personal'; // Default menu ID
    // For logged-in users, try 'p-interaction' first, then fallback to 'p-navigation'
    if (mw.config.get('wgUserId')) {
        menuId = document.getElementById('p-interaction') ? 'p-interaction' : 'p-navigation';
    }
    // Final fallback if the chosen menu doesn't exist
    if (!document.getElementById(menuId)) {
         menuId = 'p-personal';
    }

    var targetMenuUl = document.getElementById(menuId);
    if (!targetMenuUl) {
        console.error('[Minerva.js V5] Could not find target menu UL element with ID:', menuId);
        return; // Stop if menu doesn't exist
    }

    // Function to safely get page URL (same as before)
    function getSafeUrl(pageName) {
        var url = '#error-generating-url';
        try {
            if (typeof mw !== 'undefined' && typeof mw.util !== 'undefined' && typeof mw.util.getUrl === 'function') {
                url = mw.util.getUrl(pageName);
            } else {
                console.warn('[Minerva.js V5] mw.util.getUrl not available.');
                var prefix = mw.config.get('wgArticlePath', '/wiki/$1').replace('$1', '');
                url = prefix + encodeURIComponent(pageName.replace(/ /g, '_'));
            }
        } catch (e) {
            console.error('[Minerva.js V5] Error in getSafeUrl for "' + pageName + '":', e);
        }
        return url;
    }

    // --- Helper function: Creates LI > A structure for plain text menu items (left-aligned) ---
    // Renamed function for clarity
    function addPlainTextMenuItem(targetUlElement, pageName, linkText) {
        try {
            // 1. Create list item (LI)
            var listItem = document.createElement('li');
            // Add classes likely needed for menu item structure/styling
            listItem.classList.add('mw-list-item', 'toggle-list-item');

            // 2. Create anchor (A)
            var anchor = document.createElement('a');
            anchor.href = getSafeUrl(pageName);
            // Apply classes that seemed to cause the left-alignment in V3
            anchor.classList.add('mw-list-item__label', 'toggle-list-item__anchor');
            // Set text content directly on the anchor
            anchor.textContent = linkText;

            // --- Icon Span element creation and appending is REMOVED ---

            // --- Label Span element creation and appending is REMOVED ---

            // 5. Append anchor to list item, and list item to menu
            listItem.appendChild(anchor);
            targetUlElement.appendChild(listItem);

            console.log('[Minerva.js V5] Added plain menu item:', linkText);

        } catch (e) {
            console.error('[Minerva.js V5] Error adding plain menu item "' + linkText + '":', e);
        }
    }

    // --- Helper function: Adds a header item (same as before) ---
    function addMenuHeader(targetUlElement, headerText) {
         try {
            var headerItem = document.createElement('li');
            headerItem.classList.add('menu__item', 'menu__item--category', 'menu-header');
            headerItem.innerHTML = '<span class="menu-header-text">' + headerText + '</span>';
            targetUlElement.appendChild(headerItem);
            console.log('[Minerva.js V5] Added header:', headerText);
         } catch (e) {
             console.error('[Minerva.js V5] Error adding header "' + headerText + '":', e);
         }
    }

    // --- Add Categories section ---
    addMenuHeader(targetMenuUl, '— CATEGORIES —');
    // Call the new function, without the icon name parameter
    addPlainTextMenuItem(targetMenuUl, 'Animal_cruelty_cases_by_location', 'By Location/地点');
    addPlainTextMenuItem(targetMenuUl, 'Animal_cruelty_cases_by_species', 'By Species/物种');
    addPlainTextMenuItem(targetMenuUl, 'Animal_cruelty_cases_by_year', 'By Year/年份');

    // --- Add Resources section ---
    addMenuHeader(targetMenuUl, '— RESOURCES —');
    // Call the new function, without the icon name parameter
    addPlainTextMenuItem(targetMenuUl, 'Documentaries', 'Documentaries/纪录片');
    addPlainTextMenuItem(targetMenuUl, 'Downloads', 'Downloads/下载');
    addPlainTextMenuItem(targetMenuUl, 'Studies', 'Studies/研究');
    addPlainTextMenuItem(targetMenuUl, 'Useful_links', 'Useful links/实用链接');

    console.log('[Minerva.js V5] Script finished (Intentionally creating plain, left-aligned menu items).');

}); // End of $.when()