打开/关闭搜索
搜索
打开/关闭菜单
60
73
29
1.1K
武外梗百科
导航
首页
最近更改
随机页面
站务
其他
友链
特殊页面
打开/关闭外观设置菜单
通知
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。
user-interface-preferences
个人工具
讨论
贡献
创建账号
登录
查看“︁MediaWiki:Common.js”︁的源代码
MediaWiki界面页面
查看
阅读
查看源代码
查看历史
associated-pages
系统消息
讨论
更多操作
←
MediaWiki:Common.js
因为以下原因,您没有权限编辑该页面:
此页面为本wiki上的软件提供界面文本,并受到保护以防止滥用。 如欲修改所有wiki的翻译,请访问
translatewiki.net
上的MediaWiki本地化项目。
您无权编辑此JavaScript页面,因为编辑此页面可能会影响所有访问者。
您可以查看和复制此页面的源代码。
//Microsoft 和 Google 分析 document.head.insertAdjacentHTML('beforeend',` <!-- Google tag (gtag.js) --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-GVZPTSXG1H"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-GVZPTSXG1H'); </script> `); document.head.insertAdjacentHTML('beforeend',` <script type="text/javascript"> (function(c,l,a,r,i,t,y){ c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)}; t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i; y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y); })(window, document, "clarity", "script", "uewoetn0au"); </script> `); //页面摘要功能 function fillExcerpts() { document.querySelectorAll('.page-excerpt').forEach(div => { if (div.dataset.filled) return; // 避免重复填充 const title = div.dataset.title; const length = parseInt(div.dataset.length) || 200; // 调用 MediaWiki API 获取摘要 const url = '/api.php?action=query&prop=extracts&exchars=' + length + '&titles=' + encodeURIComponent(title) + '&format=json'; fetch(url) .then(resp => resp.json()) .then(data => { const pages = data.query.pages; let text = ''; for (let pageId in pages) { if (pages.hasOwnProperty(pageId)) { text = pages[pageId].extract || ''; break; } } // 保留链接,用 innerHTML div.innerHTML = text; div.dataset.filled = '1'; }) .catch(err => { console.error('Failed to fetch excerpt for', title, err); div.textContent = ''; }); }); } // MutationObserver 监控页面内容变化,兼容 SPA / 异步加载 const observer = new MutationObserver(() => fillExcerpts()); observer.observe(document.body, { childList: true, subtree: true }); // 页面首次加载执行一次 document.addEventListener('DOMContentLoaded', fillExcerpts);
返回
MediaWiki:Common.js
。
查看“︁MediaWiki:Common.js”︁的源代码
MediaWiki界面页面