MediaWiki:Common.js
From Artifacts of Capitalism
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', function () {
function addUserMenuLinks() {
// Only proceed if the user is logged in
if (!mw.config.get('wgUserName')) return;
// Look for the user menu (the "blue guy") dropdown
const $menu = $('.cmln-personal-tools ul');
if ($menu.length === 0) {
// If not found, try again in 100ms
setTimeout(addUserMenuLinks, 100);
return;
}
// Avoid adding duplicates if already present
if ($menu.data('custom-links-added')) return;
const links = [
{
href: '/index.php?title=Special:Upload',
label: 'Upload a File'
},
{
href: '/index.php?title=Special:ListFiles',
label: 'All Files'
},
{
href: '/index.php?title=Help:Contents',
label: 'Help'
},
{
href: '/index.php?title=Special:SpecialPages',
label: 'Special pages'
}
];
links.forEach(link => {
const $li = $('<li>')
.addClass('mw-list-item')
.append($('<a>').attr('href', link.href).text(link.label));
$menu.append($li);
});
// Mark as populated to prevent duplication
$menu.data('custom-links-added', true);
}
$(addUserMenuLinks);
});