- 欢迎加入官方Discord和Telegram群组!
- 我们正在删除政治内容页面,还您一个干净的H萌娘,净化社区的同时也可以让您认真学习和讨论性知识(?
- 不知道接下来该看什么?可以去查阅本站的优质条目
- 如果您在H萌娘上发现某些内容错误/空缺,请勇于修正/添加!编辑H萌娘其实很容易!(由于遭到破坏,自动确认用户外的编辑现在会先审核 )
- 有任何意见、建议、求助都可以在 讨论版 提出!
MediaWiki:Common.js/edit.js
跳到导航
跳到搜索
注意:这类代码页面在保存之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。
- 按住
CTRL+SHIFT+DEL 或 ⌘-Shift-R
来清除缓存! - 或尝试在地址栏的地址最后添加代码
?_=1
来访问最新页面。 - 你还可以在设置中勾选小工具在页面右上角添加清除缓存按钮!
1. | 桌面版CSS | MediaWiki:Common.css |
2. | 桌面版JS | MediaWiki:Common.js |
3. | 移动端CSS | MediaWiki:Mobile.css |
4. | 移动端JS | MediaWiki:Mobile.js |
5. | 全局共用CSS | MediaWiki:Gadget-site-styles.css |
6. | 全局共用JS | MediaWiki:Gadget-site-javascript.js |
7. | 管理员CSS | MediaWiki:Group-sysop.css |
8. | 管理员JS | MediaWiki:Group-sysop.js |
9. | 编辑时载入 | MediaWiki:Common.js/edit.js |
引用api时用
mw.loader.using("mw.Api")
,引用uri时用mw.loader.using("mediawiki.Uri")
。/* Any JavaScript here will be loaded for all users on edit page load. */
// <pre>
$(function() {
if (mw.config.get("wgPageName").startsWith("H萌娘讨论:讨论版")) {
$(".mw-editnotice + .mw-warning-with-logexcerpt").hide();
}
var wpSummary = $('[name="wpSummary"]');
// $(".mw-summary-preset-item a").closest('.oo-ui-fieldLayout-header').width($('#wpSummary').width());
$(".mw-summary-preset-item a").on("click", function() {
wpSummary.val(wpSummary.val() + " " + $(this).text());
wpSummary.focus();
return false;
});
// .wikiEditor-ui-controls 颜色修正
$('.wikiEditor-ui-controls').css('background-color', $('#content').css('background-color'));
//编辑请求
var prefixNumber = function(num) {
var result = "" + num;
if (result.length === 1) {
result = "0" + result;
}
return result;
};
if (["edit", "submit"].indexOf(mw.config.get("wgAction")) !== -1 && !!$(".permissions-errors, #wpTextbox1[readonly]")[1] && mw.config.get("wgUserName") && !$(".newComment")[0]) {
var wgNamespaceIds = Object.entries(mw.config.get("wgNamespaceIds")),
wgNamespaceNumber = mw.config.get("wgNamespaceNumber"),
ns = [];
if (wgNamespaceNumber < 0 || wgNamespaceNumber % 2 === 1) {
return;
}
var talkNamespaceNumber = wgNamespaceNumber + 1;
var talkns = -1;
wgNamespaceIds.sort(function(_a, _b) {
var a = _a[0],
b = _b[0];
if (a === "") {
if (b === "") {
return 0;
}
return -1;
}
if (b === "") {
return 1;
}
return a[0].codePointAt() - b[0].codePointAt();
});
wgNamespaceIds.forEach(function(_ns) {
var i = _ns[0],
n = _ns[1];
if (n === wgNamespaceNumber) { ns.push(i); }
if (talkns === -1 && n === talkNamespaceNumber) { talkns = i; }
});
if (!ns[0]) { return; }
var page = mw.config.get("wgPageName");
var pageToLowerCase = page.toLowerCase();
for (var j = 0, l = ns.length; j < l; j++) {
if (pageToLowerCase.startsWith(ns[j])) {
page = page.replace(new RegExp("^" + ns[j] + ":", "i"), "");
break;
}
}
var talkpage = talkns + ":" + page;
var container = $("<div/>", {
"class": "editRequest",
});
var now = new Date();
container.append("您虽然无权编辑本页面,但您可以点击右侧按钮在本页的讨论页提出编辑请求,让可以编辑的人代为编辑:");
$("<span/>").addClass("newComment").text("提出编辑请求").on("click", function() {
window.open(mw.config.get("wgServer") + mw.config.get("wgScriptPath") + "/index.php?action=edit&preload=Template:编辑请求/comment&preloadtitle=编辑请求 - " + encodeURIComponent(mw.config.get("wgUserName") + " - " + now.getFullYear() + "." + prefixNumber(now.getMonth() + 1) + "." + prefixNumber(now.getDate())) + "§ion=new&title=" + encodeURIComponent(talkpage), "_blank");
}).appendTo(container);
$("#mw-content-text").children(".wikiEditor-ui:first, textarea[readonly]:first").before("<hr>").before(container);
}
const explainconflict = $("#mw-content-text > .mw-explainconflict #explainconflict-info");
if (explainconflict[0]) {
$("html, body").animate({
scrollTop: explainconflict.closest(".infoBox").offset().top - 2,
}, 137);
}
});
// </pre>