MediaWiki:Gadget-markadmins.js: Difference between revisions

Jump to navigation Jump to search
m
no edit summary
(import)
 
mNo edit summary
 
(9 intermediate revisions by 5 users not shown)
Line 1: Line 1:
// rewritten by [[m:User:Hoo man]]; 2012-08-26, adapted by [[User:Obersachse]], optimized by [[User:Jack who built the house]]
// rewritten by [[m:User:Hoo man]]; 2012-08-26, adapted by [[User:Obersachse]], optimized by [[User:Jack who built the house]]
// For attribution: [[MediaWiki:Gadget-markadmins.js]]
(function () {
(function () {


var userSet;
var userSet;
var users_talkLinkOnly;


var userSetTips = {
var userSetTips = {
'A' : 'administrator',
'A' : 'administrator',
'B' : 'burecrat',
'B' : 'bureaucrat',
'C' : 'checkuser',
'CU' : 'checkuser',
'F' : 'interface administrator',
'IA' : 'interface administrator',
'S' : 'Steward',
'IWA' : 'interwiki administrator',
'NSS': 'non-steward suppressor',
'OS': 'suppressor',
'S' : 'steward',
'SA': 'system administrator',
};
};


Line 30: Line 33:
);
);
}
}
var $links = $content.find('a[title^="Участни"], a[title^="Обсуждение участни"]');
var $links = $content.find('a[title^="User"], a[title^="Talk"]');
 
 
if (runNum === 2) {
if (runNum === 2) {
if ($links.length === prevLinksCount) {
if ($links.length === prevLinksCount) {
Line 52: Line 53:
}
}


$.getJSON(mw.util.wikiScript(), {
new mw.Api().get({
title: 'MediaWiki:Gadget-markadmins.json',
action: 'query',
action: 'raw'
list: 'allusers',
}).done(function (ans) {
augroup: 'sysop|bureaucrat|checkuser|interface-admin|interwiki-admin|non-stewardsuppress|suppress|steward|sysadmin',
userSet = ans.userSet;
auprop: 'groups',
users_talkLinkOnly = ans.users_talkLinkOnly;
aulimit: 500,
format: 'json',
formatversion: 2
}).done(function(ans) {
var list = ans.query.allusers,
groups = ['sysop', 'bureaucrat', 'checkuser', 'interface-admin', 'interwiki-admin', 'non-stewardsuppress', 'suppress', 'steward', 'sysadmin'],
key = ['A', 'B', 'CU', 'IA', 'IWA', 'NSS', 'OS', 'S', 'SA'],
userSet = {};
for (var i = 0; i < key.length; i++) {
userSet[key[i]] = [];
}
for (var i = 0; i < list.length; i++) {
for (var j = 0; j < groups.length; j++) {
if (list[i].groups.includes(groups[j])) {
userSet[key[j]].push(list[i].name);
}
}
}
$links.each(function (i, link) {
$links.each(function (i, link) {
if (!link.parentNode ||
if (!link.parentNode ||
Line 67: Line 88:
var matches, user, flags = [], tips = [], flag;
var matches, user, flags = [], tips = [], flag;
matches = /^Участни(?:к|ца):(.+)|Обсуждение участни(?:ка|цы):(.+)/.exec(link.title);
matches = /^User:(.+)|Talk:(.+)/.exec(link.title);
if (!matches) return;
if (!matches) return;
if (matches[2] && users_talkLinkOnly.indexOf(matches[2]) !== -1) {
if (matches[2]) {
if ($(link).parent().hasClass('mw-usertoollinks') || link.textContent.match(/обс/i)) return;
if ($(link).parent().hasClass('mw-usertoollinks') || link.textContent.match(/обс/i)) return;
matches[1] = matches[2];
matches[1] = matches[2];
Line 76: Line 96:
return;
return;
}
}
user = decodeURIComponent(matches[1]);
user = decodeURIComponent(matches[1]);
if (link.href.indexOf('redlink=1') !== -1) {
if (link.href.indexOf('redlink=1') !== -1) {
user = user.replace(/ \([^\)]+\)$/, '');
user = user.replace(/ \([^\)]+\)$/, '');
}
}
for (flag in userSet) {
for (flag in userSet) {
if (userSet[flag].indexOf(user) !== -1 && userSetTips[flag]) {
if (userSet[flag].indexOf(user) !== -1 && userSetTips[flag]) {
Line 89: Line 109:
}
}
if (!flags.length) return;
if (!flags.length) return;
tips = ' (' + tips.join(', ') + ')';
tips = ' (' + tips.join(', ') + ')';
var spanElem = document.createElement('span');
var spanElem = document.createElement('span');
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu