2023年政策修订增补工作正在进行中,欢迎参与!
User:AnnAngela/common.js
跳转到导航
跳转到搜索
注意:在保存之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。
- Firefox/Safari:按住“Shift”的同时单击“刷新”,或按“Ctrl-F5”或“Ctrl-R”(Mac为“⌘-R”)
- Google Chrome:按“Ctrl-Shift-R”(Mac为“⌘-Shift-R”)
- Internet Explorer:按住“Ctrl”的同时单击“刷新”,或按“Ctrl-F5”
- Opera:在“工具→首选项”中清除缓存
- 如果您已登录但该页面出现未登录状态,请尝试在地址栏的地址最后添加代码
?_=1
来访问最新页面。 - 添加代码后的本页地址如下:
-{R|https://moegirl.icu/User:AnnAngela/common.js?_=1}-
/* eslint-disable prefer-arrow-callback */
/* eslint-disable prefer-template */
/* eslint-disable comma-dangle */
/* eslint-disable no-var */
/* eslint dot-notation: ["error", { "allowPattern": "^(?:catch|default)$" } ] */
/* eslint-disable prefer-rest-params */
/* eslint-disable no-unused-vars */
/* eslint-disable no-redeclare */
/* global mw, $, OO, moment, Cron, prettyPrint, LocalObjectStorage, lazyload, wgULS */
/* eslint-enable no-unused-vars */
/* eslint-enable no-redeclare */
// <pre>
"use strict";
(function ($, mw) {
sessionStorage.setItem("WidgetDeceasedPersonGrayClass", "removeClass");
window.popupStructure = "menus";
window.LocalComments = $.extend(window.LocalComments || {}, {
twentyFourHours: true,
});
mw.config.set("AnnTools-Hitokoto-es2015", true);
var path = mw.config.get("wgServer") + mw.config.get("wgScriptPath");
mw.loader.load(path + "/index.php?title=User:AnnAngela/js/PersonalLabel.js&action=raw&ctype=text/javascript");
mw.loader.load(path + "/index.php?title=User:AnnAngela/js/navbox-link.js&action=raw&ctype=text/javascript");
mw.loader.load(path + "/index.php?title=User:AnnAngela/js/mwPanel.js&action=raw&ctype=text/javascript");
mw.loader.load(path + "/index.php?title=User:AnnAngela/js/watchlist-toggle.js&action=raw&ctype=text/javascript");
mw.loader.load(path + "/index.php?title=User:AnnAngela/js/watchlist-log.js&action=raw&ctype=text/javascript");
mw.loader.load(path + "/index.php?title=User:AnnAngela/js/nulleditInCategory.js&action=raw&ctype=text/javascript");
mw.loader.load(path + "/index.php?title=User:AnnAngela/js/userStatus.js&action=raw&ctype=text/javascript");
mw.loader.load(path + "/index.php?title=User:AnnAngela/js/floatPurgeButton.js&action=raw&ctype=text/javascript");
mw.loader.load(path + "/index.php?title=User:AnnAngela/js/watchScripts.js&action=raw&ctype=text/javascript");
var loop = setInterval(function () {
if (["edit", "submit"].includes(mw.config.get("wgAction"))) {
if (!$("#wikiEditor-section-advanced > div.group.group-insert").length) {
return;
}
clearInterval(loop);
$("#wikiEditor-section-advanced > div.group.group-insert").append($("<a/>").addClass("label").css({
cursor: "pointer",
"float": "right",
"margin-left": "8px",
"margin-right": "5px",
}).text("code").on("click", function () {
var textbox = $("#wpTextbox1"),
start = textbox[0].selectionStart,
text = textbox.val(),
string = prompt("要插入的内容");
if (string === null) {
return;
}
textbox.val(text.substring(0, start) + "<code>" + string + "</code>" + text.substring(start));
textbox[0].selectionStart = textbox[0].selectionEnd = start + 13 + string.length;
textbox.focus();
}));
$("#wikiEditor-section-advanced > div.group.group-insert").append($("<a/>").addClass("label").css({
cursor: "pointer",
"float": "right",
"margin-left": "8px",
"margin-right": "5px",
}).text("code & nowiki").on("click", function () {
// eslint-disable-next-line no-var
var textbox = $("#wpTextbox1"),
start = textbox[0].selectionStart,
text = textbox.val(),
string = prompt("要插入的内容");
if (string === null) {
return;
}
textbox.val(text.substring(0, start) + "<code><nowiki>" + string + "</nowiki></code>" + text.substring(start));
textbox[0].selectionStart = textbox[0].selectionEnd = start + 30 + string.length;
textbox.focus();
}));
}
}, 1e3);
$(function () {
mw.loader.using("mediawiki.util").then(function () {
var flag = false;
setTimeout(function loop(flag) {
if (!window.pg || !window.pg.fn || !window.pg.fn.purgePopups) {
return setTimeout(loop, 100, flag);
}
mw.hook("wikipage.content").fire($("#ca-history"));
}, 100, flag);
var mainpageContent = $("body.mainpage").find("#mw-content-text")[0],
settings = {
Wikiplus_Installed: "True",
x18: "1",
Wikiplus_Settings: JSON.stringify({
defaultSummary: "function(a){switch(mw.config.get('wgNamespaceNumber')){case 274:case 8:return' ';default:return ![-1,0].includes(a.sectionNumber)?'/* '+a.sectionName+' */ //QuickEdit':'//QuickEdit'}}",
}),
"AnnTools-Hitokoto-color": "blue",
"AnnTools-Hitokoto-timer": "13070",
"MathJax-Menu-Settings": JSON.stringify($.extend({}, (function () {
try {
return JSON.parse(localStorage.getItem("MathJax-Menu-Settings") || "{}");
} catch (_) {
return {};
}
})(), { renderer: "CHTML" })),
};
var i;
for (i in settings) {
localStorage.setItem(i, settings[i]);
}
sessionStorage.setItem("mgym", "1");
$("#pt-mycontris").before('<li id="pt-myWikiCode"><a href="/User:AnnAngela/WikiCode" title="代码备忘">代码备忘</a></li>');
if (mainpageContent && mw.util.getParamValue("noTable") !== "1") {
$(mainpageContent).prepend('<table class="wikitable" style="width:100%"><caption>首页栏目→模板</caption><tr><td style="width:24.5%">你好~欢迎来到萌娘百科!</td><td style="width:0.8%">→</td><td style="width:24.5%"><a href="/Template:%E9%A6%96%E9%A1%B5/%E4%B8%93%E9%A2%98" title="Template:首页/专题">首页/专题</a></td><td style="width:0.4%"> </td><td style="width:24.5%">音乐专区</td><td style="width:0.8%">→</td><td style="width:24.5%"><a href="/Template:%E9%A6%96%E9%A1%B5/%E5%A4%9A%E5%AA%92%E4%BD%93" title="Template:首页/多媒体">首页/多媒体</a></td></tr><tr><td>专题导航</td><td>→</td><td><a href="/Template:%E9%A6%96%E9%A1%B5/%E5%AF%BC%E8%88%AA" title="Template:首页/导航">首页/导航</a></td><td> </td><td>萌言萌语</td><td>→</td><td><a href="/Template:%E9%A6%96%E9%A1%B5/meme" title="Template:首页/meme">首页/meme</a></td></tr><tr><td>集合啦!萌百编友会</td><td>→</td><td><a href="/Template:%E9%A6%96%E9%A1%B5/游戏" title="Template:首页/游戏">首页/游戏</a></td><td> </td><td>填坑区!</td><td>→</td><td><a href="/Template:%E9%A6%96%E9%A1%B5/%E5%A1%AB%E5%9D%91" title="Template:首页/填坑">首页/填坑</a></td></tr><tr><td>虚拟UP主</td><td>→</td><td><a href="/Template:%E9%A6%96%E9%A1%B5/虚拟UP主" title="Template:首页/虚拟UP主">首页/虚拟UP主</a></td><td> </td><td>周边·其他</td><td>→</td><td><a href="/Template:%E9%A6%96%E9%A1%B5/%E5%91%A8%E8%BE%B9" title="Template:首页/周边">首页/周边</a></td></tr><tr><td>ACGN</td><td>→</td><td><a href="/Template:%E9%A6%96%E9%A1%B5/ACGN" title="Template:首页/ACGN">首页/ACGN</a></td><td> </td><td>萌娘网姊妹项目</td><td>→</td><td><a href="/Template:Moegirlsister" title="Template:Moegirlsister">Moegirlsister</a></td></tr></table>');
}
if ($("#mw-clearyourcache")[0] && !$("#commonCodePage")[0]) {
$("#mw-clearyourcache").after('<div id="commonCodePageBox"/>');
$("#commonCodePageBox").load(path + "/template:%E5%85%AC%E5%85%B1%E4%BB%A3%E7%A0%81%E9%A1%B5?action=render"); // &version=1 #commonCodePage
}
switch (mw.config.get("wgPageName")) {
case "Talk:讨论版":
$("#firstHeading").append('<span class="sysop-show" style="margin-left: 1rem; font-size: large; line-height: 1;"><a href="' + path + '/Template:讨论版页顶/旧版" target="_blank" title="模板:讨论版页顶/旧版" style="font-size:large;line-height: 1;">讨论版页顶/旧版</a></span>');
break;
case "Talk:提问求助区":
$("#firstHeading").append('<span class="sysop-show" style="margin-left: 1rem; font-size: large; line-height: 1;"><a href="' + path + '/Template:提问求助区页顶" target="_blank" title="模板:提问求助区页顶">提问求助区页顶</a></span>');
break;
case "Template:BilibiliVideo/bvid":
$("#firstHeading").text("模板:BilibiliVideo/bvid");
$("#mw-content-text").addClass("mw-parser-output").find(".mw-json .value").each(function (_, ele) {
var t = ele.innerText.replace(/^"|"$/g, "");
$("<a/>").attr({
href: "https://zh.moegirl.org.cn/" + encodeURI(t),
target: "_blank"
}).text(t).addClass("external").appendTo(ele).before("<br>");
});
}
if (mw.config.get("wgPageName").startsWith("萌娘百科_talk:讨论版/")) {
$("#firstHeading").append('<span class="sysop-show" style="margin-left: 1rem; font-size: large; line-height: 1;"><a href="' + path + '/Template:讨论版页顶" target="_blank" title="模板:讨论版页顶" style="font-size:large;line-height: 1;">讨论版页顶</a></span>');
}
$("body").removeClass("vector-animateLayout");
if (navigator.userAgent.toLowerCase().indexOf("mobile") > 0) {
$("body").addClass("isMobile");
}
if ($(".mw-special-Log")[0]) {
$("#mw-content-text > form > fieldset").append($("<p>", {
text: "点击显示/隐藏上传日志:",
attr: {
id: "uploadToggle",
},
})).find("#uploadToggle").append($("<input>", {
attr: {
type: "button",
},
on: {
click: function click() {
var li = $("li.mw-logline-upload");
if (li.is(":hidden")) {
li.show();
$(this).val("隐藏");
} else {
li.hide();
$(this).val("显示");
}
},
},
})).find("input").trigger("click");
}
$("a.extiw").removeClass("extiw");
if ($("#pagehistory .mw-history-line-updated")[0]) {
var start = $("#pagehistory .updatedmarker").first().closest(".mw-history-line-updated").find('input[name="diff"]'),
end = $("#pagehistory .updatedmarker").last().closest(".mw-history-line-updated").next().find('input[name="oldid"]');
if (start.is(":not(:checked)")) {
start.trigger("click");
}
if (end.is(":not(:checked)")) {
end.trigger("click");
}
end.trigger("click");
}
if (!document.querySelector("script#AnnTools_TalkToc")) {
var h = $("#mw-content-text > .mw-parser-output").children("h1, h2, h3, h4, h5, h6");
var maxHeight = -1;
h.each(function (_, e) {
maxHeight = Math.max(maxHeight, $(e).outerHeight());
});
h.each(function (i, e) {
var $e = $(e);
$e.css({
position: "sticky",
top: Math.max(0, maxHeight - $e.outerHeight()) + "px",
left: "0",
right: "0",
"background-color": "white",
"z-index": 9999 + i,
});
$e.find("[id]").each(function (_, a) {
var id = a.id;
a.id += "_floatHeading";
var anchor = $("<span>");
anchor.attr("id", id);
$e.before(anchor);
});
});
}
/* if (localStorage.getItem("statusLock") !== "true") {
localStorage.setItem("statusLock", "true");
$.get("https://zh.moegirl.org.cn/User:AnnAngela/Status?action=raw", function (status) {
if (status === "offline") {
mw.loader.using("mediawiki.api").then(function () {
new mw.Api().postWithToken("csrf", {
title: "User:AnnAngela/Status",
text: "online",
summary: "online",
tags: "Automation tool",
minor: true,
nocreate: true,
});
});
}
});
} */
});
});
})(jQuery, mediaWiki);
// </pre>