你现在正在访问的是萌娘百科用于保存和管理图片、音频等媒体文件的子项目萌娘共享,想要回到萌娘百科,请使用浏览器上的返回按钮、或点击这里
MediaWiki:Gadget-deletion.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),然后隐私和安全 → 清除浏览数据 → 缓存的图片和文件。
// <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 (_) 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 __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)); }; 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."); }; $(function () { return (function () { return __awaiter(void 0, void 0, void 0, function () { var globalDeletionLock, categories, sleep, deduplicate, generatePageLinkSelector, postMethods, api, container, node, portletLink, pages, isThatCategory, users, members, members_1, members_1_1, _a, title, pageid, _b, user, retryTimes, renderedHTML, root, reason, actor, link, isTrusted, e_1, e_2_1; var e_2, _c; return __generator(this, function (_d) { switch (_d.label) { case 0: if (mw.config.get("wgNamespaceNumber") !== 14 || !mw.config.get("wgIsArticle") || !mw.config.get("wgUserGroups").includes("sysop")) { return [2]; } globalDeletionLock = false; categories = { "zh.moegirl.org.cn": "即将删除的页面", "commons.moegirl.org.cn": "即将删除的页面", "en.moegirl.org.cn": "Pages awaiting deletion", "ja.moegirl.org.cn": "削除依頼中のページ", "library.moegirl.org.cn": "即将删除的页面" }; sleep = function (ms) { return new Promise(function (res) { return setTimeout(res, ms); }); }; deduplicate = function (iterable) { return __spreadArray([], __read(new Set(iterable).values()), false); }; generatePageLinkSelector = function (title) { return deduplicate([encodeURI(title), mw.util.wikiUrlencode(title)]).map(function (selector) { return "a[href$=\"/".concat(selector, "\"]"); }).join(","); }; return [4, mw.loader.using(["mediawiki.util", "mediawiki.api"])]; case 1: _d.sent(); postMethods = ["post", "postWithToken"]; api = new Proxy(new mw.Api(), { get: function (t, p) { if (postMethods.includes(p)) { return function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } return sleep(200).then(function () { return t[p].apply(t, __spreadArray([], __read(args), false)); }); }; } return t[p]; } }); container = $(".mw-category-generated"); node = $("<p/>").attr("id", "deletionControl"); portletLink = $(mw.util.addPortletLink("p-cactions", "#", "批量删除本分类下页面", "startDeletion", "批量删除本分类下页面")); portletLink.attr("class", "sysop-show").on("click", function () { if ($("#deletionControl")[0] || globalDeletionLock) { return false; } container.before(node); node.text("请选择要删除的页面:").append('(已选:<span id="deletionSelectingNumber"> - </span>/总计:<span id="deletionTotalNumber"> - </span>)').append($("<input/>").attr({ type: "button", value: "全选", id: "selectAll" })).append($("<input/>").attr({ type: "button", value: "全不选", id: "selectNone" })).append($("<input/>").attr({ type: "button", value: "提交", id: "runDeletion" })).append($("<input/>").attr({ type: "button", value: "取消", id: "cancelDeletion" })); $("body").addClass("deletion"); $(".mw-category-generated li").prepend($("<input/>").attr({ type: "checkbox", "class": "selectBox" })).find(".stub").toggleClass("stub _stub"); $("#deletionTotalNumber").text($(".mw-category-generated li :checkbox").length); $(".mw-category-generated li :checkbox").on("change", function () { $("#deletionSelectingNumber").text($(".mw-category-generated li :checkbox:checked").length); }).change(); $(".mw-category-generated > div > p").each(function (_, ele) { $("<input/>").attr({ type: "button", value: "全选本类别页面", "class": "deletionControlButton" }).appendTo(ele).on("click", function (_, ele) { $(ele).closest(".mw-category-generated > div").find(":checkbox:not(:disabled)").prop("checked", "checked").first().change(); }); $("<input/>").attr({ type: "button", value: "全不选本类别页面", "class": "deletionControlButton" }).appendTo(ele).on("click", function (_, ele) { $(ele).closest(".mw-category-generated > div").find(":checkbox:not(:disabled)").removeAttr("checked").first().change(); }); }); return false; }); pages = []; isThatCategory = mw.config.get("wgTitle") === categories[location.hostname]; if (!isThatCategory) return [3, 16]; globalDeletionLock = true; portletLink.find("a").text("正在加载中……"); return [4, (function () { return __awaiter(void 0, void 0, void 0, function () { var result, eol, aufrom, _result; return __generator(this, function (_a) { switch (_a.label) { case 0: result = []; eol = Symbol(); aufrom = undefined; _a.label = 1; case 1: if (!(aufrom !== eol)) return [3, 3]; return [4, api.post({ action: "query", list: "allusers", aurights: "rollback", aulimit: "max", aufrom: aufrom })]; case 2: _result = _a.sent(); if (_result["continue"]) { aufrom = _result["continue"].aufrom; } else { aufrom = eol; } result.push.apply(result, __spreadArray([], __read(_result.query.allusers.map(function (_a) { var name = _a.name; return name; })), false)); return [3, 1]; case 3: return [2, result]; } }); }); })()]; case 2: users = _d.sent(); return [4, (function () { return __awaiter(void 0, void 0, void 0, function () { var result, eol, gcmcontinue, _result; return __generator(this, function (_a) { switch (_a.label) { case 0: result = []; eol = Symbol(); gcmcontinue = undefined; _a.label = 1; case 1: if (!(gcmcontinue !== eol)) return [3, 3]; return [4, api.post({ action: "query", format: "json", rvprop: "user", prop: "revisions", generator: "categorymembers", gcmtitle: "Category:即将删除的页面", gcmprop: "ids|title", gcmtype: "page|subcat|file", gcmlimit: "max", gcmcontinue: gcmcontinue })]; case 2: _result = _a.sent(); if (_result["continue"]) { gcmcontinue = _result["continue"].gcmcontinue; } else { gcmcontinue = eol; } result.push.apply(result, __spreadArray([], __read(Object.values(_result.query.pages)), false)); return [3, 1]; case 3: return [2, result.filter(function (_a) { var title = _a.title; return document.querySelector(generatePageLinkSelector(title)); })]; } }); }); })()]; case 3: members = _d.sent(); _d.label = 4; case 4: _d.trys.push([4, 13, 14, 15]); members_1 = __values(members), members_1_1 = members_1.next(); _d.label = 5; case 5: if (!!members_1_1.done) return [3, 12]; _a = members_1_1.value, title = _a.title, pageid = _a.pageid, _b = __read(_a.revisions, 1), user = _b[0].user; retryTimes = 0; _d.label = 6; case 6: if (!(retryTimes < 3)) return [3, 11]; _d.label = 7; case 7: _d.trys.push([7, 9, , 10]); return [4, api.post({ action: "parse", pageid: pageid, prop: "text" })]; case 8: renderedHTML = (_d.sent()).parse.text["*"]; root = $("<div/>").html(renderedHTML); reason = root.find(".mw-parser-output > .infoBox.will2Be2Deleted #reason"); actor = root.find(".mw-parser-output > .infoBox.will2Be2Deleted #actor a").first(); link = $(generatePageLinkSelector(title)); if (reason.length === 1 && actor.length === 1) { isTrusted = user === actor.text() && users.includes(user); pages.push({ title: title, user: user, isTrusted: isTrusted, reason: reason.text() }); link.addClass("checked"); if (!isTrusted) { link.after("<a href=\"/".concat(mw.util.wikiUrlencode(title), "\" target=\"_blank\" class=\"linksBlank external\">").concat(link.html(), "</a> \u7981\u6B62\u5220\u9664\uFF1A\u8BE5\u6B21\u6302\u5220\u4E0D\u53EF\u9760\uFF0C\u8BF7\u624B\u52A8\u68C0\u67E5\uFF08").concat(user !== actor.text() ? "最后编辑者与挂删人不符" : "最后编辑者没有巡查权限", "\uFF09")).remove(); } else { link.after("<div style=\"clear: both; float: none\">\u6302\u5220\u4EBA\uFF1A<a href=\"/User:".concat(user, "\" class=\"mw-userlink bypass\"><bdi>").concat(user, "</bdi></a></div><div style=\"clear: both; float: none\">\u6302\u5220\u7406\u7531\uFF1A").concat(reason.text(), "</div>")); } } else { pages.push({ title: title, user: actor.text(), isTrusted: false, reason: reason.text() }); link.after("<a href=\"/".concat(mw.util.wikiUrlencode(title), "\" target=\"_blank\" class=\"linksBlank bypass external\">").concat(link.html(), "</a> \u7981\u6B62\u5220\u9664\uFF1A\u8BE5\u6B21\u6302\u5220\u4E0D\u53EF\u9760\uFF0C\u8BF7\u624B\u52A8\u68C0\u67E5\uFF08\u6302\u5220\u6A21\u677F\u672A\u7ED9\u51FA\u7406\u7531\u6216\u6302\u5220\u4EBA\uFF09")).remove(); } return [3, 11]; case 9: e_1 = _d.sent(); console.error("Deletion.js", e_1); return [3, 10]; case 10: retryTimes++; return [3, 6]; case 11: members_1_1 = members_1.next(); return [3, 5]; case 12: return [3, 15]; case 13: e_2_1 = _d.sent(); e_2 = { error: e_2_1 }; return [3, 15]; case 14: try { if (members_1_1 && !members_1_1.done && (_c = members_1["return"])) _c.call(members_1); } finally { if (e_2) throw e_2.error; } return [7]; case 15: container.find("li a").not(".bypass, .disabled, .undelectable, .checked").each(function (_, _link) { var link = $(_link); link.after("<a href=\"".concat(link.attr("href"), "\" target=\"_blank\" class=\"linksBlank bypass external\">").concat(link.html(), "</a> \u7981\u6B62\u5220\u9664\uFF1A\u8BE5\u9875\u9762\u672A\u88AB\u6302\u5220")).remove(); }); globalDeletionLock = false; mw.hook("wikipage.content").fire($(".mw-userlink.bypass")); portletLink.find("a").text("批量删除本分类下页面"); _d.label = 16; case 16: $("body").on("click", function (_a) { var target = _a.target; return __awaiter(void 0, void 0, void 0, function () { var self, statu, _loop_1, _b, _c, ele, state_1, e_3_1, e_4; var e_3, _d; return __generator(this, function (_e) { switch (_e.label) { case 0: self = $(target); if (!self.is("#selectAll")) return [3, 1]; container.find("li :checkbox:not(:disabled)").prop("checked", "checked").first().change(); return [3, 17]; case 1: if (!self.is("#selectNone")) return [3, 2]; container.find("li :checkbox:not(:disabled)").removeAttr("checked").first().change(); return [3, 17]; case 2: if (!self.is("#cancelDeletion")) return [3, 3]; if (globalDeletionLock) { return [2, false]; } $("#deletionControl, .deletionControlButton").remove(); container.find("._stub").toggleClass("stub _stub"); container.find(".selectBox").remove(); $(".disabled").removeClass("disabled"); return [3, 17]; case 3: if (!self.is("#runDeletion")) return [3, 16]; if (globalDeletionLock) { return [2, false]; } return [4, oouiDialog.confirm("\u60A8\u786E\u5B9A\u8981\u5220\u9664\u8FD9\u4E9B\u9875\u9762\u5417\uFF1F\uFF08\u9009\u4E2D\u4E86".concat($(".mw-category-generated li :checkbox:checked").length, "\u4E2A\u9875\u9762\uFF09"), { title: "批量删除分类下页面工具" })]; case 4: if (!(_e.sent())) { return [2]; } container.find(".deletionResult").remove(); container.find(".selectBox").attr("disabled", "disabled"); $("#deletionControl").append('<br><span id="result_text"><img src="https://img.moegirl.org.cn/common/d/d1/Windows_10_loading.gif" style="height: 1em; margin-top: -.25em;"><span id="deletionStatus"></span></span>'); statu = $("#deletionStatus"); globalDeletionLock = true; container.find("a:not(.bypass)").each(function (_, ele) { var self = $(ele); if (/User:AnnAngela\/SandBox/.test(self.text()) || !self.closest("li").find(":checked")[0]) { self.addClass("disabled"); } }); _e.label = 5; case 5: _e.trys.push([5, 14, , 15]); statu.text("正在删除,已完成删除的页面将会被删除线划去……"); _loop_1 = function (ele) { var self_1, url, link, page, e_5; return __generator(this, function (_f) { switch (_f.label) { case 0: self_1 = $(ele); if (self_1.text().trim() === "") { return [2, { value: void 0 }]; } self_1.css("margin-right", "2em"); url = new URL(self_1.attr("href")); link = decodeURIComponent(url.searchParams.has("title") ? url.searchParams.get("title") : url.pathname.replace(/^\//, "")).replace(/_/g, " "); page = pages.filter(function (_a) { var title = _a.title; return title === link; })[0]; _f.label = 1; case 1: _f.trys.push([1, 3, , 4]); return [4, api.postWithToken("csrf", { action: "delete", format: "json", title: link, tags: "Automation tool", reason: "\u6279\u91CF\u5220\u9664\u3010".concat(mw.config.get("wgPageName"), "\u3011\u4E0B\u7684\u9875\u9762").concat(isThatCategory && page.isTrusted && page.reason && page.user ? "\uFF08[[User_talk:".concat(page.user, "|").concat(page.user, "]]\u7684\u6302\u5220\u7406\u7531\uFF1A").concat(page.reason, " \uFF09") : "") }, { timeout: 99999 })]; case 2: _f.sent(); self_1.css("text-decoration", "line-through").after('<span class="deletionResult"> 删除成功</span>'); return [3, 4]; case 3: e_5 = _f.sent(); self_1.after("<span class=\"deletionResult\"> \u5220\u9664\u5931\u8D25\uFF1A".concat(e_5 instanceof Error ? "".concat(e_5, " ").concat(e_5.stack.split("\n")[1].trim()) : JSON.stringify(e_5), "</span>")); return [3, 4]; case 4: return [2]; } }); }; _e.label = 6; case 6: _e.trys.push([6, 11, 12, 13]); _b = __values(container.find("a").not(".bypass, .disabled, .undelectable").toArray()), _c = _b.next(); _e.label = 7; case 7: if (!!_c.done) return [3, 10]; ele = _c.value; return [5, _loop_1(ele)]; case 8: state_1 = _e.sent(); if (typeof state_1 === "object") return [2, state_1.value]; _e.label = 9; case 9: _c = _b.next(); return [3, 7]; case 10: return [3, 13]; case 11: e_3_1 = _e.sent(); e_3 = { error: e_3_1 }; return [3, 13]; case 12: try { if (_c && !_c.done && (_d = _b["return"])) _d.call(_b); } finally { if (e_3) throw e_3.error; } return [7]; case 13: $("#result_text").text("删除已完成!"); return [3, 15]; case 14: e_4 = _e.sent(); statu.text("\u53D1\u751F\u9519\u8BEF\uFF1A".concat(e_4 instanceof Error ? "".concat(e_4, " ").concat(e_4.stack.split("\n")[1].trim()) : JSON.stringify(e_4))); return [3, 15]; case 15: return [3, 17]; case 16: if (self.is("a") && globalDeletionLock) { window.open(self[0].href, "_blank"); return [2, false]; } _e.label = 17; case 17: return [2]; } }); }); }); return [2]; } }); }); })(); }); // </pre>