User:Yining Chen/pl.js
外观
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
/*
Yining Chen注:该页面来自67584928
*/
$(function () {
const k = mw.config.get(["wgServerName", "wgPageName", "wgRevisionId", "wgCurRevisionId", "wgDiffNewId"]);
const siteInfoPattern = /^([^.]+)\.([^.]+).*$/;
let serverName, projectCode, languageCode, pageName, versionId, diffId;
serverName = k.wgServerName
.replace(/^([^.]+)\.wikimirror/, "$1.wikimedia") // Toaru mirror site
.replace(".wikimirror", "")
.replace(/\.org$/, "");
project = serverName.match(siteInfoPattern)[2];
language = serverName.match(siteInfoPattern)[1];
pageName = k.wgPageName.replace(/_/g, " ");
versionId = mw.util.getParamValue("oldid") || k.wgRevisionId || k.wgCurRevisionId;
diffId = k.wgDiffNewId;
const homewikiProjectCode = window.permanentlinkDefaultProject || "wikipedia";
const homewikiLanguageCode = window.permanentlinkDefaultLanguage || "zh";
let fixCode = function () {
let proj = "",
lang = "";
const projectCodeList = {
wikipedia: "w",
wiktionary: "wikt",
wikinews: "n",
wikibooks: "b",
wikiquote: "q",
wikisource: "s",
wikiversity: "v",
wikivoyage: "voy",
wikidata: "d",
};
const wikimediaProjectList = {
commons: "c",
meta: "m",
mediawiki: "mw",
test: "testwiki",
};
const specialSiteList = {
wikisource: "oldwikisource",
"beta.wikiversity": "betawikiversity",
};
if (typeof specialSiteList[serverName] != "undefined") {
proj = specialSiteList[serverName] === homewikiProjectCode ? ":" : specialSiteList[serverName];
} else if (project === "wikimedia") {
proj = typeof wikimediaProjectList[language] === "undefined" ? language : wikimediaProjectList[language];
proj = language === homewikiProjectCode ? ":" : proj;
} else {
proj = typeof projectCodeList[project] === "undefined" ? project : projectCodeList[project];
proj = project === homewikiProjectCode ? "" : proj;
lang = language === "www" ? "" : language;
lang = lang === homewikiLanguageCode ? "" : lang;
}
return `:${proj}:${lang}`;
};
let prefixCode = "",
pageLink = "",
peramaentLink = "",
innerOutputText = "";
prefixCode = fixCode();
pageLink = `<span style="user-select: all;">[[${prefixCode}:${pageName}]]</span>`;
if (diffId) {
peramaentLink = `[[${prefixCode}:Special:Diff/${versionId}/${diffId}]]`;
} else {
peramaentLink = `[[${prefixCode}:Special:PermanentLink/${versionId}]]`;
}
innerOutputText = pageLink + (versionId ? ` (<span style="user-select: all;">${peramaentLink}</span>)` : "");
innerOutputText = innerOutputText.replace(/:+/g, ":");
$("#contentSub").before(`<div id="citationMarkup" style="font-size: 84%; line-height: 20px;">${innerOutputText}</div>`);
});