<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>http://raildb.uk/index.php?action=history&amp;feed=atom&amp;title=MediaWiki%3ACommon.js%3A</id>
	<title>MediaWiki:Common.js: - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://raildb.uk/index.php?action=history&amp;feed=atom&amp;title=MediaWiki%3ACommon.js%3A"/>
	<link rel="alternate" type="text/html" href="http://raildb.uk/index.php?title=MediaWiki:Common.js:&amp;action=history"/>
	<updated>2026-05-06T14:32:10Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.15</generator>
	<entry>
		<id>http://raildb.uk/index.php?title=MediaWiki:Common.js:&amp;diff=148&amp;oldid=prev</id>
		<title>AidanCKY: Created page with &quot;// 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 sel...&quot;</title>
		<link rel="alternate" type="text/html" href="http://raildb.uk/index.php?title=MediaWiki:Common.js:&amp;diff=148&amp;oldid=prev"/>
		<updated>2025-10-11T20:35:03Z</updated>

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