MediaWiki:Common.js: Difference between revisions
From Artifacts of Capitalism
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
mw.loader.using('mediawiki.util', function () { | mw.loader.using('mediawiki.util', function () { | ||
function | function debugUserMenuInjection() { | ||
if (!mw.config.get('wgUserName')) { | |||
if (!mw.config.get('wgUserName')) return; | console.log('[UserMenuTest] Not logged in.'); | ||
return; | |||
} | |||
const $menu = $('.cmln-personal-tools ul'); | const $menu = $('.cmln-personal-tools ul'); | ||
if ($menu.length === 0) { | if ($menu.length === 0) { | ||
console.log('[UserMenuTest] Menu not found, retrying...'); | |||
setTimeout( | setTimeout(debugUserMenuInjection, 200); | ||
return; | return; | ||
} | } | ||
console.log('[UserMenuTest] Menu found. Injecting link.'); | |||
const $testLink = $('<li>') | |||
.addClass('mw-list-item') | |||
.append( | |||
$('<a>') | |||
.attr('href', '#') | |||
.text('✅ Injected Link') | |||
.css({ | |||
background: 'firebrick', | |||
color: 'white', | |||
padding: '5px', | |||
display: 'block' | |||
}) | |||
); | |||
$menu.append($testLink); | |||
$menu. | |||
} | } | ||
$( | $(debugUserMenuInjection); | ||
}); | }); | ||
Revision as of 20:30, 14 July 2025
mw.loader.using('mediawiki.util', function () {
function debugUserMenuInjection() {
if (!mw.config.get('wgUserName')) {
console.log('[UserMenuTest] Not logged in.');
return;
}
const $menu = $('.cmln-personal-tools ul');
if ($menu.length === 0) {
console.log('[UserMenuTest] Menu not found, retrying...');
setTimeout(debugUserMenuInjection, 200);
return;
}
console.log('[UserMenuTest] Menu found. Injecting link.');
const $testLink = $('<li>')
.addClass('mw-list-item')
.append(
$('<a>')
.attr('href', '#')
.text('✅ Injected Link')
.css({
background: 'firebrick',
color: 'white',
padding: '5px',
display: 'block'
})
);
$menu.append($testLink);
}
$(debugUserMenuInjection);
});