你现在正在访问的是萌娘百科用于保存和管理图片、音频等媒体文件的子项目萌娘共享,想要回到萌娘百科,请使用浏览器上的返回按钮、或点击这里
“MediaWiki:Common.js”的版本间的差异
AnnAngela-dbot(讨论 | 贡献) (代码变动:e1e15bf6 - chore: eslint by U:星海子) (1个标签:由机器人或全自动脚本执行的操作) |
|||
(未显示4个用户的21个中间版本) | |||
第1行: | 第1行: | ||
− | /* | + | /** |
− | + | * ------------------------------------------------------------------------- | |
− | + | * !!! DON'T MODIFY THIS PAGE MANUALLY, YOUR CHANGES WILL BE OVERWRITTEN !!! | |
− | + | * ------------------------------------------------------------------------- | |
− | + | */ | |
− | + | var _addText = '{{GHIACode|page=GHIA:MoegirlPediaInterfaceCodes/blob/master/src/global/commons/MediaWiki:Common.js|user=[[U: 星海子]]|co-authors=|longId=e1e15bf6ac13a6c997a9a3208dab7f70fa6a77fb|shortId=e1e15bf6|summary=chore: eslint}}'; | |
− | + | ||
− | + | /* <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); } | |
− | var | + | step((generator = generator.apply(thisArg, _arguments || [])).next()); |
− | + | }); | |
− | + | }; | |
− | + | var __generator = (this && this.__generator) || function (thisArg, body) { | |
− | function | + | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; |
− | if ( | + | 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 () { | |
− | + | function zhUserPage() { | |
− | + | $("#mw-content-text a").each(function () { | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | $( | ||
try { | try { | ||
var link = new mw.Uri(this.href); | var link = new mw.Uri(this.href); | ||
− | if (link.toString().startsWith(mw.config.get("wgServer") + mw.config.get("wgScriptPath") | + | if (link.toString().startsWith("".concat(mw.config.get("wgServer") + mw.config.get("wgScriptPath"), "/"))) { |
− | if (/^\/api\.php/i.test(link.path)) return; | + | return; |
− | if (!link.query.title && /\.php$/i.test(link.path)) return; | + | } |
− | if (link.query && (link.query.action || link.query.diff)) return; | + | if (/^\/api\.php/i.test(link.path)) { |
− | var href = ((link.query.title || decodeURI(link.path.substring(1))).match(/^user(?:[ _]talk)?:[^ | + | return; |
− | if (href) $(this).after( | + | } |
− | } catch ( | + | if (!link.query.title && /\.php$/i.test(link.path)) { |
+ | return; | ||
+ | } | ||
+ | if (link.query && (link.query.action || link.query.diff)) { | ||
+ | return; | ||
+ | } | ||
+ | var href = ((link.query.title || decodeURI(link.path.substring(1))).match(/^user(?:[ _]talk)?:[^/]+/i) || [null])[0]; | ||
+ | if (href) { | ||
+ | $(this).after("<sub>[<a target=\"_blank\" title=\"\u4E3B\u7AD9\u4E0A\u7684\u7528\u6237 ".concat(href.replace(/user(_talk)?:/i, ""), "\" href=\"").concat(mw.config.get("wgServer").replace("commons.moegirl", "zh.moegirl")).concat(mw.config.get("wgScriptPath"), "/").concat(href, "\">\u4E3B</a>]</sub>")); | ||
+ | } | ||
+ | } | ||
+ | catch (_e) { | ||
return; | return; | ||
} | } | ||
}); | }); | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
− | + | var allowedInNamespace, allowedGroups, allowedInGroup, body, html, $body, $window, editSet, topGoback, fileInfo, license, filePage, wpSummary_1; | |
− | + | return __generator(this, function (_a) { | |
− | + | switch (_a.label) { | |
− | + | case 0: | |
− | + | allowedInNamespace = [-1, -2, 6, 14, 8, 10, 12, 828].includes(mw.config.get("wgNamespaceNumber")); | |
− | + | allowedGroups = ["sysop", "patroller", "staff"]; | |
+ | allowedInGroup = mw.config.get("wgUserGroups").filter(function (group) { return allowedGroups.includes(group); }).length > 0; | ||
+ | body = document.body; | ||
+ | html = document.documentElement; | ||
+ | $body = $(body); | ||
+ | $window = $(window); | ||
+ | $window.on("resize", function () { | ||
+ | var innerWidth = window.innerWidth; | ||
+ | var scrollbarWidth; | ||
+ | switch ("scroll") { | ||
+ | case getComputedStyle(body).overflowY: { | ||
+ | scrollbarWidth = innerWidth - body.clientWidth; | ||
+ | break; | ||
+ | } | ||
+ | case getComputedStyle(html).overflowY: { | ||
+ | scrollbarWidth = innerWidth - html.clientWidth; | ||
+ | break; | ||
+ | } | ||
+ | default: { | ||
+ | var backup = body.style.overflowY; | ||
+ | body.style.overflowY = "scroll"; | ||
+ | scrollbarWidth = innerWidth - body.clientWidth; | ||
+ | body.style.overflowY = backup; | ||
+ | } | ||
+ | } | ||
+ | $body[scrollbarWidth === 0 ? "addClass" : "removeClass"]("overlay-scrollbars"); | ||
+ | }).trigger("resize"); | ||
+ | jQuery.extend({ | ||
+ | ucFirst: function (s) { return "".concat("".concat(s).charAt(0).toUpperCase()).concat("".concat(s).substring(1)); } | ||
}); | }); | ||
− | + | editSet = function () { return __awaiter(void 0, void 0, void 0, function () { | |
− | + | return __generator(this, function (_a) { | |
− | + | switch (_a.label) { | |
− | + | case 0: return [4, mw.loader.using(["mediawiki.util"])]; | |
− | + | case 1: | |
+ | _a.sent(); | ||
+ | if (/\.(?:js|css)$/.test(mw.util.getParamValue("title") || location.pathname)) { | ||
+ | return [2]; | ||
+ | } | ||
+ | if ([2, 3].includes(mw.config.get("wgNamespaceNumber")) && mw.config.get("wgAction") === "edit" && mw.config.get("wgArticleId") === 0) { | ||
+ | location.host = location.host.replace("commons.moegirl", "zh.moegirl"); | ||
+ | return [2]; | ||
+ | } | ||
+ | if (mw.config.get("wgArticleId") === 0 && !allowedInNamespace && !allowedInGroup) { | ||
+ | $('a[href*="veaction=edit"]').remove(); | ||
+ | if ($('[class*="ve-init"]').length > 0) { | ||
+ | $window.off(); | ||
+ | location.replace("/".concat(mw.config.get("wgPageName"))); | ||
+ | } | ||
+ | $('#wikiEditor-ui-toolbar, #wpSummaryLabel, #wpSummaryWidget, [name="wpSummary"], .editCheckboxes, #wpMinoreditWidget, [name="wpMinoredit"], #wpWatchthisWidget, [name="wpWatchthis"], #editpage-copywarn, #wpSaveWidget, [name="wpSave"], #wpPreviewWidget, [name="wpPreview"], #wpDiffWidget, [name="wpDiff"], [name="wpEditToken"]').remove(); | ||
+ | $(".editOptions").prepend("<p>\u672C\u7AD9\u4EC5\u4F9B\u4E0A\u4F20\u56FE\u7247\u7528\uFF0C\u8BF7\u52FF\u5728\u672C\u7AD9\u521B\u5EFA\u9875\u9762\uFF0C\u5982\u6709\u9700\u8981\u8BF7\u5230<a target=\"_blank\" rel=\"nofollow noreferrer noopener\" class=\"external text\" href=\"".concat(mw.config.get("wgServer").replace("commons.moegirl", "zh.moegirl")).concat(mw.config.get("wgScriptPath"), "\">\u4E3B\u7AD9</a>\u3002</p>")); | ||
+ | $('#editform, [name="editform"]').each(function (_, ele) { | ||
+ | $(ele).removeAttr("action"); | ||
+ | ele.addEventListener("submit", function (e) { | ||
+ | e.preventDefault(); | ||
+ | }, { | ||
+ | capture: true | ||
+ | }); | ||
+ | }); | ||
+ | } | ||
+ | return [2]; | ||
+ | } | ||
+ | }); | ||
+ | }); }; | ||
+ | topGoback = function () { | ||
+ | if ("".concat(new mw.Uri(document.referrer)).startsWith("".concat("".concat(mw.config.get("wgServer").replace("commons.moegirl", "zh.moegirl")).concat(mw.config.get("wgScriptPath")), "/"))) { | ||
+ | $("#back").removeAttr("style").on("click", function () { | ||
+ | if (history.length > 1) { | ||
+ | history.go(-1); | ||
+ | } | ||
+ | else { | ||
+ | location.href = document.referrer; | ||
+ | } | ||
+ | }); | ||
+ | } | ||
+ | }; | ||
+ | fileInfo = function () { | ||
+ | if ($(".fileInfo")[0]) { | ||
+ | $(".mw-ui-button-group.mw-mmv-filepage-buttons:first").prepend($("<a/>", { | ||
+ | "class": "mw-mmv-view-expanded mw-ui-button mw-ui-icon", | ||
+ | text: "在萌娘百科上查看文件说明页" | ||
+ | }).on("click", function () { | ||
+ | window.open(mw.config.get("wgServer").replace("commons.moegirl", "zh.moegirl") + mw.config.get("wgScriptPath") + location.pathname + location.search, "_blank"); | ||
+ | })); | ||
+ | } | ||
+ | }; | ||
+ | license = function () { | ||
+ | if (mw.config.get("wgCanonicalSpecialPageName") === "Upload") { | ||
+ | var wpLicense_1 = $("#wpLicense"); | ||
+ | wpLicense_1.val("Copyright").trigger("change"); | ||
+ | $("#mw-upload-form").on("submit", function () { | ||
+ | if (wpLicense_1.val() === "Authorized") { | ||
+ | localStorage.setItem("AnnTools-license-authorized-".concat(encodeURIComponent("File:".concat($("#wpDestFile").val().replace(/ /g, "_")))), "true"); | ||
+ | } | ||
+ | }); | ||
+ | } | ||
+ | else if (mw.config.get("wgAction") === "edit" && mw.util.getParamValue("authorized") === "1") { | ||
+ | var wpTextbox1 = $("#wpTextbox1"); | ||
+ | wpTextbox1.val(wpTextbox1.val().replace("{{Authorized}}", "{{Authorized\n|作者名=<!--适用于作者授权百科长期使用其作品的情形,此时直接填入作者名即可-->\n|授权证明=<!--适用于作者仅授权单张图片的情形,可以在此填写授权证明的文件链接、或是相关请求授权的讨论链接等-->\n}}")); | ||
+ | setTimeout(function () { | ||
+ | alert("请在编辑框内填入相关授权信息!"); | ||
+ | }, 0); | ||
+ | } | ||
+ | else { | ||
+ | var wgPageName = encodeURIComponent((mw.config.get("wgPageName") || "").replace(/ /g, "_")); | ||
+ | if (localStorage.getItem("AnnTools-license-authorized-".concat(wgPageName)) === "true") { | ||
+ | localStorage.removeItem("AnnTools-license-authorized-".concat(wgPageName)); | ||
+ | location.replace("".concat(mw.config.get("wgServer") + mw.config.get("wgScriptPath"), "/index.php?title=").concat(wgPageName, "&action=edit&authorized=1")); | ||
+ | } | ||
+ | } | ||
+ | }; | ||
+ | filePage = function () { return __awaiter(void 0, void 0, void 0, function () { | ||
+ | var editbutton, loginbutton; | ||
+ | return __generator(this, function (_a) { | ||
+ | switch (_a.label) { | ||
+ | case 0: | ||
+ | if (!(mw.config.get("wgNamespaceNumber") === 6 && (mw.config.get("wgArticleId") || -1) > 0 && mw.config.get("wgAction") === "view" && (mw.config.get("wgRevisionId") || -1) === (mw.config.get("wgCurRevisionId") || -2) && !document.querySelector(".license-info"))) return [3, 3]; | ||
+ | if (!(document.querySelector(".common-box") && mw.config.get("wgUserId", -1) > 0)) return [3, 2]; | ||
+ | return [4, mw.loader.using("mediawiki.api")]; | ||
+ | case 1: | ||
+ | _a.sent(); | ||
+ | return [2, new mw.Api().post({ | ||
+ | action: "purge", | ||
+ | pageids: mw.config.get("wgArticleId", -1) | ||
+ | })]; | ||
+ | case 2: | ||
+ | editbutton = document.querySelector("#ca-edit a"); | ||
+ | loginbutton = document.querySelector("#pt-login a"); | ||
+ | $("#mw-imagepage-content, #mw-imagepage-content .mw-parser-output").last().append("<table class=\"common-box license-info\" style=\"margin: 0.5em 10%; width:80%; background: #FBFBFB; border-left: 10px solid Salmon;\"><tbody><tr><td style=\"padding: 2px 0 2px 0.5em\"><img alt=\"Red copyright.svg\" src=\"https://img.moegirl.org.cn/common/1/1d/Red_copyright.svg\" width=\"50\" height=\"50\"></td><td style=\"padding: 0.25em 0.5em\"><div><span style=\"font-weight: bold;\">\u7531\u4E8E\u4E0A\u4F20\u8005\u672A\u586B\u5199\u6388\u6743\u534F\u8BAE</span>\uFF0C\u672C\u4F5C\u54C1\u9ED8\u8BA4\u4EC5\u4EE5\u4ECB\u7ECD\u4E3A\u76EE\u7684\u5728\u6B64\u767E\u79D1\u4E2D\u4EE5\u975E\u76C8\u5229\u6027\u65B9\u5F0F\u5408\u7406\u4F7F\u7528\u3002</div>".concat(loginbutton || editbutton ? "<div>\u60A8\u77E5\u9053\u8BE5\u6587\u4EF6\u7684\u4F5C\u8005\u662F\u5982\u4F55\u6388\u6743\u7684\u5417\uFF1F\u5982\u679C\u60A8\u77E5\u9053\u7684\u8BDD\u6B22\u8FCE<span style=\"font-weight: bold;\">".concat(editbutton ? "<a href=\"".concat(editbutton.href, "\">\u7F16\u8F91\u8BE5\u9875\u9762</a>") : "<a href=\"".concat(mw.config.get("wgServer")).concat(mw.config.get("wgScriptPath"), "/index.php?title=Special:%E7%94%A8%E6%88%B7%E7%99%BB%E5%BD%95&returntoquery=action%3Dedit&returnto=").concat(encodeURIComponent(mw.config.get("wgPageName")), "\">\u767B\u5F55\u540E\u7F16\u8F91\u8BE5\u9875\u9762</a>"), "</span>\u586B\u5199\u6388\u6743\u534F\u8BAE~~</div>") : "", "</td></tr></tbody></table>")); | ||
+ | _a.label = 3; | ||
+ | case 3: return [2]; | ||
+ | } | ||
+ | }); | ||
+ | }); }; | ||
+ | if (["edit", "submit"].includes(mw.config.get("wgAction"))) { | ||
+ | wpSummary_1 = $('[name="wpSummary"]'); | ||
+ | $(".mw-summary-preset-item a").on("click", function () { | ||
+ | wpSummary_1.val("".concat(wpSummary_1.val(), " ").concat($(this).text()).trim()); | ||
+ | wpSummary_1.focus(); | ||
+ | return false; | ||
+ | }); | ||
+ | } | ||
+ | return [4, $.ready]; | ||
+ | case 1: | ||
+ | _a.sent(); | ||
+ | editSet(); | ||
+ | topGoback(); | ||
+ | fileInfo(); | ||
+ | filePage(); | ||
+ | zhUserPage(); | ||
+ | license(); | ||
+ | if (!allowedInGroup && $(".will2Be2Deleted")[0]) { | ||
+ | $("#ca-move").remove(); | ||
+ | } | ||
+ | $window.on("load", function () { | ||
+ | editSet(); | ||
+ | }); | ||
+ | return [2]; | ||
} | } | ||
− | } | + | }); |
− | + | }); })(); | |
− | + | ||
− | + | /* </pre> */ | |
− |
2024年4月16日 (二) 09:20的最新版本
/** * ------------------------------------------------------------------------- * !!! DON'T MODIFY THIS PAGE MANUALLY, YOUR CHANGES WILL BE OVERWRITTEN !!! * ------------------------------------------------------------------------- */ var _addText = '{{GHIACode|page=GHIA:MoegirlPediaInterfaceCodes/blob/master/src/global/commons/MediaWiki:Common.js|user=[[U:星海子]]|co-authors=|longId=e1e15bf6ac13a6c997a9a3208dab7f70fa6a77fb|shortId=e1e15bf6|summary=chore: eslint}}'; /* <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 () { function zhUserPage() { $("#mw-content-text a").each(function () { try { var link = new mw.Uri(this.href); if (link.toString().startsWith("".concat(mw.config.get("wgServer") + mw.config.get("wgScriptPath"), "/"))) { return; } if (/^\/api\.php/i.test(link.path)) { return; } if (!link.query.title && /\.php$/i.test(link.path)) { return; } if (link.query && (link.query.action || link.query.diff)) { return; } var href = ((link.query.title || decodeURI(link.path.substring(1))).match(/^user(?:[ _]talk)?:[^/]+/i) || [null])[0]; if (href) { $(this).after("<sub>[<a target=\"_blank\" title=\"\u4E3B\u7AD9\u4E0A\u7684\u7528\u6237 ".concat(href.replace(/user(_talk)?:/i, ""), "\" href=\"").concat(mw.config.get("wgServer").replace("commons.moegirl", "zh.moegirl")).concat(mw.config.get("wgScriptPath"), "/").concat(href, "\">\u4E3B</a>]</sub>")); } } catch (_e) { return; } }); } var allowedInNamespace, allowedGroups, allowedInGroup, body, html, $body, $window, editSet, topGoback, fileInfo, license, filePage, wpSummary_1; return __generator(this, function (_a) { switch (_a.label) { case 0: allowedInNamespace = [-1, -2, 6, 14, 8, 10, 12, 828].includes(mw.config.get("wgNamespaceNumber")); allowedGroups = ["sysop", "patroller", "staff"]; allowedInGroup = mw.config.get("wgUserGroups").filter(function (group) { return allowedGroups.includes(group); }).length > 0; body = document.body; html = document.documentElement; $body = $(body); $window = $(window); $window.on("resize", function () { var innerWidth = window.innerWidth; var scrollbarWidth; switch ("scroll") { case getComputedStyle(body).overflowY: { scrollbarWidth = innerWidth - body.clientWidth; break; } case getComputedStyle(html).overflowY: { scrollbarWidth = innerWidth - html.clientWidth; break; } default: { var backup = body.style.overflowY; body.style.overflowY = "scroll"; scrollbarWidth = innerWidth - body.clientWidth; body.style.overflowY = backup; } } $body[scrollbarWidth === 0 ? "addClass" : "removeClass"]("overlay-scrollbars"); }).trigger("resize"); jQuery.extend({ ucFirst: function (s) { return "".concat("".concat(s).charAt(0).toUpperCase()).concat("".concat(s).substring(1)); } }); editSet = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { case 0: return [4, mw.loader.using(["mediawiki.util"])]; case 1: _a.sent(); if (/\.(?:js|css)$/.test(mw.util.getParamValue("title") || location.pathname)) { return [2]; } if ([2, 3].includes(mw.config.get("wgNamespaceNumber")) && mw.config.get("wgAction") === "edit" && mw.config.get("wgArticleId") === 0) { location.host = location.host.replace("commons.moegirl", "zh.moegirl"); return [2]; } if (mw.config.get("wgArticleId") === 0 && !allowedInNamespace && !allowedInGroup) { $('a[href*="veaction=edit"]').remove(); if ($('[class*="ve-init"]').length > 0) { $window.off(); location.replace("/".concat(mw.config.get("wgPageName"))); } $('#wikiEditor-ui-toolbar, #wpSummaryLabel, #wpSummaryWidget, [name="wpSummary"], .editCheckboxes, #wpMinoreditWidget, [name="wpMinoredit"], #wpWatchthisWidget, [name="wpWatchthis"], #editpage-copywarn, #wpSaveWidget, [name="wpSave"], #wpPreviewWidget, [name="wpPreview"], #wpDiffWidget, [name="wpDiff"], [name="wpEditToken"]').remove(); $(".editOptions").prepend("<p>\u672C\u7AD9\u4EC5\u4F9B\u4E0A\u4F20\u56FE\u7247\u7528\uFF0C\u8BF7\u52FF\u5728\u672C\u7AD9\u521B\u5EFA\u9875\u9762\uFF0C\u5982\u6709\u9700\u8981\u8BF7\u5230<a target=\"_blank\" rel=\"nofollow noreferrer noopener\" class=\"external text\" href=\"".concat(mw.config.get("wgServer").replace("commons.moegirl", "zh.moegirl")).concat(mw.config.get("wgScriptPath"), "\">\u4E3B\u7AD9</a>\u3002</p>")); $('#editform, [name="editform"]').each(function (_, ele) { $(ele).removeAttr("action"); ele.addEventListener("submit", function (e) { e.preventDefault(); }, { capture: true }); }); } return [2]; } }); }); }; topGoback = function () { if ("".concat(new mw.Uri(document.referrer)).startsWith("".concat("".concat(mw.config.get("wgServer").replace("commons.moegirl", "zh.moegirl")).concat(mw.config.get("wgScriptPath")), "/"))) { $("#back").removeAttr("style").on("click", function () { if (history.length > 1) { history.go(-1); } else { location.href = document.referrer; } }); } }; fileInfo = function () { if ($(".fileInfo")[0]) { $(".mw-ui-button-group.mw-mmv-filepage-buttons:first").prepend($("<a/>", { "class": "mw-mmv-view-expanded mw-ui-button mw-ui-icon", text: "在萌娘百科上查看文件说明页" }).on("click", function () { window.open(mw.config.get("wgServer").replace("commons.moegirl", "zh.moegirl") + mw.config.get("wgScriptPath") + location.pathname + location.search, "_blank"); })); } }; license = function () { if (mw.config.get("wgCanonicalSpecialPageName") === "Upload") { var wpLicense_1 = $("#wpLicense"); wpLicense_1.val("Copyright").trigger("change"); $("#mw-upload-form").on("submit", function () { if (wpLicense_1.val() === "Authorized") { localStorage.setItem("AnnTools-license-authorized-".concat(encodeURIComponent("File:".concat($("#wpDestFile").val().replace(/ /g, "_")))), "true"); } }); } else if (mw.config.get("wgAction") === "edit" && mw.util.getParamValue("authorized") === "1") { var wpTextbox1 = $("#wpTextbox1"); wpTextbox1.val(wpTextbox1.val().replace("{{Authorized}}", "{{Authorized\n|作者名=<!--适用于作者授权百科长期使用其作品的情形,此时直接填入作者名即可-->\n|授权证明=<!--适用于作者仅授权单张图片的情形,可以在此填写授权证明的文件链接、或是相关请求授权的讨论链接等-->\n}}")); setTimeout(function () { alert("请在编辑框内填入相关授权信息!"); }, 0); } else { var wgPageName = encodeURIComponent((mw.config.get("wgPageName") || "").replace(/ /g, "_")); if (localStorage.getItem("AnnTools-license-authorized-".concat(wgPageName)) === "true") { localStorage.removeItem("AnnTools-license-authorized-".concat(wgPageName)); location.replace("".concat(mw.config.get("wgServer") + mw.config.get("wgScriptPath"), "/index.php?title=").concat(wgPageName, "&action=edit&authorized=1")); } } }; filePage = function () { return __awaiter(void 0, void 0, void 0, function () { var editbutton, loginbutton; return __generator(this, function (_a) { switch (_a.label) { case 0: if (!(mw.config.get("wgNamespaceNumber") === 6 && (mw.config.get("wgArticleId") || -1) > 0 && mw.config.get("wgAction") === "view" && (mw.config.get("wgRevisionId") || -1) === (mw.config.get("wgCurRevisionId") || -2) && !document.querySelector(".license-info"))) return [3, 3]; if (!(document.querySelector(".common-box") && mw.config.get("wgUserId", -1) > 0)) return [3, 2]; return [4, mw.loader.using("mediawiki.api")]; case 1: _a.sent(); return [2, new mw.Api().post({ action: "purge", pageids: mw.config.get("wgArticleId", -1) })]; case 2: editbutton = document.querySelector("#ca-edit a"); loginbutton = document.querySelector("#pt-login a"); $("#mw-imagepage-content, #mw-imagepage-content .mw-parser-output").last().append("<table class=\"common-box license-info\" style=\"margin: 0.5em 10%; width:80%; background: #FBFBFB; border-left: 10px solid Salmon;\"><tbody><tr><td style=\"padding: 2px 0 2px 0.5em\"><img alt=\"Red copyright.svg\" src=\"https://img.moegirl.org.cn/common/1/1d/Red_copyright.svg\" width=\"50\" height=\"50\"></td><td style=\"padding: 0.25em 0.5em\"><div><span style=\"font-weight: bold;\">\u7531\u4E8E\u4E0A\u4F20\u8005\u672A\u586B\u5199\u6388\u6743\u534F\u8BAE</span>\uFF0C\u672C\u4F5C\u54C1\u9ED8\u8BA4\u4EC5\u4EE5\u4ECB\u7ECD\u4E3A\u76EE\u7684\u5728\u6B64\u767E\u79D1\u4E2D\u4EE5\u975E\u76C8\u5229\u6027\u65B9\u5F0F\u5408\u7406\u4F7F\u7528\u3002</div>".concat(loginbutton || editbutton ? "<div>\u60A8\u77E5\u9053\u8BE5\u6587\u4EF6\u7684\u4F5C\u8005\u662F\u5982\u4F55\u6388\u6743\u7684\u5417\uFF1F\u5982\u679C\u60A8\u77E5\u9053\u7684\u8BDD\u6B22\u8FCE<span style=\"font-weight: bold;\">".concat(editbutton ? "<a href=\"".concat(editbutton.href, "\">\u7F16\u8F91\u8BE5\u9875\u9762</a>") : "<a href=\"".concat(mw.config.get("wgServer")).concat(mw.config.get("wgScriptPath"), "/index.php?title=Special:%E7%94%A8%E6%88%B7%E7%99%BB%E5%BD%95&returntoquery=action%3Dedit&returnto=").concat(encodeURIComponent(mw.config.get("wgPageName")), "\">\u767B\u5F55\u540E\u7F16\u8F91\u8BE5\u9875\u9762</a>"), "</span>\u586B\u5199\u6388\u6743\u534F\u8BAE~~</div>") : "", "</td></tr></tbody></table>")); _a.label = 3; case 3: return [2]; } }); }); }; if (["edit", "submit"].includes(mw.config.get("wgAction"))) { wpSummary_1 = $('[name="wpSummary"]'); $(".mw-summary-preset-item a").on("click", function () { wpSummary_1.val("".concat(wpSummary_1.val(), " ").concat($(this).text()).trim()); wpSummary_1.focus(); return false; }); } return [4, $.ready]; case 1: _a.sent(); editSet(); topGoback(); fileInfo(); filePage(); zhUserPage(); license(); if (!allowedInGroup && $(".will2Be2Deleted")[0]) { $("#ca-move").remove(); } $window.on("load", function () { editSet(); }); return [2]; } }); }); })(); /* </pre> */