你现在正在访问的是萌娘百科用于保存和管理图片、音频等媒体文件的子项目萌娘共享,想要回到萌娘百科,请使用浏览器上的返回按钮、或点击这里
MediaWiki:Gadget-usergroup.js
注意:在保存之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。
- Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5或Ctrl-R(Mac为⌘-R)
- Google Chrome:按Ctrl-Shift-R(Mac为⌘-Shift-R)
- Internet Explorer:按住Ctrl的同时单击刷新,或按Ctrl-F5
- Opera:前往菜单 → 设置(Mac为Opera → Preferences),然后隐私和安全 → 清除浏览数据 → 缓存的图片和文件。
/** * ------------------------------------------------------------------------- * !!! DON'T MODIFY THIS PAGE MANUALLY, YOUR CHANGES WILL BE OVERWRITTEN !!! * ------------------------------------------------------------------------- */ var _addText = '{{GHIACode|page=GHIA:MoegirlPediaInterfaceCodes/blob/master/src/gadgets/usergroup/MediaWiki:Gadget-usergroup.js|user=[[U:AnnAngela]]|co-authors=|longId=6f7f3f9965e1e67f9282f3575f1a9e98695c9cb5|shortId=6f7f3f9|summary=fix: 无意义的await}}'; /* <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 }; } }; var __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; }; var __values = (this && this.__values) || function(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); }; var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); }; (function () { return __awaiter(void 0, void 0, void 0, function () { var localObjectStorage, groups, groupStr, groupsKey, blocklogFlags, wgUserName, cache, api, eol, fixZero, toLocalTimeZoneString, groupsKey_1, groupsKey_1_1, i, _a, result_1, aufrom, _result, blockCache, now, _b, _c, _d, username, _e, timestamp, isBlocked, querySelectorAll, markBlocked, hook, style, groups_1, groups_1_1, _f, group, color, _g, _h, _j, group, strList, _k, _l, _m, lang, str; var e_1, _o, e_2, _p, e_3, _q, e_4, _r, e_5, _s; return __generator(this, function (_t) { switch (_t.label) { case 0: return [4, $.ready]; case 1: _t.sent(); localObjectStorage = new LocalObjectStorage("usergroup"); groups = [ ["staff", "#198754"], ["bureaucrat", "#6610f2"], ["checkuser", "#673ab7"], ["suppress", "#9c27b0"], ["sysop", "#ec407a"], ["interface-admin", "#f55b42"], ["patroller", "#f77f38"], ["honoredmaintainer", "#febd45"], ["techeditor", "#3f51b5"], ["file-maintainer", "#039be5"], ["bot", "#1e88e5"], ["flood", "#1e88e5"], ["ipblock-exempt", "#29b6f6"], ["extendedconfirmed", "#57c2c3"], ["manually-confirmed", "#009688"], ["goodeditor", "#1aa179"], ["special-contributor", "#595c5f"], ].reverse(); groupStr = { bureaucrat: { zh: "行" }, checkuser: { zh: "查" }, suppress: { zh: "监", "zh-hant": "監", "zh-tw": "監", "zh-hk": "監" }, sysop: { zh: "管" }, patroller: { zh: "维", "zh-hant": "維", "zh-tw": "維", "zh-hk": "維" }, bot: { zh: "机", "zh-hant": "機", "zh-tw": "機", "zh-hk": "機" }, flood: { zh: "机", "zh-hant": "機", "zh-tw": "機", "zh-hk": "機" }, goodeditor: { zh: "优", "zh-hant": "優", "zh-tw": "優", "zh-hk": "優" }, honoredmaintainer: { zh: "荣", "zh-hant": "榮", "zh-tw": "榮", "zh-hk": "榮" }, "file-maintainer": { zh: "档", "zh-hant": "檔", "zh-tw": "檔", "zh-hk": "檔" }, "interface-admin": { zh: "界", "zh-hant": "介", "zh-tw": "介", "zh-hk": "介" }, techeditor: { zh: "技" }, "ipblock-exempt": { zh: "免" }, "manually-confirmed": { zh: "手" }, extendedconfirmed: { zh: "延" }, staff: { zh: "职", "zh-hant": "職", "zh-tw": "職", "zh-hk": "職" }, "special-contributor": { zh: "特" } }; groupsKey = groups.map(function (_a) { var _b = __read(_a, 1), group = _b[0]; return group; }); blocklogFlags = Object.entries({ anononly: wgULS("仅封禁匿名用户", "僅封鎖匿名使用者", null, null, "僅封鎖匿名用戶"), nocreate: wgULS("阻止创建新账号", "防止建立新帳號"), autoblock: wgULS("自动封禁该用户最后使用的IP地址,以及其随后试图用于编辑的所有IP地址", "自動封鎖最後使用的IP位址,以及在這之後嘗試登入的所有IP位址。"), noemail: wgULS("阻止用户发送电子邮件", "阻止使用者發送電子郵件", null, null, "阻止用戶發送電子郵件"), nousertalk: wgULS("阻止用户在封禁期间编辑自己的讨论页", "阻止使用者在封鎖期間編輯自己的對話頁", null, null, "阻止用戶在封鎖期間編輯自己的討論頁"), hiddenname: wgULS("隐藏用户名", "隱藏使用者名稱", null, null, "隱藏用戶名") }); wgUserName = mw.config.get("wgUserName"); api = new mw.Api(); eol = Symbol(); fixZero = function (n, l) { if (l === void 0) { l = 2; } return "".concat(n).padStart(l, "0"); }; toLocalTimeZoneString = function (date) { if (date === void 0) { date = new Date(); } return "".concat(date.getFullYear(), "/").concat(fixZero(date.getMonth() + 1), "/").concat(fixZero(date.getDate()), " ").concat(fixZero(date.getHours()), ":").concat(fixZero(date.getMinutes()), ":").concat(fixZero(date.getSeconds()), ".").concat(fixZero(date.getMilliseconds(), 3)); }; _t.label = 2; case 2: _t.trys.push([2, 3, , 7]); cache = localObjectStorage.getItem("cache"); if (!cache || typeof cache.timestamp !== "number" || cache.timestamp < new Date().getTime() - 30 * 60 * 1000 || !cache.groups) { throw new Error(); } else { try { for (groupsKey_1 = __values(groupsKey), groupsKey_1_1 = groupsKey_1.next(); !groupsKey_1_1.done; groupsKey_1_1 = groupsKey_1.next()) { i = groupsKey_1_1.value; if (!Array.isArray(cache.groups[i])) { throw new Error(); } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (groupsKey_1_1 && !groupsKey_1_1.done && (_o = groupsKey_1["return"])) _o.call(groupsKey_1); } finally { if (e_1) throw e_1.error; } } } return [3, 7]; case 3: _a = _t.sent(); result_1 = Object.fromEntries(groupsKey.map(function (n) { return [n, []]; })); aufrom = undefined; _t.label = 4; case 4: if (!(aufrom !== eol)) return [3, 6]; return [4, api.post({ action: "query", assertuser: wgUserName, list: "allusers", augroup: groupsKey.join("|"), aulimit: "max", auprop: "groups", aufrom: aufrom })]; case 5: _result = _t.sent(); if (_result["continue"]) { aufrom = _result["continue"].aufrom; } else { aufrom = eol; } _result.query.allusers.forEach(function (_a) { var name = _a.name, groups = _a.groups; groups.forEach(function (group) { if (groupsKey.includes(group)) { result_1[group] || (result_1[group] = []); if (!result_1[group].includes(name)) { result_1[group].push(name); } } }); }); return [3, 4]; case 6: cache = { timestamp: new Date().getTime(), groups: result_1 }; return [3, 7]; case 7: localObjectStorage.setItem("cache", cache); blockCache = localObjectStorage.getItem("blockCache", {}); now = Date.now(); try { for (_b = __values(Object.entries(blockCache)), _c = _b.next(); !_c.done; _c = _b.next()) { _d = __read(_c.value, 2), username = _d[0], _e = _d[1], timestamp = _e.timestamp, isBlocked = _e.isBlocked; if (typeof username !== "string" || typeof timestamp !== "number" || typeof isBlocked !== "boolean" || now - timestamp > 30 * 60 * 1000) { Reflect.deleteProperty(blockCache, username); } } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (_c && !_c.done && (_p = _b["return"])) _p.call(_b); } finally { if (e_2) throw e_2.error; } } localObjectStorage.setItem("blockCache", blockCache); querySelectorAll = function (selector) { return __spreadArray([], __read(document.querySelectorAll(selector)), false); }; markBlocked = function (ele, blockInfo) { ele.classList.add("markBlockInfo"); ele.classList.remove("unknownBlockInfo"); if (blockInfo.isBlocked) { ele.style.textDecoration = "underline wavy"; var sup = document.createElement("sup"); sup.classList.add("detailedBlockInfo"); sup.title = blockInfo.info; sup.textContent = "[封+]"; ele.after(sup); } }; hook = function () { return __awaiter(void 0, void 0, void 0, function () { var unknownUsernames, _a, _b, ele, parent_1, inNavbox, url, username, pathname, title, groupsKey_2, groupsKey_2_1, group, sup, blockInfo, hasApihighlimits, singleRequestLimit, targets, _loop_1, i, l, _c, _d, ele, username, blockInfo, groupsKey_3, groupsKey_3_1, group, _e, _f, node, nextElementSibling, nextNextElementSibling; var e_6, _g, e_7, _h, e_8, _j, e_9, _k, e_10, _l; return __generator(this, function (_m) { switch (_m.label) { case 0: unknownUsernames = new Set(); try { for (_a = __values(querySelectorAll("a.mw-userlink:not(.markrights), .userlink > a:not(.markrights)")), _b = _a.next(); !_b.done; _b = _a.next()) { ele = _b.value; parent_1 = ele.parentElement; inNavbox = false; while (parent_1) { if (parent_1.classList.contains("navbox")) { inNavbox = true; break; } parent_1 = parent_1.parentElement; } if (inNavbox) { continue; } ele.classList.add("markrights"); url = new URL(new mw.Uri(ele.href)); username = void 0; pathname = decodeURIComponent(url.pathname); title = url.searchParams.get("title"); if (/^\/User:[^/=%]+/.test(pathname)) { username = pathname.match(/^\/User:([^/=%]+)/)[1].replace(/_/g, " "); } else if (/^User:[^/=%]+/.test(title)) { username = title.match(/^User:([^/=%]+)/)[1].replace(/_/g, " "); } if (!username) { continue; } ele.dataset.username = username; try { for (groupsKey_2 = (e_7 = void 0, __values(groupsKey)), groupsKey_2_1 = groupsKey_2.next(); !groupsKey_2_1.done; groupsKey_2_1 = groupsKey_2.next()) { group = groupsKey_2_1.value; if (cache.groups[group].includes(username)) { sup = document.createElement("sup"); sup.classList.add("markrights-".concat(group)); ele.after(sup); } } } catch (e_7_1) { e_7 = { error: e_7_1 }; } finally { try { if (groupsKey_2_1 && !groupsKey_2_1.done && (_h = groupsKey_2["return"])) _h.call(groupsKey_2); } finally { if (e_7) throw e_7.error; } } if (!ele.classList.contains("markBlockInfo")) { blockInfo = blockCache[username]; if (blockInfo && blockInfo.timestamp) { markBlocked(ele, blockInfo); } else { ele.classList.add("unknownBlockInfo"); unknownUsernames.add(username); } } } } catch (e_6_1) { e_6 = { error: e_6_1 }; } finally { try { if (_b && !_b.done && (_g = _a["return"])) _g.call(_a); } finally { if (e_6) throw e_6.error; } } if (!(unknownUsernames.size > 0)) return [3, 6]; return [4, mw.user.getRights()]; case 1: hasApihighlimits = (_m.sent()).includes("apihighlimits"); singleRequestLimit = hasApihighlimits ? 500 : 50; targets = __spreadArray([], __read(unknownUsernames.values()), false); _loop_1 = function (i, l) { var bkcontinue, target, blockedUserName, now_1, _result, _o, _p, username; var e_11, _q; return __generator(this, function (_r) { switch (_r.label) { case 0: bkcontinue = undefined; target = targets.slice(i * singleRequestLimit, (i + 1) * singleRequestLimit); blockedUserName = []; now_1 = Date.now(); _r.label = 1; case 1: if (!(bkcontinue !== eol)) return [3, 3]; return [4, api.post({ action: "query", assertuser: wgUserName, list: "blocks", bkusers: target, bklimit: "max", bkprop: "id|user|by|timestamp|expiry|reason|flags", bkcontinue: bkcontinue })]; case 2: _result = _r.sent(); if (_result["continue"]) { bkcontinue = _result["continue"].aufrom; } else { bkcontinue = eol; } _result.query.blocks.forEach(function (blockInfo) { var e_12, _a; blockedUserName.push(blockInfo.user); var info = "".concat(blockInfo.id, " - \n \u88ABU:").concat(blockInfo.by).concat(wgULS("封禁", "封鎖"), "\u4E8E").concat(toLocalTimeZoneString(new Date(blockInfo.timestamp)), "\uFF0C"); if (moment(blockInfo.expiry).isValid()) { info += "".concat(wgULS("持续", "持續"), "\u81F3").concat(toLocalTimeZoneString(new Date(blockInfo.expiry))); } else { info += wgULS("持续时间为无限期", "持續時間為不限期"); } info += "\n ".concat(wgULS("额外限制", "額外限制"), "\uFF1A"); if (!Reflect.has(blockInfo, "allowusertalk")) { blockInfo.nousertalk = true; } var flags = []; try { for (var blocklogFlags_1 = (e_12 = void 0, __values(blocklogFlags)), blocklogFlags_1_1 = blocklogFlags_1.next(); !blocklogFlags_1_1.done; blocklogFlags_1_1 = blocklogFlags_1.next()) { var _b = __read(blocklogFlags_1_1.value, 2), flag = _b[0], comment = _b[1]; if (Reflect.has(blockInfo, flag)) { flags.push(comment); } } } catch (e_12_1) { e_12 = { error: e_12_1 }; } finally { try { if (blocklogFlags_1_1 && !blocklogFlags_1_1.done && (_a = blocklogFlags_1["return"])) _a.call(blocklogFlags_1); } finally { if (e_12) throw e_12.error; } } if (flags.length === 0) { flags.push(wgULS("(无)", "(無)")); } info += flags.join("、"); info += "\n ".concat(wgULS("理由", "緣由"), "\uFF1A").concat(blockInfo.reason); blockCache[blockInfo.user] = { timestamp: now_1, isBlocked: true, info: info }; }); return [3, 1]; case 3: try { for (_o = (e_11 = void 0, __values(target.filter(function (username) { return !blockedUserName.includes(username); }))), _p = _o.next(); !_p.done; _p = _o.next()) { username = _p.value; blockCache[username] = { timestamp: now_1, isBlocked: false }; } } catch (e_11_1) { e_11 = { error: e_11_1 }; } finally { try { if (_p && !_p.done && (_q = _o["return"])) _q.call(_o); } finally { if (e_11) throw e_11.error; } } return [2]; } }); }; i = 0, l = Math.ceil(targets.length / singleRequestLimit); _m.label = 2; case 2: if (!(i < l)) return [3, 5]; return [5, _loop_1(i, l)]; case 3: _m.sent(); _m.label = 4; case 4: i++; return [3, 2]; case 5: try { for (_c = __values(querySelectorAll(".unknownBlockInfo")), _d = _c.next(); !_d.done; _d = _c.next()) { ele = _d.value; username = ele.dataset.username; blockInfo = blockCache[username]; if (blockInfo && blockInfo.timestamp) { markBlocked(ele, blockInfo); } } } catch (e_8_1) { e_8 = { error: e_8_1 }; } finally { try { if (_d && !_d.done && (_j = _c["return"])) _j.call(_c); } finally { if (e_8) throw e_8.error; } } localObjectStorage.setItem("blockCache", blockCache); _m.label = 6; case 6: try { for (groupsKey_3 = __values(groupsKey), groupsKey_3_1 = groupsKey_3.next(); !groupsKey_3_1.done; groupsKey_3_1 = groupsKey_3.next()) { group = groupsKey_3_1.value; try { for (_e = (e_10 = void 0, __values(querySelectorAll(".markrights-".concat(group)))), _f = _e.next(); !_f.done; _f = _e.next()) { node = _f.value; nextElementSibling = node.nextElementSibling; while (nextElementSibling && __spreadArray([], __read(nextElementSibling.classList), false).filter(function (className) { return className.startsWith("markrights-"); }).length > 0) { nextNextElementSibling = nextElementSibling.nextElementSibling; if (nextElementSibling.classList.contains(".markrights-".concat(group))) { nextElementSibling.remove(); } nextElementSibling = nextNextElementSibling; } } } catch (e_10_1) { e_10 = { error: e_10_1 }; } finally { try { if (_f && !_f.done && (_l = _e["return"])) _l.call(_e); } finally { if (e_10) throw e_10.error; } } } } catch (e_9_1) { e_9 = { error: e_9_1 }; } finally { try { if (groupsKey_3_1 && !groupsKey_3_1.done && (_k = groupsKey_3["return"])) _k.call(groupsKey_3); } finally { if (e_9) throw e_9.error; } } return [2]; } }); }); }; hook(); mw.hook("wikipage.content").add(hook); mw.hook("anntools.usergroup").add(hook); if (document.readyState !== "complete") { $(window).on("load", hook); } style = ["sup[class^=markrights-]+sup[class^=markrights-] { margin-left: 2px; }"]; try { for (groups_1 = __values(groups), groups_1_1 = groups_1.next(); !groups_1_1.done; groups_1_1 = groups_1.next()) { _f = __read(groups_1_1.value, 2), group = _f[0], color = _f[1]; style.push(".markrights-".concat(group, " { color: ").concat(color, "; }")); } } catch (e_3_1) { e_3 = { error: e_3_1 }; } finally { try { if (groups_1_1 && !groups_1_1.done && (_q = groups_1["return"])) _q.call(groups_1); } finally { if (e_3) throw e_3.error; } } try { for (_g = __values(Object.entries(groupStr)), _h = _g.next(); !_h.done; _h = _g.next()) { _j = __read(_h.value, 2), group = _j[0], strList = _j[1]; style.push("html .markrights-".concat(group, "::after { content: \"").concat(strList.zh, "\"; }")); try { for (_k = (e_5 = void 0, __values(Object.entries(strList))), _l = _k.next(); !_l.done; _l = _k.next()) { _m = __read(_l.value, 2), lang = _m[0], str = _m[1]; style.push("html[lang=".concat(lang.toLowerCase(), " i] .markrights-").concat(group, "::after { content: \"").concat(str, "\"; }")); } } catch (e_5_1) { e_5 = { error: e_5_1 }; } finally { try { if (_l && !_l.done && (_s = _k["return"])) _s.call(_k); } finally { if (e_5) throw e_5.error; } } } } catch (e_4_1) { e_4 = { error: e_4_1 }; } finally { try { if (_h && !_h.done && (_r = _g["return"])) _r.call(_g); } finally { if (e_4) throw e_4.error; } } mw.loader.addStyleTag(style.join("\n")); return [2]; } }); }); })(); /* </pre> */