MediaWiki talk:Gadget-markAdmins.js

From Meta, a Wikimedia project coordination wiki

GS[edit]

{{editrequest}} Expand to include GS..

@groups
			global_sysop: {
				label: 'GS',
				legacyName: 'global_sysop',
				legacyLabelId: 'gstxt',
				enabled: true
			},

~riley (talk) 22:45, 29 January 2020 (UTC)[reply]

Done via Special:Diff/19758330. — regards, Revi 22:51, 29 January 2020 (UTC)[reply]

Add Staffs?[edit]

{{edit protected}}

			staff: {
				label: 'Staff',
				legacyName: 'staff',
				legacyLabelId: 'stafftxt',
				enabled: true
			},
Hello :) I propose adding Staffs to list, is it okay or unnecessary? If okay i can prepare list for -data.js --MrJaroslavik (talk) 21:22, 2 December 2020 (UTC)[reply]
I'm deactivating the template above as right now there's no request but a proposal. Once there's consensus that adding Staff would be okay, please reactivate the edit protected template. Also, this should probably be advertised in Meta:Babel in order to achieve minimum participation. Regards, —MarcoAurelio (talk) 14:58, 9 December 2020 (UTC)[reply]

Label doubling issue[edit]

See the first image on the right and find User page (A/IA) (A/IA). Can we fix this label doubling issue in the so-called left-navigation?

This gadget looks at anchors in mw.util.$content, and this is basically the same as document.querySelector('.mw-body')[1]. This is the cause of the problem because left-navigation is included in .mw-body in vector-2022 (and also in timeless), while it's not in vector. This means that in vector-2022, #ca-nstab-user is manually pushed into the array although the array(-like object) inherently contains the anchor as an element of the array:

anchors = $content[0].getElementsByTagName('a');
// Add also the userpage link
if (isUserpage && !this.fullPageProcessed &&
    ((isUserpage = document.getElementById('ca-nstab-user')) &&
    (isUserpage = isUserpage.getElementsByTagName('a')))) {
    anchors = Array.from(anchors);
    anchors.push(isUserpage[0]);
}

The easiest way to resolve this issue is to check whether #ca-nstab-user is already in the collected anchors:

anchors = $content[0].getElementsByTagName('a');
// Add also the userpage link
var containsNstabUser = !!$content[0].querySelector('#ca-nstab-user');
if (!containsNstabUser && isUserpage && !this.fullPageProcessed &&
    ((isUserpage = document.getElementById('ca-nstab-user')) &&
    (isUserpage = isUserpage.getElementsByTagName('a')))) {
    anchors = Array.from(anchors);
    anchors.push(isUserpage[0]);
}

We can get rid of mw.util.$content itself, but this patch would suffice for the time being. Dragoniez (talk) 18:28, 3 July 2023 (UTC)[reply]

Anyway, Array.from(anchors) should be Array.prototype.slice.call(anchors) if we limit ourselves to ES5 syntax for browser compatibility because it's an ES6 feature. Dragoniez (talk) 18:55, 3 July 2023 (UTC)[reply]