Jump to content

MediaWiki:Common.js: Difference between revisions

From λ LUMENWARD
No edit summary
No edit summary
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
/* =========================================================
/* =========================================================
   Lumenward: Top-level header links (Vector 2022)
   Lumenward: Top header links (Vector 2022, SAFE)
   - GitHub + Discord next to each other
   Places GitHub + Discord next to the logo (left lane)
  - Not in dropdown
   ========================================================= */
   ========================================================= */


mw.loader.using(['mediawiki.util'], function () {
mw.loader.using(['mediawiki.util'], function () {
  if (document.getElementById('lumenward-header-links')) return;


   // ====== CHANGE THESE ======
   var container =
  var GITHUB_URL  = 'https://github.com/YOUR_GITHUB_ORG_OR_REPO';
    document.querySelector('.vector-header-start') ||
  var DISCORD_URL = 'https://discord.gg/YOUR_INVITE_CODE';
    document.querySelector('.mw-header');
  // ==========================


   // Find a stable header container (prefer right side, fallback to header)
   if (!container) return;
  var targets = [
    document.querySelector('.mw-header .vector-header-end'),
    document.querySelector('.mw-header .mw-header-user'),
    document.querySelector('.mw-header .vector-user-links'),
    document.querySelector('.mw-header')
  ].filter(Boolean);


   if (!targets.length) return;
   var wrap = document.createElement('div');
  wrap.id = 'lumenward-header-links';
  wrap.style.display = 'inline-flex';
  wrap.style.gap = '14px';
  wrap.style.marginLeft = '16px';
  wrap.style.alignItems = 'center';
 
var links = [
  { text: 'GitHub', url: 'https://github.com/Lumenward' },
  { text: 'Discord', url: 'https://discord.gg/Kc9DtJUG' },
];


  // Remove any existing injected links to avoid duplicates
  ['lumenward-github-link', 'lumenward-discord-link'].forEach(function (id) {
    var el = document.getElementById(id);
    if (el) el.remove();
  });


   function makeLink(id, href, label) {
   links.forEach(function (l) {
     var a = document.createElement('a');
     var a = document.createElement('a');
     a.id = id;
     a.href = l.url;
    a.href = href;
     a.textContent = l.text;
     a.textContent = label;
     a.target = '_blank';
     a.target = '_blank';
     a.rel = 'noopener';
     a.rel = 'noopener';
    a.style.marginRight = '12px';
     a.style.fontWeight = '600';
     a.style.fontWeight = '600';
     a.style.textDecoration = 'none';
     a.style.textDecoration = 'none';
     a.style.whiteSpace = 'nowrap';
     a.style.color = '#000';
     return a;
     wrap.appendChild(a);
   }
   });
 
  var github = makeLink('lumenward-github-link', GITHUB_URL, 'GitHub');
  var discord = makeLink('lumenward-discord-link', DISCORD_URL, 'Discord');


   // Insert both at the beginning of the chosen header container
   container.appendChild(wrap);
  // (discord first-child, github before it so order becomes GitHub then Discord)
  targets[0].insertBefore(discord, targets[0].firstChild);
  targets[0].insertBefore(github, discord);
});
});

Latest revision as of 21:38, 5 January 2026

/* =========================================================
   Lumenward: Top header links (Vector 2022, SAFE)
   Places GitHub + Discord next to the logo (left lane)
   ========================================================= */

mw.loader.using(['mediawiki.util'], function () {
  if (document.getElementById('lumenward-header-links')) return;

  var container =
    document.querySelector('.vector-header-start') ||
    document.querySelector('.mw-header');

  if (!container) return;

  var wrap = document.createElement('div');
  wrap.id = 'lumenward-header-links';
  wrap.style.display = 'inline-flex';
  wrap.style.gap = '14px';
  wrap.style.marginLeft = '16px';
  wrap.style.alignItems = 'center';

var links = [
  { text: 'GitHub', url: 'https://github.com/Lumenward' },
  { text: 'Discord', url: 'https://discord.gg/Kc9DtJUG' },
];


  links.forEach(function (l) {
    var a = document.createElement('a');
    a.href = l.url;
    a.textContent = l.text;
    a.target = '_blank';
    a.rel = 'noopener';
    a.style.fontWeight = '600';
    a.style.textDecoration = 'none';
    a.style.color = '#000';
    wrap.appendChild(a);
  });

  container.appendChild(wrap);
});