MediaWiki:Common.js
外观
注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的更改的影响。
- Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5或Ctrl-R(Mac为⌘-R)
- Google Chrome:按Ctrl-Shift-R(Mac为⌘-Shift-R)
- Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5。
/**
* -------------------------------------------------------------------------
* !!! DON'T MODIFY THIS PAGE MANUALLY, YOUR CHANGES WILL BE OVERWRITTEN !!!
* -------------------------------------------------------------------------
*/
var _addText = '{{GHIACode|page=GHIA:MoegirlPediaInterfaceCodes/blob/master/src/global/commons/Common.js|user=[[U:AnnAngela]]|co-authors=|longId=c61967347a25491d4253b6b176b667233dcd7900|shortId=c6196734|summary=refactor: use arrow functions for consistency in various gadgets}}';
/* <pre> */
"use strict";(async()=>{const e=[-1,-2,6,14,8,10,12,828].includes(mw.config.get("wgNamespaceNumber")),t=["sysop","patroller","staff"],i=mw.config.get("wgUserGroups").filter(e=>t.includes(e)).length>0,{body:o}=document,a=document.documentElement,m=$(o),n=$(window);n.on("resize",()=>{const{innerWidth:e}=window;let t;switch("scroll"){case getComputedStyle(o).overflowY:t=e-o.clientWidth;break;case getComputedStyle(a).overflowY:t=e-a.clientWidth;break;default:{const i=o.style.overflowY;o.style.overflowY="scroll",t=e-o.clientWidth,o.style.overflowY=i}}m[0===t?"addClass":"removeClass"]("overlay-scrollbars")}).trigger("resize"),jQuery.extend({ucFirst:e=>`${`${e}`.charAt(0).toUpperCase()}${`${e}`.substring(1)}`});const editSet=async()=>{await mw.loader.using(["mediawiki.util"]),/\.(?:js|css)$/.test(mw.util.getParamValue("title")||location.pathname)||([2,3].includes(mw.config.get("wgNamespaceNumber"))&&"edit"===mw.config.get("wgAction")&&0===mw.config.get("wgArticleId")?location.host=location.host.replace("commons.moegirl","zh.moegirl"):0!==mw.config.get("wgArticleId")||e||i||($('a[href*="veaction=edit"]').remove(),$('[class*="ve-init"]').length>0&&(n.off(),location.replace(`/${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>本站仅供上传图片用,请勿在本站创建页面,如有需要请到<a target="_blank" rel="nofollow noreferrer noopener" class="external text" href="${mw.config.get("wgServer").replace("commons.moegirl","zh.moegirl")}${mw.config.get("wgScriptPath")}">主站</a>。</p>`),$('#editform, [name="editform"]').each((e,t)=>{$(t).removeAttr("action"),t.addEventListener("submit",e=>{e.preventDefault()},{capture:!0})})))},mwSaveDialogSummary=()=>{let e=!1;mw.hook("ve.saveDialog.stateChanged").add(()=>{e||($("div.ve-ui-mwSaveDialog-summaryLabel span.mw-summary-preset-item > a").removeAttr("target").on("click",function(e){e.preventDefault();const t=$("div.ve-ui-mwSaveDialog-summary > textarea");t.val(`${t.val()} ${$(this).text()}`.trim()),t.on("focus")}),e=!0)}),mw.hook("ve.activationComplete").add(()=>{e=!1})};await $.ready,editSet(),`${new mw.Uri(document.referrer)}`.startsWith(`${mw.config.get("wgServer").replace("commons.moegirl","zh.moegirl")}${mw.config.get("wgScriptPath")}/`)&&$("#back").removeAttr("style").on("click",()=>{history.length>1?history.go(-1):location.href=document.referrer}),$(".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",()=>{window.open(mw.config.get("wgServer").replace("commons.moegirl","zh.moegirl")+mw.config.get("wgScriptPath")+location.pathname+location.search,"_blank")})),(async()=>{if(6===mw.config.get("wgNamespaceNumber")&&(mw.config.get("wgArticleId")||-1)>0&&"view"===mw.config.get("wgAction")&&(mw.config.get("wgRevisionId")||-1)===(mw.config.get("wgCurRevisionId")||-2)&&!document.querySelector(".license-info")){if(document.querySelector(".common-box")&&mw.config.get("wgUserId",-1)>0)return await mw.loader.using("mediawiki.api"),(new mw.Api).post({action:"purge",pageids:mw.config.get("wgArticleId",-1)});const e=document.querySelector("#ca-edit a"),t=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;">由于上传者未填写授权协议</span>,本作品默认仅以介绍为目的在此百科中以非盈利性方式合理使用。</div>${t||e?`<div>您知道该文件的作者是如何授权的吗?如果您知道的话欢迎<span style="font-weight: bold;">${e?`<a href="${e.href}">编辑该页面</a>`:`<a href="${mw.config.get("wgServer")}${mw.config.get("wgScriptPath")}/index.php?title=Special:%E7%94%A8%E6%88%B7%E7%99%BB%E5%BD%95&returntoquery=action%3Dedit&returnto=${encodeURIComponent(mw.config.get("wgPageName"))}">登录后编辑该页面</a>`}</span>填写授权协议~~</div>`:""}</td></tr></tbody></table>`)}})(),$("#mw-content-text a").each(function(){try{const e=new mw.Uri(this.href);if(e.toString().startsWith(`${mw.config.get("wgServer")+mw.config.get("wgScriptPath")}/`))return;if(/^\/api\.php/i.test(e.path))return;if(!e.query.title&&/\.php$/i.test(e.path))return;if(e.query&&(e.query.action||e.query.diff))return;const t=((e.query.title||decodeURI(e.path.substring(1))).match(/^user(?:[ _]talk)?:[^/]+/i)||[null])[0];t&&$(this).after(`<sub>[<a target="_blank" title="主站上的用户 ${t.replace(/user(_talk)?:/i,"")}" href="${mw.config.get("wgServer").replace("commons.moegirl","zh.moegirl")}${mw.config.get("wgScriptPath")}/${t}">主</a>]</sub>`)}catch(e){return}}),(()=>{if("Upload"===mw.config.get("wgCanonicalSpecialPageName")){const e=$("#wpLicense");e.val("Copyright").trigger("change"),$("#mw-upload-form").on("submit",()=>{"Authorized"===e.val()&&localStorage.setItem(`AnnTools-license-authorized-${encodeURIComponent(`File:${$("#wpDestFile").val().replace(/ /g,"_")}`)}`,"true")})}else if("edit"===mw.config.get("wgAction")&&"1"===mw.util.getParamValue("authorized")){const e=$("#wpTextbox1");e.val(e.val().replace("{{Authorized}}","{{Authorized\n|作者名=\x3c!--适用于作者授权百科长期使用其作品的情形,此时直接填入作者名即可--\x3e\n|授权证明=\x3c!--适用于作者仅授权单张图片的情形,可以在此填写授权证明的文件链接、或是相关请求授权的讨论链接等--\x3e\n}}")),setTimeout(()=>{alert("请在编辑框内填入相关授权信息!")},0)}else{const e=encodeURIComponent((mw.config.get("wgPageName")||"").replace(/ /g,"_"));"true"===localStorage.getItem(`AnnTools-license-authorized-${e}`)&&(localStorage.removeItem(`AnnTools-license-authorized-${e}`),location.replace(`${mw.config.get("wgServer")+mw.config.get("wgScriptPath")}/index.php?title=${e}&action=edit&authorized=1`))}})(),!i&&$(".will2Be2Deleted")[0]&&$("#ca-move").remove(),["edit","submit"].includes(mw.config.get("wgAction"))?(mwSaveDialogSummary(),$('[for="wpSummary"] .mw-summary-preset-item a').on("click",function(){const e=$('[name="wpSummary"]');return e.val(`${e.val()} ${$(this).text()}`.trim()),e.on("focus"),!1})):"view"===mw.config.get("wgAction")&&mw.hook("ve.activationComplete").add(()=>{mwSaveDialogSummary()}),n.on("load",()=>{editSet()})})();
/* </pre> */