MediaWiki:Minerva.js
Appearance
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 */ // Wait for the document to be ready $(document).ready(function () { // Target the UL containing Home, Random (#p-navigation seems less reliable, let's target the main menu container's first UL) // Updated selector: Find the main menu container, then its direct child UL var $menuUl = $('#mw-mf-page-left .menu > ul').first(); // Ensure the menu target exists if ($menuUl.length) { // --- Function to generate URL safely --- function getSafeUrl(pageName) { // Check if mw.util exists for getUrl, otherwise fallback to simple string concat if (typeof mw !== 'undefined' && typeof mw.util !== 'undefined' && typeof mw.util.getUrl === 'function') { return mw.util.getUrl(pageName); } else { // Basic fallback if mw.util is not ready (less ideal) // Assumes standard /wiki/ path prefix var prefix = mw.config.get('wgArticlePath', '/wiki/$1').replace('$1', ''); return prefix + encodeURIComponent(pageName.replace(/ /g, '_')); } } // --- Add Categories section items --- // Add a divider LI with a specific class first $menuUl.append('<li class="menu-divider-section" data-section="Categories"></li>'); // Add links, wrapping them in LI with a custom class $menuUl.append('<li class="custom-menu-item"><a href="' + getSafeUrl('Animal cruelty cases by location') + '">By Location/地点</a></li>'); $menuUl.append('<li class="custom-menu-item"><a href="' + getSafeUrl('Animal cruelty cases by species') + '">By Species/物种</a></li>'); $menuUl.append('<li class="custom-menu-item"><a href="' + getSafeUrl('Animal cruelty cases by year') + '">By Year/年份</a></li>'); // --- Add Resources section items --- // Add another divider $menuUl.append('<li class="menu-divider-section" data-section="Resources"></li>'); // Add links $menuUl.append('<li class="custom-menu-item"><a href="' + getSafeUrl('useful links') + '">Useful links/实用链接</a></li>'); $menuUl.append('<li class="custom-menu-item"><a href="' + getSafeUrl('documentaries') + '">Documentaries/纪录片</a></li>'); $menuUl.append('<li class="custom-menu-item"><a href="' + getSafeUrl('psychological study') + '">Psychological study/心理研究</a></li>'); } else { // Log a warning if the menu UL isn't found console.warn('Could not find the main mobile menu UL element (#mw-mf-page-left .menu > ul) to append items.'); } });