User:Wong128hk/Markright.js
外观
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
/**
* 取自 oldid=46135902
* MediaWiki:Gadget-MarkRights.js
*
* 在最近修改、监视列表、条目历史记录等位置以特殊格式显示有特殊权限的用户
*
*/
$(function () {
var markUG = 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 interfaceadminlist = [];
var bureaucratlist = [];
var culist = [];
var oslist = [];
var plist = [];
var rlist = [];
var alist = [];
var ipbelist = [];
var comlist = [];
var acclist = [];
var floodlist = [];
var mmslist = [];
var botlist = [];
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<interfaceadminlist.length; j++) {
$('a.mw-userlink[title="User:' + interfaceadminlist[j] + '"]').append('<sup style="color:mediumvioletred;">I</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<acclist.length; j++) {
$('a.mw-userlink[title="User:' + acclist[j] + '"]').append('<sup style="color:blue;">m</sup>');
}
for (j=0; j<mmslist.length; j++) {
$('a.mw-userlink[title="User:' + mmslist[j] + '"]').append('<sup style="color:blue;">s</sup>');
}
// 确认权限
for (j=0; j<comlist.length; j++) {
$('a.mw-userlink[title="User:' + comlist[j] + '"]').append('<sup style="color:green;">c</sup>');
}
// 机器权限
for (j=0; j<botlist.length; j++) {
$('a.mw-userlink[title="User:' + botlist[j] + '"]').append('<sup style="color:blue;">b</sup>');
}
for (j=0; j<floodlist.length; j++) {
$('a.mw-userlink[title="User:' + floodlist[j] + '"]').append('<sup style="color:mediumvioletred;">f</sup>');
}
// IPBE
for (j=0; j<ipbelist.length; j++) {
$('a.mw-userlink[title="User:' + ipbelist[j] + '"]').append('<sup style="color:green;">E</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('bureaucrat') > -1) {
bureaucratlist.push(user.name);
}
// Due to Office Actions
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('interface-admin') > -1) {
interfaceadminlist.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('accountcreator') > -1) {
acclist.push(user.name);
}
if (user.groups.indexOf('massmessage-sender') > -1) {
mmslist.push(user.name);
}
if (user.groups.indexOf('confirmed') > -1) {
comlist.push(user.name);
}
if (user.groups.indexOf('bot') > -1) {
botlist.push(user.name);
}
if (user.groups.indexOf('flood') > -1) {
floodlist.push(user.name);
}
if (user.groups.indexOf('ipblock-exempt') > -1) {
ipbelist.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);
}
};
markUG();
});