MediaWiki:Common.js: Difference between revisions
Appearance
No edit summary Tag: Reverted |
No edit summary Tag: Manual revert |
||
| Line 1: | Line 1: | ||
/* ========================================================= | /* ========================================================= | ||
Lumenward: | Lumenward: Top-level header links (Vector 2022) | ||
- GitHub + Discord next to each other | |||
- Not in dropdown | - Not in dropdown | ||
========================================================= */ | ========================================================= */ | ||
mw. | mw.loader.using(['mediawiki.util'], function () { | ||
// | // ====== CHANGE THESE ====== | ||
var | var GITHUB_URL = 'https://github.com/YOUR_GITHUB_ORG_OR_REPO'; | ||
var DISCORD_URL = 'https://discord.gg/YOUR_INVITE_CODE'; | |||
// ========================== | |||
// | // Find a stable header container (prefer right side, fallback to header) | ||
var | var targets = [ | ||
document.querySelector('.mw-header .vector-header-end') | document.querySelector('.mw-header .vector-header-end'), | ||
document.querySelector('.mw-header .mw-header-user') | document.querySelector('.mw-header .mw-header-user'), | ||
document.querySelector('.mw-header .vector-user-links'); | document.querySelector('.mw-header .vector-user-links'), | ||
document.querySelector('.mw-header') | |||
].filter(Boolean); | |||
if (! | if (!targets.length) return; | ||
// 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) { | |||
var a = document.createElement('a'); | |||
a.id = id; | |||
a.href = href; | |||
a.textContent = label; | |||
a.target = '_blank'; | |||
a.rel = 'noopener'; | |||
a.style.marginRight = '12px'; | |||
a.style.fontWeight = '600'; | |||
a.style.textDecoration = 'none'; | |||
a.style.whiteSpace = 'nowrap'; | |||
return a; | |||
} | |||
// Insert | 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 | |||
// (discord first-child, github before it so order becomes GitHub then Discord) | |||
targets[0].insertBefore(discord, targets[0].firstChild); | |||
targets[0].insertBefore(github, discord); | |||
}); | }); | ||
Revision as of 11:51, 14 December 2025
/* =========================================================
Lumenward: Top-level header links (Vector 2022)
- GitHub + Discord next to each other
- Not in dropdown
========================================================= */
mw.loader.using(['mediawiki.util'], function () {
// ====== CHANGE THESE ======
var GITHUB_URL = 'https://github.com/YOUR_GITHUB_ORG_OR_REPO';
var DISCORD_URL = 'https://discord.gg/YOUR_INVITE_CODE';
// ==========================
// Find a stable header container (prefer right side, fallback to header)
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;
// 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) {
var a = document.createElement('a');
a.id = id;
a.href = href;
a.textContent = label;
a.target = '_blank';
a.rel = 'noopener';
a.style.marginRight = '12px';
a.style.fontWeight = '600';
a.style.textDecoration = 'none';
a.style.whiteSpace = 'nowrap';
return 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
// (discord first-child, github before it so order becomes GitHub then Discord)
targets[0].insertBefore(discord, targets[0].firstChild);
targets[0].insertBefore(github, discord);
});