MediaWiki:Common.js:修订间差异
MediaWiki界面页面
更多操作
创建页面,内容为“→这里的任何JavaScript将为所有用户在每次页面加载时加载。: →===== 江中缘搜索摘要清理:开始 =====: →仅处理 Special:Search 的摘要展示;不修改页面原文、索引或搜索顺序。: (function () { 'use strict'; function cleanSource(source) { var text = source .replace(/<(script|style|template|noscript)\b[^>]*>[\s\S]*?<\/\1\s*>/gi, ' ') .replace(/<(?:script|style|template|noscript)\b[^>]*>…” |
无编辑摘要 |
||
| 第1行: | 第1行: | ||
/* ===== 江中缘搜索摘要清理:开始 ===== */ | /* ===== 江中缘搜索摘要清理:开始 ===== */ | ||
/* 仅处理 Special:Search 的摘要展示;不修改页面原文、索引或搜索顺序。 */ | /* 仅处理 Special:Search 的摘要展示;不修改页面原文、索引或搜索顺序。 */ | ||
| 第63行: | 第62行: | ||
})(); | })(); | ||
/* ===== 江中缘搜索摘要清理:结束 ===== */ | /* ===== 江中缘搜索摘要清理:结束 ===== */ | ||
/* ===== 搜索结果页官方页脚:开始 ===== */ | |||
/* 复用首页已确认的品牌、社区入口及版权文案;仅在 Special:Search 初始化。 */ | |||
(function () { | |||
function initSearchFooter() { | |||
if (!document.body.classList.contains('mw-special-Search')) return; | |||
var footer = document.querySelector('footer.citizen-footer, #citizen-footer, .mw-footer, #footer'); | |||
if (!footer || document.getElementById('jzy-official-footer')) return; | |||
var gameRulesUrl = "/index.php?title=%E6%B8%B8%E6%88%8F%E8%A7%84%E5%88%99"; | |||
var contactUrl = "https://qm.qq.com/q/560dSf2pxe"; | |||
var layout = document.createElement("section"); | |||
layout.id = "jzy-official-footer"; | |||
layout.setAttribute("aria-label", "江中缘网站页脚"); | |||
layout.innerHTML = | |||
'<div class="jzy-official-footer-top">' + | |||
'<a class="jzy-official-footer-brand" href="https://www.mcjzy.net/" target="_blank" rel="noopener" aria-label="访问江中缘官网">' + | |||
'<img src="https://wiki.mcjzy.net/images/1/10/3.png" alt="江中缘">' + | |||
'</a>' + | |||
'<div class="jzy-official-footer-socials" aria-label="江中缘社区平台">' + | |||
'<span class="jzy-footer-social" title="抖音"><img src="https://wiki.mcjzy.net/images/thumb/0/01/%E6%8A%96%E9%9F%B3.png/120px-%E6%8A%96%E9%9F%B3.png?20260720050242" alt="抖音"></span>' + | |||
'<a class="jzy-footer-social" href="https://space.bilibili.com/102775924?spm_id_from=333.1007.0.0" target="_blank" rel="noopener" title="哔哩哔哩"><img src="https://wiki.mcjzy.net/images/thumb/6/66/B%E7%AB%99.png/120px-B%E7%AB%99.png?20260720050109" alt="哔哩哔哩"></a>' + | |||
'<a class="jzy-footer-social" href="https://kook.vip/3mszpv" target="_blank" rel="noopener" title="KOOK"><img src="https://wiki.mcjzy.net/images/thumb/8/83/KOOK.png/120px-KOOK.png?20260720050143" alt="KOOK"></a>' + | |||
'<a class="jzy-footer-social" href="https://qm.qq.com/q/560dSf2pxe" target="_blank" rel="noopener" title="QQ 群"><img src="https://wiki.mcjzy.net/images/thumb/8/8c/QQ.png/120px-QQ.png?20260720050211" alt="QQ 群"></a>' + | |||
'</div>' + | |||
'</div>' + | |||
'<div class="jzy-official-footer-rule"></div>' + | |||
'<div class="jzy-official-footer-bottom">' + | |||
'<p class="jzy-official-footer-copy">江中缘满载无限可能,随心定义你的线上欢乐时光。<br><strong>江中缘 Wiki</strong> 由社区维护,记录服务器的玩法、系统与资料。<br>本站内容基于《江中缘》相关的《我的世界》游戏内容整理;本 Wiki 与 Mojang Studios、Microsoft、网易无隶属关系。<br>© 2026 江中缘。版权所有。</p>' + | |||
'<nav class="jzy-official-footer-links" aria-label="页脚链接">' + | |||
'<a href="' + gameRulesUrl + '">游戏规则</a>' + | |||
'<a href="/index.php?title=%E9%A6%96%E9%A1%B5">关于本站</a>' + | |||
'<a href="' + contactUrl + '" target="_blank" rel="noopener">联系我们</a>' + | |||
'</nav>' + | |||
'</div>'; | |||
footer.insertBefore(layout, footer.firstChild); | |||
footer.classList.add("jzy-footer-ready"); | |||
} | |||
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', initSearchFooter); | |||
else initSearchFooter(); | |||
if (window.mw && mw.hook) mw.hook('wikipage.content').add(initSearchFooter); | |||
})(); | |||
/* ===== 搜索结果页官方页脚:结束 ===== */ | |||
2026年10月19日 (一) 06:23的最新版本
/* ===== 江中缘搜索摘要清理:开始 ===== */
/* 仅处理 Special:Search 的摘要展示;不修改页面原文、索引或搜索顺序。 */
(function () {
'use strict';
function cleanSource(source) {
var text = source
.replace(/<(script|style|template|noscript)\b[^>]*>[\s\S]*?<\/\1\s*>/gi, ' ')
.replace(/<(?:script|style|template|noscript)\b[^>]*>[\s\S]*$/gi, ' ')
.replace(/<!--[\s\S]*?(?:-->|$)/g, ' ')
.replace(/\/\*[\s\S]*?\*\//g, ' ')
.replace(/<[^>]*>/g, ' ')
.replace(/<[^>]*$/g, ' ')
.replace(/^[.\s…]*(?:[a-zA-Z][\w:-]*|[="'\s])+>/, '… ')
.replace(/\b(?:class|id|href|style|title|data-[\w-]+)\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, ' ')
.replace(/(?:^|[.…]\s*)[>]+/g, '… ')
.replace(/\[\[(?:File|Image|文件|图像):[^\]]*\]\]/gi, ' ')
.replace(/\[\[([^\]|]+)\|([^\]]+)\]\]/g, '$2')
.replace(/\[\[([^\]]+)\]\]/g, '$1')
.replace(/'{2,5}/g, '')
.replace(/[|]/g, ' ')
.replace(/&(?:nbsp|amp|quot|apos|lt|gt);/g, function (entity) {
return { ' ':' ', '&':'&', '"':'"', ''':"'", '<':'<', '>':'>' }[entity];
})
.replace(/\s+/g, ' ').replace(/(?:…\s*){2,}/g, '… ').trim();
/* 只有可靠的正文才显示;无法还原的脚本、样式或数据片段留空。 */
if (/[<>]|(?:jzy[-:]|data:image|https?:\/\/)|(?:\b(?:function|document|window|const|var)\b)|[{}]|=>/i.test(text)) return '';
return text;
}
function highlight(node, text, terms) {
var lower = text.toLocaleLowerCase(), start = 0;
node.replaceChildren();
while (start < text.length) {
var at = -1, term = '';
terms.forEach(function (word) {
var found = lower.indexOf(word.toLocaleLowerCase(), start);
if (found >= 0 && (at < 0 || found < at || (found === at && word.length > term.length))) { at = found; term = word; }
});
if (at < 0) { node.appendChild(document.createTextNode(text.slice(start))); break; }
node.appendChild(document.createTextNode(text.slice(start, at)));
var mark = document.createElement('span');
mark.className = 'searchmatch';
mark.textContent = text.slice(at, at + term.length);
node.appendChild(mark);
start = at + term.length;
}
}
function cleanResults(root) {
if (!document.body.classList.contains('mw-special-Search')) return;
var scope = root && root.querySelectorAll ? root : document;
scope.querySelectorAll('.mw-search-results .searchresult').forEach(function (snippet) {
if (snippet.dataset.jzyCleaned) return;
snippet.dataset.jzyCleaned = 'true';
var terms = Array.from(new Set(Array.from(snippet.querySelectorAll('.searchmatch')).map(function (mark) { return mark.textContent.trim(); }).filter(function (term) { return term && term.length <= 80 && !/[<>]/.test(term); })));
var text = cleanSource(snippet.textContent);
highlight(snippet, text, terms);
snippet.hidden = !text;
});
}
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', function () { cleanResults(document); });
else cleanResults(document);
if (window.mw && mw.hook) mw.hook('wikipage.content').add(function (content) { cleanResults(content && content[0]); });
})();
/* ===== 江中缘搜索摘要清理:结束 ===== */
/* ===== 搜索结果页官方页脚:开始 ===== */
/* 复用首页已确认的品牌、社区入口及版权文案;仅在 Special:Search 初始化。 */
(function () {
function initSearchFooter() {
if (!document.body.classList.contains('mw-special-Search')) return;
var footer = document.querySelector('footer.citizen-footer, #citizen-footer, .mw-footer, #footer');
if (!footer || document.getElementById('jzy-official-footer')) return;
var gameRulesUrl = "/index.php?title=%E6%B8%B8%E6%88%8F%E8%A7%84%E5%88%99";
var contactUrl = "https://qm.qq.com/q/560dSf2pxe";
var layout = document.createElement("section");
layout.id = "jzy-official-footer";
layout.setAttribute("aria-label", "江中缘网站页脚");
layout.innerHTML =
'<div class="jzy-official-footer-top">' +
'<a class="jzy-official-footer-brand" href="https://www.mcjzy.net/" target="_blank" rel="noopener" aria-label="访问江中缘官网">' +
'<img src="https://wiki.mcjzy.net/images/1/10/3.png" alt="江中缘">' +
'</a>' +
'<div class="jzy-official-footer-socials" aria-label="江中缘社区平台">' +
'<span class="jzy-footer-social" title="抖音"><img src="https://wiki.mcjzy.net/images/thumb/0/01/%E6%8A%96%E9%9F%B3.png/120px-%E6%8A%96%E9%9F%B3.png?20260720050242" alt="抖音"></span>' +
'<a class="jzy-footer-social" href="https://space.bilibili.com/102775924?spm_id_from=333.1007.0.0" target="_blank" rel="noopener" title="哔哩哔哩"><img src="https://wiki.mcjzy.net/images/thumb/6/66/B%E7%AB%99.png/120px-B%E7%AB%99.png?20260720050109" alt="哔哩哔哩"></a>' +
'<a class="jzy-footer-social" href="https://kook.vip/3mszpv" target="_blank" rel="noopener" title="KOOK"><img src="https://wiki.mcjzy.net/images/thumb/8/83/KOOK.png/120px-KOOK.png?20260720050143" alt="KOOK"></a>' +
'<a class="jzy-footer-social" href="https://qm.qq.com/q/560dSf2pxe" target="_blank" rel="noopener" title="QQ 群"><img src="https://wiki.mcjzy.net/images/thumb/8/8c/QQ.png/120px-QQ.png?20260720050211" alt="QQ 群"></a>' +
'</div>' +
'</div>' +
'<div class="jzy-official-footer-rule"></div>' +
'<div class="jzy-official-footer-bottom">' +
'<p class="jzy-official-footer-copy">江中缘满载无限可能,随心定义你的线上欢乐时光。<br><strong>江中缘 Wiki</strong> 由社区维护,记录服务器的玩法、系统与资料。<br>本站内容基于《江中缘》相关的《我的世界》游戏内容整理;本 Wiki 与 Mojang Studios、Microsoft、网易无隶属关系。<br>© 2026 江中缘。版权所有。</p>' +
'<nav class="jzy-official-footer-links" aria-label="页脚链接">' +
'<a href="' + gameRulesUrl + '">游戏规则</a>' +
'<a href="/index.php?title=%E9%A6%96%E9%A1%B5">关于本站</a>' +
'<a href="' + contactUrl + '" target="_blank" rel="noopener">联系我们</a>' +
'</nav>' +
'</div>';
footer.insertBefore(layout, footer.firstChild);
footer.classList.add("jzy-footer-ready");
}
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', initSearchFooter);
else initSearchFooter();
if (window.mw && mw.hook) mw.hook('wikipage.content').add(initSearchFooter);
})();
/* ===== 搜索结果页官方页脚:结束 ===== */