From 85d9cc8222802995b935134c688277a9dcb5f7ea Mon Sep 17 00:00:00 2001 From: fallenice2022 <111823793+fallenice2022@users.noreply.github.com> Date: Tue, 31 Oct 2023 16:50:11 +0000 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=8F=98=E9=87=8F=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E3=80=81=E6=98=BE=E7=A4=BA=E9=A2=84=E5=8A=A0=E8=BD=BD=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E7=A7=BB=E5=8A=A8=E8=87=B3edit.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gadgets/edit/MediaWiki:Gadget-edit.js | 19 ++++++++++++------- .../site-js/MediaWiki:Gadget-site-js.js | 4 ---- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/gadgets/edit/MediaWiki:Gadget-edit.js b/src/gadgets/edit/MediaWiki:Gadget-edit.js index e0348e67..85ca649a 100644 --- a/src/gadgets/edit/MediaWiki:Gadget-edit.js +++ b/src/gadgets/edit/MediaWiki:Gadget-edit.js @@ -4,14 +4,18 @@ $(() => { if (!["edit", "submit"].includes(mw.config.get("wgAction"))) { return; } - if (mw.config.get("wgPageName").startsWith("萌娘百科_talk:讨论版/")) { + const wgPageName = mw.config.get("wgPageName"); + const wgNamespaceNumber = mw.config.get("wgNamespaceNumber"); + + if (wgPageName.startsWith("萌娘百科_talk:讨论版/")) { $(".mw-editnotice + .mw-warning-with-logexcerpt").hide(); } - const sanity = $(document.createElement("span")); + const sanity = $(""); const sanityClean = (h) => { sanity.text(h); return sanity.html(); }; + // 快速填写编辑摘要 const wpSummary = $('[name="wpSummary"]'); // $(".mw-summary-preset-item a").closest('.oo-ui-fieldLayout-header').width($('#wpSummary').width()); $(".mw-summary-preset-item a").on("click", ({ target }) => { @@ -51,8 +55,7 @@ $(() => { return result; }; if (!$("ul.permissions-errors").find('a[href*="MoeAuth"]').length && !!$(".permissions-errors, #wpTextbox1[readonly]")[1] && mw.config.get("wgUserName") && !$(".newComment")[0]) { - const wgNamespaceNumber = mw.config.get("wgNamespaceNumber"), - ns = []; + const ns = []; if (wgNamespaceNumber < 0 || wgNamespaceNumber % 2 === 1) { return; } @@ -69,7 +72,6 @@ $(() => { if (!ns[0]) { return; } - const wgPageName = mw.config.get("wgPageName"); let page = mw.config.get("wgPageName"); const pageToLowerCase = page.toLowerCase(); for (const n of ns) { @@ -96,11 +98,14 @@ $(() => { scrollTop: explainconflict.closest(".infoBox").offset().top - 2, }, 137); } - + //只在ns0和ns2的子页面加载预加载工具 + if (![0, 2].includes(wgNamespaceNumber) || wgNamespaceNumber === 2 && !wgPageName.includes("/")) { + $("#multiboilerplateform").remove(); + } // 非维护组、技术组成员提出方针编辑请求时提醒需要走提案 if ( new URLSearchParams(location.search).get("preloadtitle").startsWith("编辑请求") && - mw.config.get("wgNamespaceNumber") === 5 && + wgNamespaceNumber === 5 && mw.config.get("wgAction") === "edit" && !mw.config.get("wgUserGroups").some((value) => ["patroller", "sysop", "techeditor", "interface-admin", "staff"].includes(value)) ) { diff --git a/src/gadgets/site-js/MediaWiki:Gadget-site-js.js b/src/gadgets/site-js/MediaWiki:Gadget-site-js.js index 46b61117..7a3961c8 100644 --- a/src/gadgets/site-js/MediaWiki:Gadget-site-js.js +++ b/src/gadgets/site-js/MediaWiki:Gadget-site-js.js @@ -571,10 +571,6 @@ passive: true, }); }); - //只在ns0和ns2的子页面加载预加载工具 - if (![0, 2].includes(mw.config.get("wgNamespaceNumber")) || mw.config.get("wgNamespaceNumber") === 2 && !mw.config.get("wgPageName").includes("/")) { - $("#multiboilerplateform").remove(); - } // 小工具使用统计移除默认启用的小工具 if (mw.config.get("wgCanonicalSpecialPageName") === "GadgetUsage") { gadgetUsageRemoveDefaultGadgets();