MCBBS Wiki欢迎您共同参与编辑!在参与编辑之前请先阅读Wiki方针

如果在编辑的过程中遇到了什么问题,可以去讨论板提问。

为了您能够无阻碍地参与编辑 未验证/绑定过邮箱的用户,请尽快绑定/验证

MCBBS Wiki GitHub群组已上线!

您可以在回声洞中发表吐槽!

服务器状态监控。点击进入

本站由MCBBS用户自行搭建,与MCBBS及东银河系漫游指南(北京)科技有限公司没有从属关系。点此了解 MCBBS Wiki 不是什么>>

Gadget:usergroup.js:修订间差异

来自MCBBS Wiki
跳到导航 跳到搜索
(// Edit via Wikiplus)
(Litwak913移动页面用户:坑触可/js/usergroup.jsGadget:usergroup.js
 
(未显示2个用户的2个中间版本)
第8行: 第8行:
suppress: {list: [], class: "markrights-suppress"},
suppress: {list: [], class: "markrights-suppress"},
sysop: {list: [], class: "markrights-sysop"},
sysop: {list: [], class: "markrights-sysop"},
developer: {list: [], class: "markrights-developer"},
'interface-admin': {list: [], class: "markrights-interface-admin"},
'interface-admin': {list: [], class: "markrights-interface-admin"},
// 页面管理型权限
// 页面管理型权限
patroller: {list: [], class: "markrights-patroller"},
patroller: {list: [], class: "markrights-patroller"},
rollbacker: {list: [], class: "markrights-rollbacker"},
// 确认权限
// 确认权限
developer: {list: [], class: "developer"},
autoconfirmed: {list: [], class: "markrights-autoconfirmed"},
autoconfirmed: {list: [], class: "markrights-autoconfirmed"},
extendedconfirmed: {list: [], class: "markrights-extendedconfirmed"},
extendedconfirmed: {list: [], class: "markrights-extendedconfirmed"},
// 机器权限
// 机器权限
bot: {list: [], class: "markrights-bot"},
bot: {list: [], class: "markrights-bot"},
// 其他权限
excellenteditor: {list: [], class: "markrights-excellenteditor"}
};
};
var markUG = function () {
var markUG = function () {

2023年7月23日 (日) 18:12的最新版本

// From Wikipedia. MediaWiki:Gadget-MarkRights.js

$(function () {
    var groups = {
        // 全站管理型权限
        bureaucrat: {list: [], class: "markrights-bureaucrat"},
        checkuser: {list: [], class: "markrights-checkuser"},
        suppress: {list: [], class: "markrights-suppress"},
        sysop: {list: [], class: "markrights-sysop"},
        developer: {list: [], class: "markrights-developer"},
        'interface-admin': {list: [], class: "markrights-interface-admin"},
        // 页面管理型权限
        patroller: {list: [], class: "markrights-patroller"},
        // 确认权限
        autoconfirmed: {list: [], class: "markrights-autoconfirmed"},
        extendedconfirmed: {list: [], class: "markrights-extendedconfirmed"},
        // 机器权限
        bot: {list: [], class: "markrights-bot"},
        // 其他权限
        excellenteditor: {list: [], class: "markrights-excellenteditor"}
    };
    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 getUsername = function (title) {
            return title.replace('用户:', '').replace(/_/g, ' ').replace(/%(?!\d+)/g, '%25');
        };

        var done = function () {
            var group;
            $('a.mw-userlink:not(.mw-anonuserlink)').each(function (i, el) {
                var username = getUsername($(el).attr('title'));
                if (username) {
                    for (group in groups) {
                        if (groups.hasOwnProperty(group)) {
                            if (groups[group].list.indexOf(username) > -1) {
                                $(el).append('<sup class="' + groups[group].class + '"></sup>');
                            }
                        }
                    }
                }
            });
        };

        var process = function (data) {
            var users, group;
            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) {
                    for (group in groups) {
                        if (groups.hasOwnProperty(group) && user.groups.indexOf(group) > -1) {
                            groups[group].list.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);
        }
    };
    mw.hook('wikipage.content').add(function(e) {
        if (e.attr('id') === 'mw-content-text') {
            markUG();
            return;
        }
        if (e.hasClass('mw-changeslist')) markUG();
    });
});