MediaWiki talk:Gadget-markAdmins.js
This script, markAdmins, is a JavaScript gadget which can be enabled or disabled in your Preferences. |
i18n | Gadget translations:
internationalisation needs to be implemented |
Written by Rillke, based on a version of the German Wikipedia. If you find bugs and can't figure out how to fix them yourself, please add a section to this page and I'll see what can be done.
To change the default mark settings, use the following parameter (in your own skin pages: monobook.js/vector.js/common.js). For example, in order to turn on/off flagging (enabled: false/true) of 'stewards's or 'vrt-permissions', following lines must be added: window.markAdminCfg = {
groups: {
'steward': { enabled: false },
'vrt-permissions': { enabled: true }
}
};
For a more complex setting, e.g. turning off flagging of administrators and turning on flagging of 'steward's, 'vrt-permissions' or 'image-reviewer's, or change labels, following lines must be added: window.markAdminCfg = {
groups: {
'sysop': { enabled: false },
'steward': {
label: 'ST',
enabled: true
},
'vrt-permissions': {
label: 'VRT',
enabled: true
},
'image-reviewer': {
label: 'IR',
enabled: true
}
}
};
window.markAdminCfg = {
runOn: ['Special', 'User', 'User_talk', 'Project', 'File', 'Help'],
runOnHistory: true,
runOnTalk: true,
runOnDiff: true
};
window.marksubpages = true;
window.dontmarkmyself = false;
Note: The marked lines should only be needed if you don't have already set
The actual user data is provided in script MediaWiki:Gadget-markAdmins-data.js.window.markAdminCfg . Otherwise you should add missing preferences inside the braces. |
Suggestions
[edit]Since not used in any environment without a window and a document:
- if (typeof(markadmins) == 'undefined')
+ if (window.markadmins === undefined)
and so on -- Rillke(q?) 20:59, 8 June 2014 (UTC)
- Be bold. NNW 08:41, 9 June 2014 (UTC)
addOnloadHook is deprecated since 2011 1, also someone must maintain this script all the time, against popups.js which has a bit similar function (at same time more user status on hover). I'm curious what happens if addOnloadHook is switched off (it should be 2014). Just my comment, keep working. → Perhelion 18:25, 9 June 2014 (UTC)
- As at least some parts of this script seem to be very old, I am thinking about re-adapting it from the original code. But before doing this, I need to know if the script at de is up to date. Can someone verify this? --Didym (talk) 18:58, 9 June 2014 (UTC)
- Yes that is exactly what I also just wanted to say. I've asked some one, but I think this script is up-to-date. → Perhelion 19:09, 9 June 2014 (UTC)
- A adapted version of the source on de is now at User:Didym/markAdmins.js. If this is correct, I will copy it to the gadget's page. --Didym (talk) 22:39, 9 June 2014 (UTC)
- Yes that is exactly what I also just wanted to say. I've asked some one, but I think this script is up-to-date. → Perhelion 19:09, 9 June 2014 (UTC)
A few thoughts on this gadget
[edit]- I would be cautious enabling it on Commons because it may erode existing structures. It encourages users consulting administrators directly instead of using existing infrastructure like Category:Protected edit requests or Commons:Administrators' noticeboard for administrative assistance. This is already the case for a lot of German Wikipedia users who are used with this gadget and the structures there (de.wp has no Category:Protected edit requests; either you drop a note on the talk page and wait or you ask an admin who could be inclined directly)
- Data and program code could be separated to facilitate coding a maintenance bot that could update the list. Adding a second script to this gadget at MediaWiki:Gadgets-definition is fairly easy and cheap.
var markimagereviewers = window.markimagereviewers === true; ...
Please make a config object and simply merge user config.var config = { mark: { imagereviewers: true, otrs: true } }; $.extend(true, config, window.markAdminConfig);
- You will need a dependency to the user module at MediaWiki:Gadgets-definition if you want a user to be allowed to reliably customize it.
- Please validate your script with JSHint and add the options to the script source code, if you didn't use the default option set!
-- Rillke(q?) 07:29, 10 June 2014 (UTC)
Cross-project usage?
[edit]Right now we have copies of this script adapted for the local Admin list on multiple projects. Would it be possible (or rather: how hard would it be) to reprogram this script to work on multiple projects? Basically it should be possible to include the Admin-Lists of all relevant projects, and then just pick the correct one, right? I think this would make maintenance a lot easier. What do others think? Is there somebody with spare time willing to work on this? --Patrick87 (talk) 08:35, 13 June 2014 (UTC)
- That is as this script it does en:User:Amalthea/userhighlighter.js. But I don't know the getJSON object is performant on every page load... I would suggest to make option as button for manual activation, I don't believe you need this every time... (Anyway I'don't use it.) → Perhelion 08:11, 16 June 2014 (UTC)
- CommonsMaintenanceBot is now maintaining a list in its user namespace and will be hopefully soon be permitted to write into the MediaWiki: namespace at Commons so I'll be able to make the data part of the gadget. As soon as this is possible I will give the gadget an overhaul so the code will shrink a lot... -- Rillke(q?) 23:49, 19 July 2014 (UTC)
New version
[edit]I re-wrote the script. Volunteers may test it at test.wikipedia.org (gadget-markadmins
). It separates data from logic and should be easier to adopt to other wikis. It also (mostly) compliant with new coding standards. MediaWiki:Gadget-markAdmins.js, MediaWiki:Gadget-markAdmins-data.js, MediaWiki:Gadget-markAdmins.css. When no one will speak up with issues, I will deploy it to Wikimedia Commons in 10 days. -- Rillke(q?) 13:57, 21 November 2014 (UTC)
- The data page should be in alphabetical order. NNW 14:25, 21 November 2014 (UTC)
- Thanks Rillke for working on this script. @NordNordWest: no need to have ABC imho, because the script is bot updated. --Steinsplitter (talk) 09:47, 24 November 2014 (UTC)
- I didn't know that there is a bot to do that job. Of course that way there is no need for an alphabetical order. NNW 10:52, 24 November 2014 (UTC)
- I think it would be still nice-to-have an alphabetical order. It simply makes nicer diffs. -- Rillke(q?) 09:13, 27 November 2014 (UTC)
- Done -- data is in alphabetical order now. -- Rillke(q?) 17:39, 8 December 2014 (UTC)
- Thanks Rillke for working on this script. @NordNordWest: no need to have ABC imho, because the script is bot updated. --Steinsplitter (talk) 09:47, 24 November 2014 (UTC)
- Also a first thought regarding the data page: From my quick first glance at it, it seems pretty hard to update it with data that can be queried from Special:ListUsers (or the API respectively). Do you have an easy way (or even a tool) at hand to update this list semi-automatically? Adding/removing each change in group membership manually is a quite time-consuming task (at which NNW does a great job here on Commons and on dewiki) but re-creating the list from scratch from time to time by querying and compiling the full list at once might be more desirable in many cases.
A second question standing to reason: Did you already compare execution time of your re-written script compared to the old script? markAdmins was always a very expensive script, we most probably do not want to regress at this... --Patrick87 (talk) 23:37, 23 November 2014 (UTC) - We could have (A-Bot), which account is admin, also a bot. (aka Adminbot - This exists on Wikidata and I think it's useful.) — Revi 04:46, 24 November 2014 (UTC)
- In fact, we have such a bot, which was recently approved. -- Rillke(q?) 09:15, 24 November 2014 (UTC)
- Thanks, I assume most users with a little knowledge of JavaScript can work from there to adapt the bot to their own needs (or are there even plans of your own to migrate this bot to other Wikis, specifically enwiki/dewiki)?
Do you have an answer to the second question yet? I could also do some tests on my own when I get the time... --Patrick87 (talk) 10:02, 24 November 2014 (UTC)- Time and accuracy is an issue here so I would be grateful if you could set up some transparent tests. -- Rillke(q?) 14:50, 24 November 2014 (UTC)
- It should be relatively easy to clone using toollabs:rillke-node and the source code. All they need is to drop tasks they do not want and to have an own config file. But well, if I would be asked by other wikis whether to run the bot there, I would probably accept. -- Rillke(q?) 14:52, 24 November 2014 (UTC)
- I did a quick comparison of runtimes of the old vs. the new script version. (I simply executed the script from Firefox's JavaScript console and measured the runtime using
console.time() / console.timeEnd()
). - It turns out your new version is a little slower (the difference isn't huge though):
- On Commons:Administrators' noticeboard/User problems/Archive 3 execution times are 22.39 ms vs. 26.40 ms (+18%).
- On Commons:Village pump/Archive/2014/10 execution times are 31.10 ms vs. 35.80 ms (+15%).
- (I think those two pages are good samples for a real world scenario; the times are calculated as the mean value of 6 independent measurements each).
- --Patrick87 (talk) 22:46, 24 November 2014 (UTC)
- Can you do some profiling to see what is consuming more time? For example, the new version is using a hook so it works with live preview, ...
- Did you use the minified versions (that are shipped by default through RL or the unminified versions? With which browsers did you test it? -- Rillke(q?) 06:42, 25 November 2014 (UTC)
- I did a quick comparison of runtimes of the old vs. the new script version. (I simply executed the script from Firefox's JavaScript console and measured the runtime using
- Thanks, I assume most users with a little knowledge of JavaScript can work from there to adapt the bot to their own needs (or are there even plans of your own to migrate this bot to other Wikis, specifically enwiki/dewiki)?
- In fact, we have such a bot, which was recently approved. -- Rillke(q?) 09:15, 24 November 2014 (UTC)
New version is live now
[edit]Please report any issues here. If you have the feeling, it is extremely slow now, empty your common.js / skin.js and test again before complaining. -- Rillke(q?) 18:25, 8 December 2014 (UTC)
Legacy JavaScript
[edit]Template:JS migration
Hello! This script has been detected as using deprecated parameters that need to be replaced with the updated version. Examples include addOnloadHook()
needs to be replaced with $()
; all wgGlobalVariables need to be properly gotten with mw.config.get( 'wgGlobalVariable' )
; and addPortletLink
needs to be called with mw.util.addPortletLink
. Please see MW:ResourceLoader/Legacy JavaScript for details. Thank you. — {{U|Technical 13}} (e • t • c) 21:55, 18 January 2015 (UTC)
- @Technical 13: And where is the deprecated code in this script? I can't see it. -- Rillke(q?) 15:56, 19 January 2015 (UTC)
- It was the addOnloadHook mentioned at the top of this talk page that triggered it. There are still coding conventions to fix here (not as important and I'll get back around to them) and there are still parts that need to be properly jQuerified (again, not as critical as why I'm originally here, and I'll get back around to them). — {{U|Technical 13}} (e • t • c) 16:30, 19 January 2015 (UTC)
- No. I can use the DOM directly. Nothing has to be jQueryfied unless we are about to eliminate an issue. What is the issue here? -- Rillke(q?) 16:40, 19 January 2015 (UTC)
- It was the addOnloadHook mentioned at the top of this talk page that triggered it. There are still coding conventions to fix here (not as important and I'll get back around to them) and there are still parts that need to be properly jQuerified (again, not as critical as why I'm originally here, and I'll get back around to them). — {{U|Technical 13}} (e • t • c) 16:30, 19 January 2015 (UTC)
Stewards
[edit]Hello.please add
// is this user a steward? if (stewards_str.indexOf(currUser) !== -1) marker.push( 'S' );
(from Wikidata).Thank you --ديفيد عادل وهبة خليل 2 (talk) 14:54, 1 September 2016 (UTC)
- @ديفيد عادل وهبة خليل 2: Please elaborate why. I see no need for the change. --Steinsplitter (talk) 14:59, 1 September 2016 (UTC)
- @Steinsplitter: The Gadget does not work with the stewards on Commons.Please fix it.Thank you --ديفيد عادل وهبة خليل 2 (talk) 15:05, 1 September 2016 (UTC)
- @ديفيد عادل وهبة خليل 2: The gadget does not 'indicate' Stewards on Commons, because there are no members of that user group 'on Commons'. (see here) Stewards hold rights 'globally', and are listed here, as well as on meta. Reventtalk 21:56, 20 October 2016 (UTC)
- @Steinsplitter: It works with the stewards on Wikidata --ديفيد عادل وهبة خليل 2 (talk) 09:06, 21 October 2016 (UTC)
- The gadget on Wikidata uses a hardcoded list, it does not 'detect' people with the global right. Reventtalk 21:08, 21 October 2016 (UTC)
- @Steinsplitter: It works with the stewards on Wikidata --ديفيد عادل وهبة خليل 2 (talk) 09:06, 21 October 2016 (UTC)
- @ديفيد عادل وهبة خليل 2: The gadget does not 'indicate' Stewards on Commons, because there are no members of that user group 'on Commons'. (see here) Stewards hold rights 'globally', and are listed here, as well as on meta. Reventtalk 21:56, 20 October 2016 (UTC)
- @Steinsplitter: The Gadget does not work with the stewards on Commons.Please fix it.Thank you --ديفيد عادل وهبة خليل 2 (talk) 15:05, 1 September 2016 (UTC)
- This gadget uses a hardcoded list, too, it's MediaWiki:Gadget-markAdmins-data.js. User:Rillke just would have to instruct his bot to add the stewards to the data file, they are already part of the gadget:
steward: { label: 'S', legacyName: 'steward', legacyLabelId: 'stewtxt' }
- I assume he just forgot to instruct the bot and nobody noticed it until now. NNW 12:46, 27 October 2016 (UTC)
- @ديفيد عادل وهبة خليل 2: Individual marking worked all the time, but there was no good explanation, how it had to be done. Jdx has added this explanation now as a comment into the Gadget. @Revent: Your comment above is months old, so maybe you meanwhile noticed it yourself, but some of the listed stewards in MediaWiki:Gadget-markAdmins-data.js are quite active in Commons. — Speravir – 16:25, 5 December 2016 (UTC)
It turns out there is indeed an issue: When a groups is configured not to be shown, and a user is in groups that are listed after that group which are configured to be shown, the latter aren't. Example: DerHexer is (A/S/P), however, if you configure to hide the S, what you get is DerHexer (A) despite it should be DerHexer (A/P). -- Rillke(q?) 16:35, 28 July 2019 (UTC)
{{Edit request}} Please apply this change with exactly that reason. I expect any admin be able to read Diffs, therefore every admin should be able to fulfil this request. -- Rillke(q?) 16:35, 28 July 2019 (UTC)
- Done --Didym (talk) 16:45, 28 July 2019 (UTC)
Labels for OTRS members and image reviewers
[edit]{{Edit request}}
How about adding a short comment behind the labels for both OTRS-member groups and image reviewers. For me as someone, who is not a native English speaker, these are not obvious at first. For OTRS members I can think of a derivation from “permission” and the G for “global”, but the L for image reviewers is obscure to me. Why not use IR
instead? — Speravir – 19:12, 7 December 2016 (UTC)
- Those labels came from my personal script. I didn't want to use O for the OTRS group because of the OS already in use, hence the P for permissions. The L means license reviewer, my intention was to keep the labels as short as possible, therefore just L instead of LR. --Didym (talk) 20:50, 7 December 2016 (UTC)
- Aargh, L as in “license”, yes! Thank you, Didym. — Speravir – 23:10, 7 December 2016 (UTC)
- So anything to be done here? --Zhuyifei1999 (talk) 02:44, 8 December 2016 (UTC)
- Zhuyifei1999 My edit request was for a potential short comment, what the letters stand for, at least for these three mentioned here: P, GP and L. Actually I’m only interested in having this information somewhere, but it is not possible to add this on the page, but outside of script code. Didym, what do you think as original introducer, where this info could best be added? — Speravir – 17:13, 8 December 2016 (UTC)
- I just noticed, that Perhelion added a box on the top of this page. I added there myself the info I missed. Therefore my original request is obsolete (hoping that any other potential user asking for the label origins finds this), but perhaps it should be added into the script itself, that also the labels can be changed with user config, cf. Perhelion’s addition in the box. — Speravir – 01:16, 9 December 2016 (UTC)
- @Speravir: OK, I am closing ER as per your statement above. --jdx Re: 22:46, 13 December 2016 (UTC)
- So anything to be done here? --Zhuyifei1999 (talk) 02:44, 8 December 2016 (UTC)
- Aargh, L as in “license”, yes! Thank you, Didym. — Speravir – 23:10, 7 December 2016 (UTC)
(after set it opt-off by default, moved here from other section)
- btw: I never saw the (P)s before, and wondered what that could mean. I found out that it marks OTRS-members, but I think thats a bit confusing to use a (P) for that an (O) would be much more self-undstandable. regards. --JuTa 04:20, 31 October 2017 (UTC)
- I know, but as (OS) was already in use, I tried to find something without O, hence the (P), as this marks access to the permissions-queues. --Didym (talk) 09:51, 31 October 2017 (UTC)
- Yes, it stays for OTRS-Permission- / Permission requests member, and I'm fine with that. This marker is now turned off by default again!? (@JuTa and Artix Kreiger: ) -- User: Perhelion 11:17, 2 November 2017 (UTC)
- I know, but as (OS) was already in use, I tried to find something without O, hence the (P), as this marks access to the permissions-queues. --Didym (talk) 09:51, 31 October 2017 (UTC)
- I know I'm commenting on an old thread, but what about "OT" instead for OTRS members, instead of P? That should differentiate it against oversighters. pandakekok9 08:53, 15 January 2021 (UTC)
- I think "O" is ok, I don't see any confusion as OS is always OS and not O. --Krd 09:03, 15 January 2021 (UTC)
Behavior
[edit]{{Editrequest}} Perhelion, du als Fachmann dienst jetzt mal als passendes Beispiel ;).
- [[User:Perhelion]]: User:Perhelion
- [[:m:User:Perhelion]]: m:User:Perhelion
- [[:mw:User:Perhelion]]: mw:User:Perhelion
- [[:de:User:Perhelion]]: de:User:Perhelion
- [[w:de:User:Perhelion]]: w:de:User:Perhelion
- [[:de:s:User:Perhelion]]: de:s:User:Perhelion
- [[:s:de:User:Perhelion]]: s:de:User:Perhelion
- [[File:Mediawiki-logo.png|x16px|link=:mw:User:Perhelion]] [[File:Wikimedia Community Logo optimized.svg|x16px|link=:m:User:Perhelion]]:
In my opinion outgoing links to other projects should better not show that (here misleading) additional marker as well as image links shouldn't do so because of better appearance and viewability. Pinging Zhuyifei1999 as well, my js level is quite low... --Achim (talk) 15:07, 25 October 2017 (UTC)
- Done Thank you! PS: I optimized the speed also a bit. -- User: Perhelion 02:54, 27 October 2017 (UTC)
- Probably related to this change, the (P) and (L) markers are gone now. @Perhelion: could you have a look at this again? --Didym (talk) 06:27, 27 October 2017 (UTC)
- @Didym: Yes and sorry I removed the deprecated user config method, please use only the above mentioned config (maybe someone could improve it).
Or is there really a backward compatibility to (old original script) needed?-- User: Perhelion 10:11, 27 October 2017 (UTC)- PPS: That is very remarkable, (after a quick search) you are the only user which used this (markimagereviewers, only one other had markotrs). -- User: Perhelion 11:09, 27 October 2017 (UTC)
- @Didym: Yes and sorry I removed the deprecated user config method, please use only the above mentioned config (maybe someone could improve it).
- Probably related to this change, the (P) and (L) markers are gone now. @Perhelion: could you have a look at this again? --Didym (talk) 06:27, 27 October 2017 (UTC)
Missing OS
[edit]Although listed in MediaWiki:Gadget-markAdmins-data.js there is no "OS" shown behind Raymond's name. NNW 16:12, 11 September 2018 (UTC)
- I have the "OS" behind his name, so this doesn't seem to be a general problem. --Didym (talk) 20:55, 11 September 2018 (UTC)
- NNW, does this issue still persist for you? I see OS behind their name. If yes, pleas mark this thread as resolved. Thank you. -- Rillke(q?) 16:04, 28 July 2019 (UTC)
- It’s okay now. NNW 11:51, 29 July 2019 (UTC)
Done
Interface admins and template editors
[edit]Would it be possible to mark interface admins and template editors too? I'd like to see them marked as well. Thanks, pandakekok9 08:50, 15 January 2021 (UTC)
- +1 --Krd 09:01, 15 January 2021 (UTC)
- Done Interface admins are now marked as IA by default. Template editors are NOT marked by default, and one should enable it through their own common.js page like this. Furthermore, they should be added to the reports. I opened a thread about this at MediaWiki talk:Gadget-markAdmins-data.js#Template editors. 4nn1l2 (talk) 17:06, 13 February 2022 (UTC)
Label doubling issue
[edit]{{Edit request}}
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) 19:56, 3 July 2023 (UTC)
- Done —Mdaniels5757 (talk • contribs) 18:39, 29 July 2023 (UTC)