Jump to content

MediaWiki:Common.js

From Once Human Guide
Revision as of 20:06, 8 April 2026 by Bones (talk | contribs)

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.
mw.loader.using('mediawiki.util').then(function () {
    $(function () {

        // Change Discussion tab to Discord
        const talkTab = document.querySelector('#ca-talk a');

        if (talkTab) {
            talkTab.textContent = 'Discord';
            talkTab.href = 'https://discord.gg/FZtkXeGeUA';
            talkTab.target = '_blank';
            talkTab.rel = 'noopener noreferrer';

            talkTab.addEventListener('click', function (e) {
                e.preventDefault();
                window.open('https://discord.gg/FZtkXeGeUA', '_blank');
            });
        }

        // Add Road Map tab with matching tab classes
        const tabList = document.querySelector('#p-associated-pages .vector-menu-content-list, #p-namespaces .vector-menu-content-list');
        const existingTab = document.querySelector('#ca-talk, #ca-view');

        if (tabList && !document.getElementById('ca-roadmap')) {
            const li = document.createElement('li');
            li.id = 'ca-roadmap';

            if (existingTab) {
                li.className = existingTab.className;
                li.removeAttribute('class');
                li.className = existingTab.className.replace(/\bselected\b|\bactive\b/g, '').trim();
            } else {
                li.className = 'mw-list-item';
            }

            const a = document.createElement('a');
            a.href = 'https://ohwikiguide.com/index.php/Road_Map';
            a.title = 'Road Map';

            const span = document.createElement('span');
            span.textContent = 'Road Map';

            a.appendChild(span);
            li.appendChild(a);
            tabList.appendChild(li);
        }

    });
});