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 */ // Version based on user's provided code that previously showed links (but had 404s) // Modified to use correct URL generation and add CSS classes $(document).ready(function () { console.log('[Minerva.js] Running modified ChatGPT/Initial Append code...'); // Target the specific UL element user's code targeted var $menu = $('#p-navigation'); console.log('[Minerva.js] Target menu UL selector:', '#p-navigation'); console.log('[Minerva.js] Found target menu UL elements:', $menu.length); if ($menu.length) { console.log('[Minerva.js] Target UL found. Appending items...'); // --- Function to generate URL safely --- // Including this function again for robust URL generation function getSafeUrl(pageName) { var url = '#error-generating-url'; // Default fallback 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] mw.util.getUrl not available, using basic fallback.'); var prefix = '/wiki/'; // Default prefix if (typeof mw !== 'undefined' && typeof mw.config !== 'undefined' && typeof mw.config.get === 'function') { prefix = mw.config.get('wgArticlePath', '/wiki/$1').replace('$1', ''); } else { console.warn('[Minerva.js] mw.config.get not available for wgArticlePath.'); } url = prefix + encodeURIComponent(pageName.replace(/ /g, '_')); } } catch (e) { console.error('[Minerva.js] Error within getSafeUrl for "' + pageName + '":', e); } // console.log('[Minerva.js] Generated URL for "' + pageName + '":', url); // Optional debug return url; } try { // Add Categories section header with a class $menu.append('<li class="menu-section-header">— CATEGORIES —</li>'); // Add links with corrected href and custom class $menu.append('<li class="custom-menu-item"><a href="' + getSafeUrl('Animal cruelty cases by location') + '">By Location/地点</a></li>'); $menu.append('<li class="custom-menu-item"><a href="' + getSafeUrl('Animal cruelty cases by species') + '">By Species/物种</a></li>'); $menu.append('<li class="custom-menu-item"><a href="' + getSafeUrl('Animal cruelty cases by year') + '">By Year/年份</a></li>'); // Add Resources section header with a class $menu.append('<li class="menu-section-header">— RESOURCES —</li>'); // Add links with corrected href and custom class $menu.append('<li class="custom-menu-item"><a href="' + getSafeUrl('useful links') + '">Useful links/实用链接</a></li>'); $menu.append('<li class="custom-menu-item"><a href="' + getSafeUrl('documentaries') + '">Documentaries/纪录片</a></li>'); $menu.append('<li class="custom-menu-item"><a href="' + getSafeUrl('psychological study') + '">Psychological study/心理研究</a></li>'); console.log('[Minerva.js] Finished appending items using modified initial code.'); } catch (e) { console.error('[Minerva.js] Error occurred during menu append process:', e); } } else { console.warn('[Minerva.js] Could not find the #p-navigation element to append items.'); } }); console.log('[Minerva.js] Modified ChatGPT/Initial Append code execution finished.'); // Log end