User:KirkLU/js/markRight.js
外观
< User:KirkLU | js
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
/*
取自 oldid=46107689 markIPBE.js 原作者:逆襲的天邪鬼
在最近修改、监视列表、条目历史记录等位置以特殊格式显示有特殊权限的用户
更新項目:
1.項目矩陣
2.用顏色標記權限並提示該標記的權限名稱
3.權限用for 迴圈重複操作來呈現,並設定上限
4.不僅限於IPBE用戶。
5.支援顯示最近更改的按鈕
更新者:小躍
*/
$(function () {
var markRight = 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 bureaucratlist = []; var culist = []; var oslist = []; var sysoplist = []; var iadlist=[];
var plist = []; var rlist = []; var arlist = []; var tplist = []; var tslist = []; var ipbelist = [];
var acrelist=[]; var masmlist = []; var eclist=[]; var aclist=[];
var memberlist=[bureaucratlist,culist,oslist,sysoplist,iadlist,plist,rlist,arlist,tplist,tslist,ipbelist,acrelist,masmlist,eclist,aclist];
var membername=['bureaucrat','checkuser','oversight','sysop','interface-admin','patroller','rollbacker','autoreviewer','templateeditor','transwiki','massmessage','accountcreator','ipblock-exempt','extendedconfirmed','autoconfirmed'];
var membertag=['#D00000','red','#FF4040','orange','#FFD700','#4DE680','#3CB371','#008000','#00BFFF','blue','#191970','#191970','#8B00FF','#909090','#C0C0C0'];
var done = function () {
var k;
var j;
for(k=0;k<memberlist.length;k++){
for (j=0; j<memberlist[k].length; j++) {
$('a.mw-userlink[title="User:' + memberlist[k][j] + '"]')
.append('<sup style="color:'+membertag[k]+';background-color:transparent" title="'+membername[k]+'">★</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) {
var m=0;
for(m=0;m<memberlist.length;m++){
if (user.groups.indexOf(membername[m]) > -1) {
memberlist[m].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(mw.config.get('wgPageName')=='Special:用户列表'){}else{
markRight();
$('.oo-ui-flaggedElement-progressive.oo-ui-buttonWidget > a').click(
function(){
setTimeout(function(){markRight()},7000);
}
);
}
});