736
edits
(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 userSetTips = { | var userSetTips = { | ||
'A' : 'administrator', | 'A' : 'administrator', | ||
'B' : ' | 'B' : 'bureaucrat', | ||
' | 'CU' : 'checkuser', | ||
' | 'IA' : 'interface administrator', | ||
'S' : ' | 'IWA' : 'interwiki administrator', | ||
'NSS': 'non-steward suppressor', | |||
'OS': 'suppressor', | |||
'S' : 'steward', | |||
'SA': 'system administrator', | |||
}; | }; | ||
Line 30: | Line 33: | ||
); | ); | ||
} | } | ||
var $links = $content.find('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: | ||
} | } | ||
new mw.Api().get({ | |||
action: 'query', | |||
list: 'allusers', | |||
}).done(function (ans) { | augroup: 'sysop|bureaucrat|checkuser|interface-admin|interwiki-admin|non-stewardsuppress|suppress|steward|sysadmin', | ||
userSet = | auprop: 'groups', | ||
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 = /^ | matches = /^User:(.+)|Talk:(.+)/.exec(link.title); | ||
if (!matches) return; | if (!matches) return; | ||
if | 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'); |