打开/关闭菜单
32
245
25
891
植物大战僵尸杂交版Wiki
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。
本Wiki为杂交版民间Wiki,不对杂交版官方产生影响

MediaWiki:Common.js:修订间差异

MediaWiki界面页面
无编辑摘要
Operator留言 | 贡献
无编辑摘要
 
(未显示2个用户的6个中间版本)
第1行: 第1行:
// 等待页面内容加载完成
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
mw.hook('wikipage.content').add(function() {
 
     // 如果已经添加过,则不再重复添加
// 自动加载 MediaWiki:Footer 页面内容,并插入到每个页面底部
     if (document.getElementById('global-footer-links')) {
 
$(document).ready(function() {
    const namespace = mw.config.get('wgNamespaceNumber');
    const action = mw.config.get('wgAction');
      
     if (namespace !== 0 || action !== 'view') {
         return;
         return;
     }
     }


     var footerHtml = '<div id="global-footer-links" style="width:100%; margin-top:20px; padding:15px 0; display:flex; justify-content:space-between; flex-wrap:wrap; gap:10px; border-top:1px solid #ccc;">' +
     fetch("/api.php?action=parse&page=MediaWiki:Footer&format=json")
        '<div><a href="https://new.pvzhe.wiki/index.php?title=特殊:创建账户&returnto=首页">加入我们</a></div>' +
         .then(res => res.json())
         '<div><a href="https://www.pvzhe.com/new">前往官网以了解更多游戏信息</a></div>' +
        .then(data => {
        '</div>';
            if (data.parse && data.parse.text) {
   
                const html = data.parse.text['*'];
    // 判断是否为移动端(Minerva 皮肤或窄屏)
                $('#mw-content-text').append('<div class="global-footer">' + html + '</div>');
    var isMobile = (mw.config.get('skin') === 'minerva') || window.innerWidth < 768;
            }
   
        });
    if (isMobile) {
        // 移动端:只尝试移动端容器
        var $mobileTarget = $('.mw-body, .content, main');
        if ($mobileTarget.length) {
            $mobileTarget.append(footerHtml);
        }
    } else {
        // PC 端:只尝试 PC 端容器
        var $pcTarget = $('#mw-content-text, .mw-body-content, #content, .mw-parser-output');
        if ($pcTarget.length) {
            $pcTarget.append(footerHtml);
        }
    }
});
});

2026年3月27日 (五) 11:25的最新版本

/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */

// 自动加载 MediaWiki:Footer 页面内容,并插入到每个页面底部

$(document).ready(function() {
    const namespace = mw.config.get('wgNamespaceNumber');
    const action = mw.config.get('wgAction');
    
    if (namespace !== 0 || action !== 'view') {
        return;
    }

    fetch("/api.php?action=parse&page=MediaWiki:Footer&format=json")
        .then(res => res.json())
        .then(data => {
            if (data.parse && data.parse.text) {
                const html = data.parse.text['*'];
                $('#mw-content-text').append('<div class="global-footer">' + html + '</div>');
            }
        });
});