打开/关闭菜单
60
73
29
1.1K
武外梗百科
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

MediaWiki:Common.js

MediaWiki界面页面
Zelda110留言 | 贡献2026年1月17日 (六) 16:40的版本

注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的更改的影响。

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
//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>
`);
document.head.insertAdjacentHTML('beforeend',`
<meta name="baidu-site-verification" content="codeva-38vNyP0io6" />
`);

mw.loader.using(['mediawiki.util', 'mediawiki.api']).then(function () {
    $(function () {
        var $el = $('#wiki-wordcount-number');
        if (!$el.length) return;

        new mw.Api().get({
            action: 'query',
            meta: 'siteinfo',
            siprop: 'statistics',
            format: 'json'
        }).done(function (data) {
            var total = (data.query.statistics['cirrussearch-article-words'] || 0);

            // 缓动函数(ease-out):前快后慢
            function easeOutQuad(t) {
                return t * (2 - t);
            }

            var duration = 2000; // 动画总时长
            var startTime = null;

            function animate(timestamp) {
                if (!startTime) startTime = timestamp;
                var time = timestamp - startTime;
                var progress = Math.min(time / duration, 1);
                var eased = easeOutQuad(progress);

                var currentVal = Math.floor(eased * total);
                $el.text(currentVal.toLocaleString());

                if (progress < 1) {
                    requestAnimationFrame(animate);
                }
            }

            requestAnimationFrame(animate);
        }).fail(function () {
            console.error('字数统计 API 请求失败');
        });
    });
});