User:Vanished user 1929210/MarkUserRights.js
Appearance
(Redirected from User:逆襲的天邪鬼/MarkUserRights.js)
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:Vanished user 1929210/MarkUserRights. |
/**
* MarkUserRights.js
*
* Mark user rights in Recent Changes, Watchlist, History...
*
* Auto-mark:
window.markUserRights = true;
importScript('User:逆襲的天邪鬼/MarkUserRights.js');
* Manual mode:
importScript('User:逆襲的天邪鬼/MarkUserRights.js');
*/
(function () {
var markIPBE = function () {
var $users = $('a.mw-userlink:not(.mw-anonuserlink)');
var users = {};
$users.each(function (index, link) {
users[link.textContent] = true;
});
var queue1 = [];
var queue2 = [];
var i=0, n=0;
for (var user in users) {
queue1.push(user);
i++;
if (i === 50) {
queue2.push(queue1);
queue1 = [];
n++;
i = 0;
}
}
if (queue1.length > 0) {
queue2.push(queue1);
n++;
}
var sysoplist = [];
var bureaucratlist = [];
var culist = [];
var oslist = [];
var plist = [];
var rlist = [];
var alist = [];
var vlist = [];
var flist = [];
var tlist = [];
var ipbelist = [];
var extendedconfirmedlist = [];
var done = function () {
var j;
for (j=0; j<bureaucratlist.length; j++) {
$('a.mw-userlink[title="User:' + bureaucratlist[j] + '"]').append('<sup style="color:black;">B</sup>');
}
for (j=0; j<culist.length; j++) {
$('a.mw-userlink[title="User:' + culist[j] + '"]').append('<sup style="color:purple;">C</sup>');
}
for (j=0; j<oslist.length; j++) {
$('a.mw-userlink[title="User:' + oslist[j] + '"]').append('<sup style="color:purple;">O</sup>');
}
for (j=0; j<sysoplist.length; j++) {
$('a.mw-userlink[title="User:' + sysoplist[j] + '"]').append('<sup style="color:mediumvioletred;">A</sup>');
}
for (j=0; j<vlist.length; j++) {
$('a.mw-userlink[title="User:' + vlist[j] + '"]').append('<sup style="color:sienna;">v</sup>');
}
for (j=0; j<plist.length; j++) {
$('a.mw-userlink[title="User:' + plist[j] + '"]').append('<sup style="color:sienna;">p</sup>');
}
for (j=0; j<rlist.length; j++) {
$('a.mw-userlink[title="User:' + rlist[j] + '"]').append('<sup style="color:sienna;">r</sup>');
}
for (j=0; j<alist.length; j++) {
$('a.mw-userlink[title="User:' + alist[j] + '"]').append('<sup style="color:sienna;">a</sup>');
}
for (j=0; j<flist.length; j++) {
$('a.mw-userlink[title="User:' + flist[j] + '"]').append('<sup style="color:sienna;">f</sup>');
}
for (j=0; j<tlist.length; j++) {
$('a.mw-userlink[title="User:' + tlist[j] + '"]').append('<sup style="color:sienna;">t</sup>');
}
for (j=0; j<extendedconfirmedlist.length; j++) {
$('a.mw-userlink[title="User:' + extendedconfirmedlist[j] + '"]').append('<sup style="color:green;">e</sup>');
}
for (j=0; j<ipbelist.length; j++) {
$('a.mw-userlink[title="User:' + ipbelist[j] + '"]').append('<sup style="color:green;">i</sup>');
}
};
var process = function (data) {
var users;
if (data.query && data.query.users) {
users = data.query.users;
} else {
users = [];
}
for (var i=0; i<users.length; i++) {
var user = users[i];
if (user.groups) {
if (user.groups.indexOf('ipblock-exempt') > -1) {
ipbelist.push(user.name);
}
if (user.groups.indexOf('bureaucrat') > -1) {
bureaucratlist.push(user.name);
}
if (user.groups.indexOf('checkuser') > -1) {
culist.push(user.name);
}
if (user.groups.indexOf('oversight') > -1) {
oslist.push(user.name);
}
if (user.groups.indexOf('sysop') > -1) {
sysoplist.push(user.name);
}
if (user.groups.indexOf('reviewer') > -1) {
vlist.push(user.name);
}
if (user.groups.indexOf('patroller') > -1) {
plist.push(user.name);
}
if (user.groups.indexOf('rollbacker') > -1) {
rlist.push(user.name);
}
if (user.groups.indexOf('autoreviewer') > -1) {
alist.push(user.name);
}
if (user.groups.indexOf('filemover') > -1) {
flist.push(user.name);
}
if (user.groups.indexOf('templateeditor') > -1) {
tlist.push(user.name);
}
if (user.groups.indexOf('extendedconfirmed') > -1) {
extendedconfirmedlist.push(user.name);
}
}
}
n--;
if (n <= 0) {
done();
}
};
var api = new mw.Api();
for (var j=0; j<queue2.length; j++) {
api.get({
format: 'json',
action: 'query',
list: 'users',
usprop: 'groups',
ususers: queue2[j].join('|')
}).done(process);
}
};
if (window.markUserRights) {
$(function () {
markIPBE();
});
} else {
$(mw.util.addPortletLink('p-cactions', '#', 'Make user rights')).click(function (e) {
e.preventDefault();
markIPBE();
$(this).remove();
});
}
})();