本网站正在建设中(~ ̄▽ ̄)~
- 你好~!欢迎来到中文歌声合成个人收集站-VCPedia.cn!
- 若发现页面信息有误或投稿至本站,请联系管理员。
MediaWiki:Gadget-flagEditWar.js
跳到导航
跳到搜索
注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。
- Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5或Ctrl-R(Mac为⌘-R)
- Google Chrome:按Ctrl-Shift-R(Mac为⌘-Shift-R)
- Internet Explorer或Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
- Opera:按 Ctrl-F5。
/* <pre> */ /** * ------------------------------------------------------------------------- * !!! DON'T MODIFY THIS PAGE MANUALLY, YOUR CHANGES WILL BE OVERWRITTEN !!! * ------------------------------------------------------------------------- */ var _addText = '{{GHIACode|page=GHIA:MoegirlPediaInterfaceCodes/blob/master/src/gadgets/flagEditWar/MediaWiki:Gadget-flagEditWar.js|user=[[U:AnnAngela]]|longId=419cd5e745038a58a62252461c978d08c868eddb|shortId=419cd5e|message=eslint auto fix}}'; "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 (_) 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 () { var protectLevel = ["sysop", "patrolleredit"]; if ($("#EditWarWarningEndTime")[0] || mw.config.get("wgNamespaceNumber") !== 0 || !mw.config.get("wgUserGroups").includes("sysop") || !protectLevel.includes(mw.config.get("wgRestrictionEdit")[0])) { return; } var hasWarning = !!$("#EditWarWarning")[0]; var working = false; var main = function () { return __awaiter(void 0, void 0, void 0, function () { var pagename, api, data, user, endTime, template, summary, text, e_1; return __generator(this, function (_a) { switch (_a.label) { case 0: working = true; $("#mw-notification-area").appendTo("body"); pagename = mw.config.get("wgPageName"); api = new mw.Api(); _a.label = 1; case 1: _a.trys.push([1, 8, , 9]); mw.notify("正在查询日志……", { title: "正在标记编辑战", autoHide: false, tag: "lr-flagEditWar" }); return [4, api.get({ action: "query", list: "logevents", letype: "protect", leprop: "user|details", lelimit: 1, letitle: pagename })]; case 2: data = (_a.sent()).query.logevents["0"]; user = data.user; endTime = data.params.details[0].expiry; if (endTime === "infinite") { throw new Error("编辑战保护时长不应为「无限期」!"); } else { endTime = moment(endTime).utcOffset(8).format("YYYY年MM月DD日 HH:mm:ss [(CST)]"); } template = "{{\u7F16\u8F91\u6218|sysop=".concat(user, "|end=").concat(endTime, "}}\n"), summary = "\u7F16\u8F91\u6218\u6A21\u677F\uFF1A\u7531[[User_talk:".concat(user, "|").concat(user, "]]\u4FDD\u62A4\u81F3").concat(endTime); if (!hasWarning) return [3, 5]; mw.notify("检测到编辑战模板,正在获取页面内容……", { title: "正在标记编辑战", autoHide: false, tag: "lr-flagEditWar" }); return [4, api.get({ action: "parse", prop: "wikitext", page: pagename, section: 0 })]; case 3: text = (_a.sent()).parse.wikitext["*"]; text = text.replace(/\{\{编辑战(?:\|.*?)?\}\}\n?/, template); mw.notify("正在修改编辑战模板……", { title: "正在标记编辑战", autoHide: false, tag: "lr-flagEditWar" }); return [4, api.postWithToken("csrf", { action: "edit", title: pagename, section: 0, text: text, minor: true, summary: "\u4FEE\u6539".concat(summary), tags: "Automation tool" })]; case 4: _a.sent(); return [3, 7]; case 5: mw.notify("正在添加编辑战模板……", { title: "正在标记编辑战", autoHide: false, tag: "lr-flagEditWar" }); return [4, api.postWithToken("csrf", { action: "edit", title: pagename, section: 0, prependtext: template, minor: true, summary: "\u6DFB\u52A0".concat(summary), tags: "Automation tool" })]; case 6: _a.sent(); _a.label = 7; case 7: mw.notify("即将刷新……", { title: "标记编辑战成功", type: "success", tag: "lr-flagEditWar" }); window.setTimeout(function () { return location.reload(); }, 730); return [3, 9]; case 8: e_1 = _a.sent(); mw.notify(["编辑页面时出现错误:", $("<code />").text(e_1)], { title: "标记编辑战失败", type: "error", tag: "lr-flagEditWar" }); working = false; return [3, 9]; case 9: return [2]; } }); }); }; $(mw.util.addPortletLink("p-tb", "#", "标记编辑战", "t-lr-flagEditWar", "".concat(hasWarning ? "修改此页面的" : "在此页面悬挂", "\u7F16\u8F91\u6218\u6A21\u677F"))).on("click", 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(); _a = working; if (_a) return [3, 2]; return [4, oouiDialog.confirm("\u786E\u5B9A\u8981".concat(hasWarning ? "修改此页面的" : "在此页面悬挂", "\u7F16\u8F91\u6218\u6A21\u677F\u5417\uFF1F"), { title: "标记编辑战小工具" })]; case 1: _a = !(_b.sent()); _b.label = 2; case 2: if (_a) { return [2]; } main(); return [2]; } }); }); }); }); /* </pre> */