跳转到内容

MediaWiki:Gadget-blockEnhance.js:修订间差异

来自萌娘共享
代码变动:103d1a56 - feat: rename (#594) by U:AnnAngela, co-authored-by: GH:github-actions[bot]
标签由机器人或全自动脚本执行的操作
代码变动:103d1a56 - feat: rename (#594) by U:AnnAngela, co-authored-by: GH:github-actions[bot]
标签由机器人或全自动脚本执行的操作
第8行: 第8行:
/* <pre> */
/* <pre> */


// <pre>
"use strict";
"use strict";
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
(async () => {
     try {
     if (mw.config.get("wgCanonicalSpecialPageName") !== "Block") {
        var info = gen[key](arg);
        var value = info.value;
    } catch (error) {
        reject(error);
         return;
         return;
     }
     }
     if (info.done) {
     await $.ready;
        resolve(value);
     const showResults = (size, cidr) => {
    } else {
        $("#mw-checkuser-cidr-res").val(cidr);
        Promise.resolve(value).then(_next, _throw);
        $("#mw-checkuser-ipnote").text(size);
     }
}
function _async_to_generator(fn) {
    return function() {
        var self = this, args = arguments;
        return new Promise(function(resolve, reject) {
            var gen = fn.apply(self, args);
            function _next(value) {
                asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
            }
            function _throw(err) {
                asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
            }
            _next(undefined);
        });
     };
     };
}
    const updateCIDRresult = () => {
function _ts_generator(thisArg, body) {
        const form = document.getElementById("mw-checkuser-cidrform");
    var f, y, t, _ = {
        if (!form) {
         label: 0,
            return;
         sent: function() {
         }
            if (t[0] & 1) throw t[1];
        form.style.display = "inline";
             return t[1];
         const iplist = document.getElementById("mw-checkuser-iplist");
         },
        if (!iplist) {
         trys: [],
             return;
         ops: []
         }
    }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
         const text = iplist.value;
    return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
         let ips;
        return this;
        if (text.indexOf("\n") !== -1) {
    }), g;
            ips = text.split("\n");
    function verb(n) {
        }
         return function(v) {
        else if (text.indexOf("\t") !== -1) {
             return step([
            ips = text.split("\t");
                n,
        }
                v
        else if (text.indexOf(",") !== -1) {
            ]);
            ips = text.split(",");
         };
        }
    }
        else if (text.indexOf(" - ") !== -1) {
    function step(op) {
            ips = text.split(" - ");
        if (f) throw new TypeError("Generator is already executing.");
        }
         while(g && (g = 0, op[0] && (_ = 0)), _)try {
        else if (text.indexOf("-") !== -1) {
             if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            ips = text.split("-");
             if (y = 0, t) op = [
        }
                op[0] & 2,
         else if (text.indexOf(" ") !== -1) {
                t.value
             ips = text.split(" ");
            ];
         }
             switch(op[0]){
        else {
                 case 0:
            ips = text.split(";");
                 case 1:
         }
                     t = op;
        let binPrefix = 0, prefixCidr = 0, prefix = "", foundV4 = false, foundV6 = false, ipCount, blocs, isOverflow;
        for (let i = 0; i < ips.length; i++) {
             const addy = ips[i].replace(/^\s*|\s*$/, "");
            const ipV4 = mw.util.isIPv4Address(addy, true);
            const ipV6 = mw.util.isIPv6Address(addy, true);
            const ipCidr = addy.match(/^(.*)(?:\/(\d+))?$/);
             let bin = "";
            let x = 0, z = 0, start = 0, end = 0, ip, cidr, bloc, binBlock;
             if (ipV4) {
                 foundV4 = !0;
                 if (foundV6) {
                     prefix = "";
                     break;
                     break;
                 case 4:
                 }
                    _.label++;
                 ip = ipCidr[1];
                    return {
                cidr = ipCidr[2] || null;
                        value: op[1],
                 blocs = ip.split(".");
                        done: false
                 for (x = 0; x < blocs.length; x++) {
                    };
                    bloc = parseInt(blocs[x], 10);
                 case 5:
                    binBlock = bloc.toString(2);
                    _.label++;
                    while (binBlock.length < 8) {
                    y = op[1];
                         binBlock = `0${binBlock}`;
                    op = [
                        0
                    ];
                    continue;
                 case 7:
                    op = _.ops.pop();
                    _.trys.pop();
                    continue;
                 default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
                         _ = 0;
                        continue;
                     }
                     }
                     if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
                     bin += binBlock;
                        _.label = op[1];
                }
                        break;
                prefix = "";
                if (cidr) {
                    bin = bin.substring(0, cidr);
                }
                if (binPrefix === 0) {
                    binPrefix = bin;
                }
                else {
                    for (x = 0; x < binPrefix.length; x++) {
                        if (bin[x] === undefined || binPrefix[x] !== bin[x]) {
                            binPrefix = binPrefix.substring(0, x);
                            break;
                        }
                     }
                     }
                     if (op[0] === 6 && _.label < t[1]) {
                }
                         _.label = t[1];
                prefixCidr = binPrefix.length;
                         t = op;
                if (prefixCidr < 16) {
                         break;
                     isOverflow = true;
                }
                for (z = 0; z <= 3; z++) {
                    bloc = 0;
                    start = z * 8;
                    end = start + 7;
                    for (x = start; x <= end; x++) {
                         if (binPrefix[x] === undefined) {
                            break;
                         }
                         bloc += parseInt(binPrefix[x], 10) * 2 ** (end - x);
                     }
                     }
                     if (t && _.label < t[2]) {
                     prefix += z === 3 ? bloc : `${bloc}.`;
                        _.label = t[2];
                }
                        _.ops.push(op);
                ipCount = 2 ** (32 - prefixCidr);
                         break;
                if (prefixCidr === 32) {
                    prefixCidr = !1;
                }
            }
            else if (ipV6) {
                foundV6 = !0;
                if (foundV4) {
                    prefix = "";
                    break;
                }
                ip = ipCidr[1];
                cidr = ipCidr[2] || null;
                const abbrevs = ip.match(/::/g);
                if (abbrevs && abbrevs.length > 0) {
                    const colons = ip.match(/:/g);
                    let needed = 7 - (colons.length - 2);
                    let insert = "";
                    while (needed > 1) {
                        insert += ":0";
                         needed--;
                     }
                     }
                     if (t[2]) _.ops.pop();
                     ip = ip.replace("::", `${insert}:`);
                     _.trys.pop();
                     if (ip[0] === ":") {
                     continue;
                        ip = `0${ip}`;
            }
                     }
            op = body.call(thisArg, _);
                }
        } catch (e) {
                blocs = ip.split(":");
            op = [
                for (x = 0; x <= 7; x++) {
                6,
                    bloc = blocs[x] || "0";
                e
                    const intBlock = parseInt(bloc, 16);
            ];
                     binBlock = intBlock.toString(2);
            y = 0;
                     while (binBlock.length < 16) {
        } finally{
                         binBlock = `0${binBlock}`;
            f = t = 0;
        }
        if (op[0] & 5) throw op[1];
        return {
            value: op[0] ? op[1] : void 0,
            done: true
        };
    }
}
(function() {
    return _async_to_generator(function() {
        var showResults, updateCIDRresult, autoBlock, flag, wpTarget, powerfulUserList, submitButton, submitForm, submitButtonText, result, error;
        return _ts_generator(this, function(_state) {
            switch(_state.label){
                case 0:
                     // await mw.loader.using(["ext.gadget.libOOUIDialog"]);
                     if (mw.config.get("wgCanonicalSpecialPageName") !== "Block") {
                         return [
                            2
                        ];
                     }
                     }
                     return [
                     bin += binBlock;
                        4,
                 }
                        $.ready
                prefix = "";
                    ];
                if (cidr) {
                 case 1:
                    bin = bin.substring(0, cidr);
                    _state.sent();
                }
                    showResults = function(size, cidr) {
                if (binPrefix === 0) {
                        $("#mw-checkuser-cidr-res").val(cidr);
                    binPrefix = bin;
                        $("#mw-checkuser-ipnote").text(size);
                }
                    };
                else {
                     updateCIDRresult = function() {
                     for (x = 0; x < binPrefix.length; x++) {
                        var form = document.getElementById("mw-checkuser-cidrform");
                         if (bin[x] === undefined || binPrefix[x] !== bin[x]) {
                         if (!form) {
                             binPrefix = binPrefix.substring(0, x);
                             return;
                            break;
                         }
                         }
                        form.style.display = "inline";
                    }
                        var iplist = document.getElementById("mw-checkuser-iplist") /*  as HTMLTextAreaElement */ ;
                }
                        if (!iplist) {
                prefixCidr = binPrefix.length;
                            return;
                if (prefixCidr < 32) {
                        }
                    isOverflow = true;
                        var text = iplist.value;
                }
                        var ips;
                for (z = 0; z <= 7; z++) {
                        if (text.indexOf("\n") !== -1) {
                    bloc = 0;
                            ips = text.split("\n");
                    start = z * 16;
                        } else if (text.indexOf("\t") !== -1) {
                    end = start + 15;
                            ips = text.split("\t");
                    for (x = start; x <= end; x++) {
                        } else if (text.indexOf(",") !== -1) {
                        if (binPrefix[x] === undefined) {
                            ips = text.split(",");
                            break;
                        } else if (text.indexOf(" - ") !== -1) {
                            ips = text.split(" - ");
                        } else if (text.indexOf("-") !== -1) {
                            ips = text.split("-");
                        } else if (text.indexOf(" ") !== -1) {
                            ips = text.split(" ");
                        } else {
                            ips = text.split(";");
                        }
                        var binPrefix = 0 /*  as any */ , prefixCidr = 0 /*  as any */ , prefix = "", foundV4 = false, foundV6 = false, ipCount, blocs, isOverflow;
                        for(var i = 0; i < ips.length; i++){
                            var addy = ips[i].replace(/^\s*|\s*$/, "");
                            var ipV4 = mw.util.isIPv4Address(addy, true);
                            var ipV6 = mw.util.isIPv6Address(addy, true);
                            var ipCidr = addy.match(/^(.*)(?:\/(\d+))?$/);
                            var bin = "";
                            var x = 0, z = 0, start = 0, end = 0, ip = void 0, cidr = void 0, bloc = void 0, binBlock = void 0;
                            if (ipV4) {
                                foundV4 = !0;
                                if (foundV6) {
                                    prefix = "";
                                    break;
                                }
                                ip = ipCidr[1];
                                cidr = ipCidr[2] || null;
                                blocs = ip.split(".");
                                for(x = 0; x < blocs.length; x++){
                                    bloc = parseInt(blocs[x], 10);
                                    binBlock = bloc.toString(2);
                                    while(binBlock.length < 8){
                                        binBlock = "0".concat(binBlock);
                                    }
                                    bin += binBlock;
                                }
                                prefix = "";
                                if (cidr) {
                                    bin = bin.substring(0, cidr);
                                }
                                if (binPrefix === 0) {
                                    binPrefix = bin;
                                } else {
                                    for(x = 0; x < binPrefix.length; x++){
                                        if (bin[x] === undefined || binPrefix[x] !== bin[x]) {
                                            binPrefix = binPrefix.substring(0, x);
                                            break;
                                        }
                                    }
                                }
                                prefixCidr = binPrefix.length;
                                if (prefixCidr < 16) {
                                    isOverflow = true;
                                }
                                for(z = 0; z <= 3; z++){
                                    bloc = 0;
                                    start = z * 8;
                                    end = start + 7;
                                    for(x = start; x <= end; x++){
                                        if (binPrefix[x] === undefined) {
                                            break;
                                        }
                                        bloc += parseInt(binPrefix[x], 10) * Math.pow(2, end - x);
                                    }
                                    prefix += z === 3 ? bloc : "".concat(bloc, ".");
                                }
                                ipCount = Math.pow(2, 32 - prefixCidr);
                                if (prefixCidr === 32) {
                                    prefixCidr = !1;
                                }
                            } else if (ipV6) {
                                foundV6 = !0;
                                if (foundV4) {
                                    prefix = "";
                                    break;
                                }
                                ip = ipCidr[1];
                                cidr = ipCidr[2] || null;
                                var abbrevs = ip.match(/::/g);
                                if (abbrevs && abbrevs.length > 0) {
                                    var colons = ip.match(/:/g);
                                    var needed = 7 - (colons.length - 2);
                                    var insert = "";
                                    while(needed > 1){
                                        insert += ":0";
                                        needed--;
                                    }
                                    ip = ip.replace("::", "".concat(insert, ":"));
                                    if (ip[0] === ":") {
                                        ip = "0".concat(ip);
                                    }
                                }
                                blocs = ip.split(":");
                                for(x = 0; x <= 7; x++){
                                    bloc = blocs[x] || "0";
                                    var intBlock = parseInt(bloc, 16);
                                    binBlock = intBlock.toString(2);
                                    while(binBlock.length < 16){
                                        binBlock = "0".concat(binBlock);
                                    }
                                    bin += binBlock;
                                }
                                prefix = "";
                                if (cidr) {
                                    bin = bin.substring(0, cidr);
                                }
                                if (binPrefix === 0) {
                                    binPrefix = bin;
                                } else {
                                    for(x = 0; x < binPrefix.length; x++){
                                        if (bin[x] === undefined || binPrefix[x] !== bin[x]) {
                                            binPrefix = binPrefix.substring(0, x);
                                            break;
                                        }
                                    }
                                }
                                prefixCidr = binPrefix.length;
                                if (prefixCidr < 32) {
                                    isOverflow = true;
                                }
                                for(z = 0; z <= 7; z++){
                                    bloc = 0;
                                    start = z * 16;
                                    end = start + 15;
                                    for(x = start; x <= end; x++){
                                        if (binPrefix[x] === undefined) {
                                            break;
                                        }
                                        bloc += parseInt(binPrefix[x], 10) * Math.pow(2, end - x);
                                    }
                                    bloc = bloc.toString(16);
                                    prefix += z === 7 ? bloc : "".concat(bloc, ":");
                                }
                                ipCount = Math.pow(2, 128 - prefixCidr);
                                if (prefixCidr === 128) {
                                    prefixCidr = !1;
                                }
                            }
                         }
                         }
                         if (prefix !== "") {
                         bloc += parseInt(binPrefix[x], 10) * 2 ** (end - x);
                            var full = prefix;
                            if (prefixCidr !== false) {
                                full += "/".concat(prefixCidr);
                            }
                            showResults("~".concat(ipCount).concat(isOverflow ? " [OVERFLOW]" : ""), full);
                        } else {
                            showResults("?", "");
                        }
                    };
                    $("#mw-content-text form").prepend('<fieldset id="mw-checkuser-cidrform" class="checkuser-show" style="display: block; float: right;"><legend>检查指定IP列表的共同区段</legend><textarea id="mw-checkuser-iplist" dir="ltr" rows="5" cols="50"></textarea><br>通用CIDR:&nbsp;<input name="mw-checkuser-cidr-res" size="35" value="" id="mw-checkuser-cidr-res">&nbsp;<strong id="mw-checkuser-ipnote">?</strong></fieldset><style>#mw-content-text form .oo-ui-fieldLayout:before, #mw-content-text form .oo-ui-fieldLayout:after {clear: left;}');
                    updateCIDRresult();
                    $("#mw-checkuser-iplist").on("keyup click", updateCIDRresult);
                    autoBlock = OO.ui.infuse($("#mw-input-wpAutoBlock"));
                    if ($("input#mw-input-wpConfirm, input[name=wpConfirm]").val() === "") {
                        autoBlock.setSelected(false);
                     }
                     }
                     flag = false;
                     bloc = bloc.toString(16);
                    wpTarget = $('[name="wpTarget"]');
                     prefix += z === 7 ? bloc : `${bloc}:`;
                     powerfulUserList = [];
                }
                    submitButton = OO.ui.infuse($('#mw-content-text [type="submit"]').parent());
                ipCount = 2 ** (128 - prefixCidr);
                    submitForm = submitButton.$element.closest("form");
                if (prefixCidr === 128) {
                    submitButtonText = submitButton.getLabel();
                     prefixCidr = !1;
                    submitButton.setDisabled(true).setLabel(wgULS("正在加载中……", "正在載入中……"));
                 }
                    submitForm.on("submit.warning", function(e) {
                        return _async_to_generator(function() {
                            var _tmp;
                            return _ts_generator(this, function(_state) {
                                switch(_state.label){
                                    case 0:
                                        e.preventDefault();
                                        e.stopImmediatePropagation();
                                        if (flag === false) {
                                            // powerfulUserList has not been loaded yet
                                            return [
                                                2
                                            ];
                                        }
                                        _tmp = powerfulUserList.includes(wpTarget.val());
                                        if (!_tmp) return [
                                            3,
                                            2
                                        ];
                                        return [
                                            4,
                                            oouiDialog.confirm("您要".concat(wgULS("封禁的用户", "封鎖的使用者", null, null, "封鎖的用戶"), "【").concat(wpTarget.val(), "】").concat(wgULS("持有“封禁”和“自我解封”权限,您的封禁很可能无效且有可能违反封禁方针,您是否要继续?", "持有「封鎖」和「自我解封」權限,您的封鎖很可能無效且有可能違反封鎖方針,您是否要繼續?")), {
                                                title: wgULS("封禁辅助工具", "封鎖輔助工具")
                                            })
                                        ];
                                    case 1:
                                        _tmp = !_state.sent();
                                        _state.label = 2;
                                    case 2:
                                        if (_tmp) {
                                            // User cancelled the action
                                            return [
                                                2
                                            ];
                                        }
                                        submitForm.off("submit.warning").trigger("submit");
                                        return [
                                            2
                                        ];
                                }
                            });
                        })();
                    });
                    _state.label = 2;
                case 2:
                    _state.trys.push([
                        2,
                        4,
                        5,
                        6
                    ]);
                    return [
                        4,
                        new mw.Api({
                            timeout: 5000
                        }).post({
                            action: "query",
                            assertuser: mw.config.get("wgUserName"),
                            list: "allusers",
                            aurights: "block|unblockself",
                            aulimit: "max",
                            auprop: "rights"
                        })
                    ];
                case 3:
                    result = _state.sent();
                    powerfulUserList = result.query.allusers.filter(function(au) {
                        return au.rights.includes("block") && au.rights.includes("unblockself");
                    }).map(function(au) {
                        return au.name;
                    });
                    return [
                        3,
                        6
                    ];
                case 4:
                     error = _state.sent();
                    console.error(error);
                    submitButton.after('<span class="error">'.concat(wgULS("无法获取持有“封禁”和“自我解封”权限的用户列表,请谨慎操作", "無法獲取持有「封鎖」和「自我解封」權限的使用者列表,請謹慎操作", null, null, "無法獲取持有「封鎖」和「自我解封」權限的用戶列表,請謹慎操作"), "。</span>"));
                    return [
                        3,
                        6
                    ];
                 case 5:
                    submitButton.setDisabled(false).setLabel(submitButtonText);
                    flag = true;
                    return [
                        7
                    ];
                case 6:
                    return [
                        2
                    ];
             }
             }
        }
        if (prefix !== "") {
            let full = prefix;
            if (prefixCidr !== false) {
                full += `/${prefixCidr}`;
            }
            showResults(`~${ipCount}${isOverflow ? " [OVERFLOW]" : ""}`, full);
        }
        else {
            showResults("?", "");
        }
    };
    $("#mw-content-text form").prepend('<fieldset id="mw-checkuser-cidrform" class="checkuser-show" style="display: block; float: right;"><legend>检查指定IP列表的共同区段</legend><textarea id="mw-checkuser-iplist" dir="ltr" rows="5" cols="50"></textarea><br>通用CIDR:&nbsp;<input name="mw-checkuser-cidr-res" size="35" value="" id="mw-checkuser-cidr-res">&nbsp;<strong id="mw-checkuser-ipnote">?</strong></fieldset><style>#mw-content-text form .oo-ui-fieldLayout:before, #mw-content-text form .oo-ui-fieldLayout:after {clear: left;}');
    updateCIDRresult();
    $("#mw-checkuser-iplist").on("keyup click", updateCIDRresult);
    const autoBlock = OO.ui.infuse($("#mw-input-wpAutoBlock"));
    if ($("input#mw-input-wpConfirm, input[name=wpConfirm]").val() === "") {
        autoBlock.setSelected(false);
    }
    let flag = false;
    const wpTarget = $('[name="wpTarget"]');
    let powerfulUserList = [];
    const submitButton = OO.ui.infuse($('#mw-content-text [type="submit"]').parent());
    const submitForm = submitButton.$element.closest("form");
    const submitButtonText = submitButton.getLabel();
    submitButton.setDisabled(true).setLabel(wgULS("正在加载中……", "正在載入中……"));
    submitForm.on("submit.warning", async (e) => {
        e.preventDefault();
        e.stopImmediatePropagation();
        if (flag === false) {
            return;
        }
        if (powerfulUserList.includes(wpTarget.val()) && !await oouiDialog.confirm(`您要${wgULS("封禁的用户", "封鎖的使用者", null, null, "封鎖的用戶")}【${wpTarget.val()}】${wgULS("持有“封禁”和“自我解封”权限,您的封禁很可能无效且有可能违反封禁方针,您是否要继续?", "持有「封鎖」和「自我解封」權限,您的封鎖很可能無效且有可能違反封鎖方針,您是否要繼續?")}`, {
            title: wgULS("封禁辅助工具", "封鎖輔助工具"),
        })) {
            return;
        }
        submitForm.off("submit.warning").trigger("submit");
    });
    try {
        const result = await new mw.Api({
            timeout: 5000,
        }).post({
            action: "query",
            assertuser: mw.config.get("wgUserName"),
            list: "allusers",
            aurights: "block|unblockself",
            aulimit: "max",
            auprop: "rights",
         });
         });
    })();
        powerfulUserList = result.query.allusers.filter((au) => au.rights.includes("block") && au.rights.includes("unblockself")).map((au) => au.name);
})(); // </pre>  
    }
    catch (error) {
        console.error(error);
        submitButton.after(`<span class="error">${wgULS("无法获取持有“封禁”和“自我解封”权限的用户列表,请谨慎操作", "無法獲取持有「封鎖」和「自我解封」權限的使用者列表,請謹慎操作", null, null, "無法獲取持有「封鎖」和「自我解封」權限的用戶列表,請謹慎操作")}。</span>`);
    }
    finally {
        submitButton.setDisabled(false).setLabel(submitButtonText);
        flag = true;
    }
})();


/* </pre> */
/* </pre> */

2025年7月24日 (四) 20:49的版本

/**
 * -------------------------------------------------------------------------
 * !!! DON'T MODIFY THIS PAGE MANUALLY, YOUR CHANGES WILL BE OVERWRITTEN !!!
 * -------------------------------------------------------------------------
 */
var _addText = '{{GHIACode|page=GHIA:MoegirlPediaInterfaceCodes/blob/master/src/gadgets/blockEnhance/Gadget-blockEnhance.js|user=[[U:AnnAngela]]|co-authors=GH:github-actions[bot]|longId=103d1a563ea4ccc8ff29fb55c9bcd88329a56eb5|shortId=103d1a56|summary=feat: rename (#594)|body=<nowiki>Co-authored-by: github-actions[bot] <41898282+github-actions[bot]📧users.noreply.github.com></nowiki>}}'; 

/* <pre> */

"use strict";
(async () => {
    if (mw.config.get("wgCanonicalSpecialPageName") !== "Block") {
        return;
    }
    await $.ready;
    const showResults = (size, cidr) => {
        $("#mw-checkuser-cidr-res").val(cidr);
        $("#mw-checkuser-ipnote").text(size);
    };
    const updateCIDRresult = () => {
        const form = document.getElementById("mw-checkuser-cidrform");
        if (!form) {
            return;
        }
        form.style.display = "inline";
        const iplist = document.getElementById("mw-checkuser-iplist");
        if (!iplist) {
            return;
        }
        const text = iplist.value;
        let ips;
        if (text.indexOf("\n") !== -1) {
            ips = text.split("\n");
        }
        else if (text.indexOf("\t") !== -1) {
            ips = text.split("\t");
        }
        else if (text.indexOf(",") !== -1) {
            ips = text.split(",");
        }
        else if (text.indexOf(" - ") !== -1) {
            ips = text.split(" - ");
        }
        else if (text.indexOf("-") !== -1) {
            ips = text.split("-");
        }
        else if (text.indexOf(" ") !== -1) {
            ips = text.split(" ");
        }
        else {
            ips = text.split(";");
        }
        let binPrefix = 0, prefixCidr = 0, prefix = "", foundV4 = false, foundV6 = false, ipCount, blocs, isOverflow;
        for (let i = 0; i < ips.length; i++) {
            const addy = ips[i].replace(/^\s*|\s*$/, "");
            const ipV4 = mw.util.isIPv4Address(addy, true);
            const ipV6 = mw.util.isIPv6Address(addy, true);
            const ipCidr = addy.match(/^(.*)(?:\/(\d+))?$/);
            let bin = "";
            let x = 0, z = 0, start = 0, end = 0, ip, cidr, bloc, binBlock;
            if (ipV4) {
                foundV4 = !0;
                if (foundV6) {
                    prefix = "";
                    break;
                }
                ip = ipCidr[1];
                cidr = ipCidr[2] || null;
                blocs = ip.split(".");
                for (x = 0; x < blocs.length; x++) {
                    bloc = parseInt(blocs[x], 10);
                    binBlock = bloc.toString(2);
                    while (binBlock.length < 8) {
                        binBlock = `0${binBlock}`;
                    }
                    bin += binBlock;
                }
                prefix = "";
                if (cidr) {
                    bin = bin.substring(0, cidr);
                }
                if (binPrefix === 0) {
                    binPrefix = bin;
                }
                else {
                    for (x = 0; x < binPrefix.length; x++) {
                        if (bin[x] === undefined || binPrefix[x] !== bin[x]) {
                            binPrefix = binPrefix.substring(0, x);
                            break;
                        }
                    }
                }
                prefixCidr = binPrefix.length;
                if (prefixCidr < 16) {
                    isOverflow = true;
                }
                for (z = 0; z <= 3; z++) {
                    bloc = 0;
                    start = z * 8;
                    end = start + 7;
                    for (x = start; x <= end; x++) {
                        if (binPrefix[x] === undefined) {
                            break;
                        }
                        bloc += parseInt(binPrefix[x], 10) * 2 ** (end - x);
                    }
                    prefix += z === 3 ? bloc : `${bloc}.`;
                }
                ipCount = 2 ** (32 - prefixCidr);
                if (prefixCidr === 32) {
                    prefixCidr = !1;
                }
            }
            else if (ipV6) {
                foundV6 = !0;
                if (foundV4) {
                    prefix = "";
                    break;
                }
                ip = ipCidr[1];
                cidr = ipCidr[2] || null;
                const abbrevs = ip.match(/::/g);
                if (abbrevs && abbrevs.length > 0) {
                    const colons = ip.match(/:/g);
                    let needed = 7 - (colons.length - 2);
                    let insert = "";
                    while (needed > 1) {
                        insert += ":0";
                        needed--;
                    }
                    ip = ip.replace("::", `${insert}:`);
                    if (ip[0] === ":") {
                        ip = `0${ip}`;
                    }
                }
                blocs = ip.split(":");
                for (x = 0; x <= 7; x++) {
                    bloc = blocs[x] || "0";
                    const intBlock = parseInt(bloc, 16);
                    binBlock = intBlock.toString(2);
                    while (binBlock.length < 16) {
                        binBlock = `0${binBlock}`;
                    }
                    bin += binBlock;
                }
                prefix = "";
                if (cidr) {
                    bin = bin.substring(0, cidr);
                }
                if (binPrefix === 0) {
                    binPrefix = bin;
                }
                else {
                    for (x = 0; x < binPrefix.length; x++) {
                        if (bin[x] === undefined || binPrefix[x] !== bin[x]) {
                            binPrefix = binPrefix.substring(0, x);
                            break;
                        }
                    }
                }
                prefixCidr = binPrefix.length;
                if (prefixCidr < 32) {
                    isOverflow = true;
                }
                for (z = 0; z <= 7; z++) {
                    bloc = 0;
                    start = z * 16;
                    end = start + 15;
                    for (x = start; x <= end; x++) {
                        if (binPrefix[x] === undefined) {
                            break;
                        }
                        bloc += parseInt(binPrefix[x], 10) * 2 ** (end - x);
                    }
                    bloc = bloc.toString(16);
                    prefix += z === 7 ? bloc : `${bloc}:`;
                }
                ipCount = 2 ** (128 - prefixCidr);
                if (prefixCidr === 128) {
                    prefixCidr = !1;
                }
            }
        }
        if (prefix !== "") {
            let full = prefix;
            if (prefixCidr !== false) {
                full += `/${prefixCidr}`;
            }
            showResults(`~${ipCount}${isOverflow ? " [OVERFLOW]" : ""}`, full);
        }
        else {
            showResults("?", "");
        }
    };
    $("#mw-content-text form").prepend('<fieldset id="mw-checkuser-cidrform" class="checkuser-show" style="display: block; float: right;"><legend>检查指定IP列表的共同区段</legend><textarea id="mw-checkuser-iplist" dir="ltr" rows="5" cols="50"></textarea><br>通用CIDR:&nbsp;<input name="mw-checkuser-cidr-res" size="35" value="" id="mw-checkuser-cidr-res">&nbsp;<strong id="mw-checkuser-ipnote">?</strong></fieldset><style>#mw-content-text form .oo-ui-fieldLayout:before, #mw-content-text form .oo-ui-fieldLayout:after {clear: left;}');
    updateCIDRresult();
    $("#mw-checkuser-iplist").on("keyup click", updateCIDRresult);
    const autoBlock = OO.ui.infuse($("#mw-input-wpAutoBlock"));
    if ($("input#mw-input-wpConfirm, input[name=wpConfirm]").val() === "") {
        autoBlock.setSelected(false);
    }
    let flag = false;
    const wpTarget = $('[name="wpTarget"]');
    let powerfulUserList = [];
    const submitButton = OO.ui.infuse($('#mw-content-text [type="submit"]').parent());
    const submitForm = submitButton.$element.closest("form");
    const submitButtonText = submitButton.getLabel();
    submitButton.setDisabled(true).setLabel(wgULS("正在加载中……", "正在載入中……"));
    submitForm.on("submit.warning", async (e) => {
        e.preventDefault();
        e.stopImmediatePropagation();
        if (flag === false) {
            return;
        }
        if (powerfulUserList.includes(wpTarget.val()) && !await oouiDialog.confirm(`您要${wgULS("封禁的用户", "封鎖的使用者", null, null, "封鎖的用戶")}${wpTarget.val()}${wgULS("持有“封禁”和“自我解封”权限,您的封禁很可能无效且有可能违反封禁方针,您是否要继续?", "持有「封鎖」和「自我解封」權限,您的封鎖很可能無效且有可能違反封鎖方針,您是否要繼續?")}`, {
            title: wgULS("封禁辅助工具", "封鎖輔助工具"),
        })) {
            return;
        }
        submitForm.off("submit.warning").trigger("submit");
    });
    try {
        const result = await new mw.Api({
            timeout: 5000,
        }).post({
            action: "query",
            assertuser: mw.config.get("wgUserName"),
            list: "allusers",
            aurights: "block|unblockself",
            aulimit: "max",
            auprop: "rights",
        });
        powerfulUserList = result.query.allusers.filter((au) => au.rights.includes("block") && au.rights.includes("unblockself")).map((au) => au.name);
    }
    catch (error) {
        console.error(error);
        submitButton.after(`<span class="error">${wgULS("无法获取持有“封禁”和“自我解封”权限的用户列表,请谨慎操作", "無法獲取持有「封鎖」和「自我解封」權限的使用者列表,請謹慎操作", null, null, "無法獲取持有「封鎖」和「自我解封」權限的用戶列表,請謹慎操作")}。</span>`);
    }
    finally {
        submitButton.setDisabled(false).setLabel(submitButtonText);
        flag = true;
    }
})(); 

/* </pre> */