User:Vanished user 1929210/MarkUserRights.js

/** * 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; jB '); }           for (j=0; jC '); }           for (j=0; jO '); }           for (j=0; jA '); }

for (j=0; jv '); }           for (j=0; jp '); }           for (j=0; jr '); }           for (j=0; ja '); }           for (j=0; jf '); }           for (j=0; jt '); }

for (j=0; je '); }

for (j=0; ji '); }       };

var process = function (data) { var users; if (data.query && data.query.users) { users = data.query.users; } else { users = []; }           for (var i=0; i -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;        }); } });