你现在正在访问的是萌娘百科用于保存和管理图片、音频等媒体文件的子项目萌娘共享,想要回到萌娘百科,请使用浏览器上的返回按钮、或点击这里
“MediaWiki:Gadget-blockEnhance.js”的版本间的差异
AnnAngela-dbot(讨论 | 贡献) (代码变动:7da2042 - feat: assertuser (#384) by U:星海子, co-authored-by: U:AnnAngela) (1个标签:由机器人或全自动脚本执行的操作) |
AnnAngela-dbot(讨论 | 贡献) (代码变动:7da2042e - feat: assertuser (#384) by U:星海子, co-authored-by: U:AnnAngela) (1个标签:由机器人或全自动脚本执行的操作) |
||
第4行: | 第4行: | ||
* ------------------------------------------------------------------------- | * ------------------------------------------------------------------------- | ||
*/ | */ | ||
− | var _addText = '{{GHIACode|page=GHIA:MoegirlPediaInterfaceCodes/blob/master/src/gadgets/blockEnhance/MediaWiki:Gadget-blockEnhance.js|user=[[U:星海子]]|co-authors=[[U:AnnAngela]]|longId=7da2042e7973140bf868288ddcdca6c51511d9d2|shortId= | + | var _addText = '{{GHIACode|page=GHIA:MoegirlPediaInterfaceCodes/blob/master/src/gadgets/blockEnhance/MediaWiki:Gadget-blockEnhance.js|user=[[U:星海子]]|co-authors=[[U:AnnAngela]]|longId=7da2042e7973140bf868288ddcdca6c51511d9d2|shortId=7da2042e|summary=feat: assertuser (#384)|body=<nowiki>* feat: assert↩↩* feat: assert↩↩* revert: 未登录可用↩↩---------↩↩Co-authored-by: AnnAngela <naganjue📧vip.qq.com></nowiki>}}'; |
/* <pre> */ | /* <pre> */ |
2024年4月16日 (二) 08:57的最新版本
/** * ------------------------------------------------------------------------- * !!! DON'T MODIFY THIS PAGE MANUALLY, YOUR CHANGES WILL BE OVERWRITTEN !!! * ------------------------------------------------------------------------- */ var _addText = '{{GHIACode|page=GHIA:MoegirlPediaInterfaceCodes/blob/master/src/gadgets/blockEnhance/MediaWiki:Gadget-blockEnhance.js|user=[[U:星海子]]|co-authors=[[U:AnnAngela]]|longId=7da2042e7973140bf868288ddcdca6c51511d9d2|shortId=7da2042e|summary=feat: assertuser (#384)|body=<nowiki>* feat: assert↩↩* feat: assert↩↩* revert: 未登录可用↩↩---------↩↩Co-authored-by: AnnAngela <naganjue📧vip.qq.com></nowiki>}}'; /* <pre> */ "use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __generator = (this && this.__generator) || function (thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (g && (g = 0, op[0] && (_ = 0)), _) try { 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; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; 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]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; (function () { return __awaiter(void 0, void 0, void 0, function () { var showResults, updateCIDRresult, autoBlock, flag, wpTarget, powerfulUserList, submitButton, submitForm, submitButtonText, result, error_1; return __generator(this, function (_a) { switch (_a.label) { case 0: if (mw.config.get("wgCanonicalSpecialPageName") !== "Block") { return [2]; } return [4, $.ready]; case 1: _a.sent(); showResults = function (size, cidr) { $("#mw-checkuser-cidr-res").val(cidr); $("#mw-checkuser-ipnote").text(size); }; updateCIDRresult = function () { var form = document.getElementById("mw-checkuser-cidrform"); if (!form) { return; } form.style.display = "inline"; var iplist = document.getElementById("mw-checkuser-iplist"); if (!iplist) { return; } var text = iplist.value; var 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(";"); } var binPrefix = 0, prefixCidr = 0, 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 !== "") { 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: <input name="mw-checkuser-cidr-res" size="35" value="" id="mw-checkuser-cidr-res"> <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; wpTarget = $('[name="wpTarget"]'); powerfulUserList = []; submitButton = OO.ui.infuse($('#mw-content-text [type="submit"]').parent()); submitForm = submitButton.$element.closest("form"); submitButtonText = submitButton.getLabel(); submitButton.setDisabled(true).setLabel(wgULS("正在加载中……", "正在載入中……")); submitForm.on("submit.warning", function (e) { return __awaiter(void 0, void 0, void 0, function () { var _a; return __generator(this, function (_b) { switch (_b.label) { case 0: e.preventDefault(); e.stopImmediatePropagation(); if (flag === false) { return [2]; } _a = powerfulUserList.includes(wpTarget.val()); if (!_a) return [3, 2]; return [4, oouiDialog.confirm("\u60A8\u8981".concat(wgULS("封禁的用户", "封鎖的使用者", null, null, "封鎖的用戶"), "\u3010").concat(wpTarget.val(), "\u3011").concat(wgULS("持有“封禁”和“自我解封”权限,您的封禁很可能无效且有可能违反封禁方针,您是否要继续?", "持有「封鎖」和「自我解封」權限,您的封鎖很可能無效且有可能違反封鎖方針,您是否要繼續?")), { title: wgULS("封禁辅助工具", "封鎖輔助工具") })]; case 1: _a = !(_b.sent()); _b.label = 2; case 2: if (_a) { return [2]; } submitForm.off("submit.warning").trigger("submit"); return [2]; } }); }); }); _a.label = 2; case 2: _a.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 = _a.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_1 = _a.sent(); console.error(error_1); submitButton.after("<span class=\"error\">".concat(wgULS("无法获取持有“封禁”和“自我解封”权限的用户列表,请谨慎操作", "無法獲取持有「封鎖」和「自我解封」權限的使用者列表,請謹慎操作", null, null, "無法獲取持有「封鎖」和「自我解封」權限的用戶列表,請謹慎操作"), "\u3002</span>")); return [3, 6]; case 5: submitButton.setDisabled(false).setLabel(submitButtonText); flag = true; return [7]; case 6: return [2]; } }); }); })(); /* </pre> */