|
|
(未显示同一用户的2个中间版本) |
第1行: |
第1行: |
| "use strict";
| | (() => { |
| (async () => { | | |
| const { | |
| wgUserGroups: e,
| |
| wgServer: t,
| |
| wgServerName: i,
| |
| wgScriptPath: o,
| |
| wgPageName: n,
| |
| wgAction: a,
| |
| skin: r,
| |
| wgNamespaceNumber: c,
| |
| wgMainPageTitle: l,
| |
| } = mw.config.get(),
| |
| s = ["sysop", "patroller", "staff"],
| |
| m = e.filter((e) => s.includes(e)).length > 0,
| |
| { getResponseHeader: w } = XMLHttpRequest.prototype;
| |
| (XMLHttpRequest.prototype.getResponseHeader = function (e) {
| |
| return `\n${this.getAllResponseHeaders().toLowerCase()}`.includes(
| |
| `\n${e.toLowerCase()}: `
| |
| )
| |
| ? w.bind(this)(e)
| |
| : (console.info(
| |
| `Refused to get unsafe header "${e}"\n`,
| |
| this,
| |
| "\n",
| |
| new Error().stack
| |
| ),
| |
| null);
| |
| }),
| |
| await $.ready,
| |
| (() => {
| |
| const e = window.scrollTo;
| |
| let t = location.hash.startsWith("#/media/");
| |
| (window.scrollTo = (i, o) => {
| |
| t
| |
| ? console.info("Prevent multimediaViewer called")
| |
| : void 0 === o
| |
| ? e(i)
| |
| : e(i, o);
| |
| }),
| |
| setInterval(() => {
| |
| $(
| |
| "a.image img[data-file-width], a.image img[data-file-height], .mw-mmv-filepage-buttons a.mw-mmv-view-expanded"
| |
| )
| |
| .not(".multimediaViewerScrollSet")
| |
| .each((e, i) => {
| |
| i.addEventListener(
| |
| "click",
| |
| (e) => {
| |
| if (
| |
| $(e.target).closest(".TabLabelText")[0] ||
| |
| $(e.target).closest("a").closest(".mw-customtoggle")[0]
| |
| )
| |
| return (
| |
| e.preventDefault(),
| |
| e.stopPropagation(),
| |
| e.stopImmediatePropagation(),
| |
| $(
| |
| $(e.target).closest(".TabLabelText")[0] ||
| |
| $(e.target)
| |
| .closest("a")
| |
| .closest(".mw-customtoggle")[0]
| |
| ).trigger("click"),
| |
| !1
| |
| );
| |
| t = !0;
| |
| },
| |
| { capture: !0 }
| |
| ),
| |
| $(i).addClass("multimediaViewerScrollSet");
| |
| }),
| |
| document.querySelector(".mw-mmv-close")
| |
| ? "on" !== mw.config.get("wgMultimediaViewerInjected") &&
| |
| (mw.config.set("wgMultimediaViewerInjected", "on"),
| |
| $(".mw-mmv-image")
| |
| .off("click")[0]
| |
| .addEventListener(
| |
| "click",
| |
| (e) => {
| |
| if ($(e.target).is("img"))
| |
| return (
| |
| window
| |
| .open(
| |
| $(e.target)
| |
| .attr("src")
| |
| .replace(
| |
| /(img\.moegirl\.org\.cn\/common\/)thumb\/([a-z\d]+\/[a-z\d]+\/)([^/]+)\/\d+px-\3/i,
| |
| "$1$2$3"
| |
| ),
| |
| "_blank"
| |
| )
| |
| .focus(),
| |
| e.preventDefault(),
| |
| e.stopPropagation(),
| |
| e.stopImmediatePropagation(),
| |
| !1
| |
| );
| |
| $(e.target).closest(".error-box")[0] ||
| |
| $(".mw-mmv-close").trigger("click");
| |
| },
| |
| { capture: !0 }
| |
| ))
| |
| : "on" === mw.config.get("wgMultimediaViewerInjected") &&
| |
| ((t = !1), mw.config.set("wgMultimediaViewerInjected", "off"));
| |
| }, 137);
| |
| })(),
| |
| l === n && "view" === a && $("body").addClass("mainpage"),
| |
| window.getSelection &&
| |
| !m &&
| |
| !["edit", "submit"].includes(a) &&
| |
| [0, 4, 8, 10, 12, 274, 828].includes(c) &&
| |
| (async () => {
| |
| await mw.loader.using("mediawiki.util");
| |
| const e = $("<div>", {
| |
| css: {
| |
| position: "absolute",
| |
| left: "-99999px",
| |
| "z-index": "-99999",
| |
| },
| |
| html: `<pre></pre><br>\n阅读更多:${
| |
| /%/.test(mw.util.wikiUrlencode(n))
| |
| ? `${n}(${t}${o}/${encodeURIComponent(n)} )`
| |
| : `${t}${o}/${n}`
| |
| }<br>\n本文引自Vocawiki(${t.replace(
| |
| /^\/\//,
| |
| "https://"
| |
| )} ),文字内容默认使用《知识共享 署名-非商业性使用-相同方式共享 3.0 中国大陆》协议。`,
| |
| }).appendTo("body"),
| |
| i = e.find("pre");
| |
| $("#mw-content-text").on("copy", () => {
| |
| const t = window.getSelection(),
| |
| o = t.toString(),
| |
| n = t.getRangeAt(0);
| |
| !o.length ||
| |
| o.length < 128 ||
| |
| $(t.anchorNode)
| |
| .add(t.basenode)
| |
| .add(t.focusNode)
| |
| .closest(".Wikiplus-InterBox")[0] ||
| |
| (i.text(o),
| |
| t.selectAllChildren(e[0]),
| |
| window.setTimeout(() => {
| |
| t.removeAllRanges(), t.addRange(n), i.empty();
| |
| }, 0));
| |
| });
| |
| })(),
| |
| $.extend({
| |
| ucFirst: (e) => {
| |
| const t = `${e}`;
| |
| return t.charAt(0).toUpperCase() + t.substring(1);
| |
| },
| |
| }),
| |
| $(".reference-text > ul,.reference-text > ol").each((e, t) => {
| |
| t.parentElement.childNodes[0] === t && $(t).addClass("listInRef");
| |
| }),
| |
| $(".mw-collapsible")[0] &&
| |
| "" !== location.hash &&
| |
| (async () => {
| |
| await mw.loader.using(["jquery.makeCollapsible"]),
| |
| $(".mw-collapsible").makeCollapsible();
| |
| const { hash: e } = location;
| |
| (location.hash = ""), (location.hash = e);
| |
| })(),
| |
| (async () => {
| |
| const e = $("body").children("#content, #app").find("#notice-activity"),
| |
| t = "moeskin" === r,
| |
| i =
| |
| "moeskin" === r
| |
| ? {
| |
| visible: {
| |
| "user-select": "none",
| |
| "text-align": "center",
| |
| "box-sizing": "inherit",
| |
| background: "none",
| |
| margin: "0",
| |
| border: "0",
| |
| font: "inherit",
| |
| "vertical-align": "baseline",
| |
| "text-decoration": "none",
| |
| position: "absolute",
| |
| top: ".2rem",
| |
| color: "#fff",
| |
| "background-color": "#00000080",
| |
| "border-radius": "99em",
| |
| padding: ".1rem .5rem",
| |
| "line-height": "1.5",
| |
| right: ".2rem",
| |
| "z-index": "999999",
| |
| cursor: "pointer",
| |
| },
| |
| hidden: { top: "-0.8rem" },
| |
| }
| |
| : {
| |
| visible: {
| |
| position: "absolute",
| |
| right: "1rem",
| |
| top: "50%",
| |
| transform: "translate(0,-50%)",
| |
| fontSize: "1rem",
| |
| },
| |
| hidden: { transform: "translate(0,0)" },
| |
| };
| |
| if (e.length > 0) {
| |
| await mw.loader.using(["user.options"]),
| |
| mw.user.options.get("gadget-noticeActivity");
| |
| const o = e.data("topNoticeId"),
| |
| n = t ? e.parent() : e;
| |
| n.css("position", "relative");
| |
| const a = n.children(),
| |
| r = $("<span>");
| |
| r.css(i.visible);
| |
| const c = $("<a>");
| |
| c.attr({ href: "javascript:void(0);" }).text("隐藏活动通知"),
| |
| r.append(c),
| |
| t ? c.css({ color: "white" }) : r.prepend("[").append(c).append("]"),
| |
| n.append(r);
| |
| let l = !0;
| |
| c.on("click", () => {
| |
| l
| |
| ? ((l = !1),
| |
| a.hide(),
| |
| e.css({ height: "0px" }),
| |
| n.css({ overflow: "visible", "background-color": "transparent" }),
| |
| r.css(i.hidden),
| |
| localStorage.setItem("AnnTools-notice-activity", o),
| |
| c.text("显示活动通知"))
| |
| : ((l = !0),
| |
| a.show(),
| |
| e.css({ height: "auto" }),
| |
| n.css({
| |
| overflow: "visible",
| |
| "background-color": t
| |
| ? "var(--theme-card-background-color)"
| |
| : "transparent",
| |
| }),
| |
| r.css(i.visible),
| |
| localStorage.removeItem("AnnTools-notice-activity"),
| |
| c.text("隐藏活动通知"));
| |
| }),
| |
| localStorage.getItem("AnnTools-notice-activity") === o &&
| |
| c.trigger("click");
| |
| }
| |
| })(),
| |
| (async () => {
| |
| await mw.loader.using(["mediawiki.Uri"]);
| |
| const { rdfrom: e } = new mw.Uri().query;
| |
| if (e) {
| |
| const t = new mw.Uri(e);
| |
| if (
| |
| !t.host.includes(
| |
| [104, 109, 111, 101].map((e) => String.fromCharCode(e)).join("")
| |
| )
| |
| ) {
| |
| const { query: e } = t;
| |
| e.title &&
| |
| "no" === e.redirect &&
| |
| ("moeskin" === r
| |
| ? ((e) => {
| |
| const t = e.query.title,
| |
| i = e.host,
| |
| o = $("<div/>"),
| |
| n = $("<a/>");
| |
| o.html(
| |
| '<span class="moe-icon"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 256 512"><path d="M31.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L127.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L201.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34z" fill="currentColor"></path></svg></span>'
| |
| ),
| |
| n
| |
| .attr("href", `${e}`)
| |
| .text(`${t} 【来自 ${i} 的跨站重定向】`),
| |
| o.append(n),
| |
| $("#tagline").after(o);
| |
| })(t)
| |
| : ((e) => {
| |
| const t = e.query.title,
| |
| i = e.host,
| |
| o = $("<div/>"),
| |
| n = $("<a/>");
| |
| o.text("<"),
| |
| n
| |
| .attr("href", `${e}`)
| |
| .text(`${t} 【来自 ${i} 的跨站重定向】`),
| |
| o.append(n),
| |
| $("#contentSub").prepend(o);
| |
| })(t));
| |
| }
| |
| }
| |
| })(),
| |
| (async () => {
| |
| await mw.loader.using(["mediawiki.Uri"]),
| |
| $("#t-viewavatar > a").each((e, t) => {
| |
| const i = new mw.Uri(t.href);
| |
| (i.host = i.host.replace("zh.moegirl", "commons.moegirl")),
| |
| (t.href = i);
| |
| });
| |
| })(),
| |
| e.includes("user") &&
| |
| (async () => {
| |
| const e = $(
| |
| "body.skin-vector-2022 > #content > #siteNotice, body.skin-moeskin > #app > #moe-full-container > #moe-main-container > main > #moe-global-sidenav #moe-sidenav-sitenotice"
| |
| ),
| |
| t = {
| |
| pinnedAnnouncement: "置顶公告",
| |
| newAnnouncement: "7日内新公告",
| |
| discussing: "新的讨论中提案、申请",
| |
| voting: "新的投票中提案、申请",
| |
| voted: "新的已投票结束提案、申请",
| |
| },
| |
| i = [];
| |
| if (
| |
| (Object.keys(t).forEach((o) => {
| |
| const n = o,
| |
| a = e.find(`#topNotice-${o}`).find("a"),
| |
| r = ((e) => {
| |
| try {
| |
| const t = JSON.parse(localStorage.getItem(e));
| |
| return Array.isArray(t) ? t : [];
| |
| } catch {
| |
| return [];
| |
| }
| |
| })(`AnnTools-top-notice-exist-${n}`),
| |
| c = [],
| |
| l = [];
| |
| a.each((e, t) => {
| |
| const { href: i } = t,
| |
| o = t.text.trim();
| |
| c.push(i), r.includes(i) || l.push({ href: i, text: o });
| |
| }),
| |
| localStorage.setItem(
| |
| `AnnTools-top-notice-exist-${n}`,
| |
| JSON.stringify(c)
| |
| ),
| |
| l.length > 0 && i.push({ type: t[n], links: l });
| |
| }),
| |
| i.length > 0)
| |
| ) {
| |
| $("#mw-notification-area").appendTo("body");
| |
| const e = $("<dl>");
| |
| i.forEach((t) => {
| |
| e.append(
| |
| `<dt class="mw-parser-output" style="font-weight: 400;">${t.type}:</dt>`
| |
| );
| |
| const i = $("<dd>"),
| |
| o = $("<ul>");
| |
| i.css("marginLeft", ".9em"),
| |
| t.links.forEach((e) => {
| |
| const t = $("<li>"),
| |
| i = $("<a>");
| |
| i
| |
| .attr({ href: e.href, target: "_blank", class: "external" })
| |
| .text(e.text),
| |
| i.appendTo(t),
| |
| t.appendTo(o);
| |
| }),
| |
| o.appendTo(i),
| |
| i.appendTo(e);
| |
| }),
| |
| e.find("a").on("click", (e) => {
| |
| e.stopImmediatePropagation(), e.stopPropagation();
| |
| }),
| |
| await mw.loader.using([
| |
| "mediawiki.notification",
| |
| "mediawiki.notify",
| |
| ]),
| |
| mw.notify(e, {
| |
| autoHide: !1,
| |
| title: "有新的站务通知(点击通知空白处关闭)",
| |
| });
| |
| }
| |
| })(),
| |
| !m && $(".will2Be2Deleted")[0] && $("#ca-move").remove(),
| |
| ["mzh.moegirl.org.cn", "zh.moegirl.org.cn"].includes(i) &&
| |
| $(
| |
| 'a.external.text[href$="&action=edit"], .plainlinks.userlink .external'
| |
| ).each((e, t) => {
| |
| const o = $(t);
| |
| o.attr(
| |
| "href",
| |
| o.attr("href").replace(/(?:mobile|mzh|zh)\.moegirl\.org\.cn/, i)
| |
| );
| |
| }),
| |
| $(window).on("load", () => {
| |
| $(".mw-helplink").each((e, t) => {
| |
| t.href.endsWith("/zh") || (t.href += "/zh");
| |
| });
| |
| });
| |
| })(); | | })(); |