// Insert custom Minerva menu items (client-side fallback) mw.loader.using('mediawiki.util').then(function () {

   const ITEMS = [
       { text: 'Classes', href: mw.util.getUrl('Category:Classes') },
       { text: 'Manufacturers', href: mw.util.getUrl('Category:Manufacturers') },
       { text: 'Upload Photo', href: mw.util.getUrl('Special:Upload') }
   ];
   function findMenuContainer() {
       // Try a list of likely Minerva menu containers
       const selectors = [
           '.mw-mf-main-menu',        // MobileFrontend menu class
           '.minerva-main-menu',
           '.minerva-menu',
           '.mw-navigation',         // fallback
           '.menu'                   // very generic fallback
       ];
       for (const s of selectors) {
           const el = document.querySelector(s);
           if (el) return el;
       }
       // Find any ul that contains "Home" or "Random" - good indicator
       const uls = document.querySelectorAll('ul,nav');
       for (const u of uls) {
           const text = u.textContent || ;
           if (/Home/.test(text) && /Random/.test(text)) return u;
       }
       return null;
   }
   function addMenuItems() {
       const menu = findMenuContainer();
       if (!menu) return;
       // Normalize to UL container (if nav, find its ul)
       let list = menu.tagName === 'UL' ? menu : menu.querySelector('ul') || menu;
       ITEMS.forEach(item => {
           // avoid duplicates
           if (document.querySelector('a[href="' + item.href + '"]')) return;
           // build a list-item similar to existing ones if possible
           const li = document.createElement('li');
           // try to copy classes from existing li to match style
           const sampleLi = list.querySelector('li');
           if (sampleLi) li.className = sampleLi.className;
           const a = document.createElement('a');
           a.href = item.href;
           a.textContent = item.text;
           // copy sample anchor classes (if any) for visual consistency
           const sampleA = list.querySelector('a');
           if (sampleA) a.className = sampleA.className;
           li.appendChild(a);
           list.appendChild(li);
       });
   }
   // Run once now
   addMenuItems();
   // Re-run when content is (re)inserted (MobileFrontend dynamic rendering)
   mw.hook('wikipage.content').add(function ($content) {
       try { addMenuItems(); } catch (e) { /* ignore */ }
   });
   // Also observe DOM changes as a backup
   const observer = new MutationObserver(function () {
       addMenuItems();
   });
   observer.observe(document.body, { childList: true, subtree: true });

});