MediaWiki:Common.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.
/* =========================================================
Lumenward: Add a top-level GitHub link in the header (Vector 2022)
========================================================= */
mw.loader.using(['mediawiki.util'], function () {
var url = 'https://github.com/YOUR_GITHUB_ORG_OR_REPO'; // <-- CHANGE THIS
var text = 'GitHub';
// Vector 2022 header right area (try a few known containers)
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;
// Avoid duplicates if cache reloads
if (document.getElementById('lumenward-github-link')) return;
var a = document.createElement('a');
a.id = 'lumenward-github-link';
a.href = url;
a.textContent = text;
a.target = '_blank';
a.rel = 'noopener';
a.style.marginRight = '12px';
a.style.fontWeight = '600';
a.style.textDecoration = 'none';
// Insert before the user menu area if possible; otherwise append to header end
targets[0].insertBefore(a, targets[0].firstChild);
});