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

MediaWiki:Common.js:修订间差异

MediaWiki界面页面
无编辑摘要
无编辑摘要
第1行: 第1行:
// 等待页面完全加载后再执行
// 确保只执行一次
$(function() {
if (window.globalFooterAdded) return;
    // 如果已经添加过,则不再重复添加
window.globalFooterAdded = true;
    if (document.getElementById('global-footer-links')) {
        return;
    }


// 延迟执行,确保 DOM 完全加载
setTimeout(function() {
    if (document.getElementById('global-footer-links')) 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;">' +
     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;">' +
         '<div><a href="https://new.pvzhe.wiki/index.php?title=特殊:创建账户&returnto=首页">加入我们</a></div>' +
         '<div><a href="https://new.pvzhe.wiki/index.php?title=特殊:创建账户&returnto=首页">加入我们</a></div>' +
第11行: 第12行:
         '</div>';
         '</div>';
      
      
     // 查找页脚元素(PC和手机端通用的选择器)
     // 查找所有可能的插入位置
     var $footer = $('#footer, #mw-footer, footer, .footer');
     var possibleTargets = [
        document.querySelector('#footer'),
        document.querySelector('#mw-footer'),
        document.querySelector('footer'),
        document.querySelector('.footer'),
        document.querySelector('#mw-content-text')?.parentNode,
        document.querySelector('.mw-body-content')?.parentNode
    ];
   
    // 找到第一个存在的元素
    var target = null;
    for (var i = 0; i < possibleTargets.length; i++) {
        if (possibleTargets[i]) {
            target = possibleTargets[i];
            break;
        }
    }
      
      
     if ($footer.length) {
     // 如果找到目标,在它之前插入
        // 在页脚之前插入
    if (target) {
        $footer.before(footerHtml);
         target.insertAdjacentHTML('beforebegin', footerHtml);
    } else {
         // 如果找不到页脚,才尝试追加到内容区末尾
        $('#mw-content-text, .mw-body-content, #content').append(footerHtml);
     }
     }
});
}, 500);

2026年3月22日 (日) 05:24的版本

// 确保只执行一次
if (window.globalFooterAdded) return;
window.globalFooterAdded = true;

// 延迟执行,确保 DOM 完全加载
setTimeout(function() {
    if (document.getElementById('global-footer-links')) 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;">' +
        '<div><a href="https://new.pvzhe.wiki/index.php?title=特殊:创建账户&returnto=首页">加入我们</a></div>' +
        '<div><a href="https://www.pvzhe.com/new">前往官网以了解更多游戏信息</a></div>' +
        '</div>';
    
    // 查找所有可能的插入位置
    var possibleTargets = [
        document.querySelector('#footer'),
        document.querySelector('#mw-footer'),
        document.querySelector('footer'),
        document.querySelector('.footer'),
        document.querySelector('#mw-content-text')?.parentNode,
        document.querySelector('.mw-body-content')?.parentNode
    ];
    
    // 找到第一个存在的元素
    var target = null;
    for (var i = 0; i < possibleTargets.length; i++) {
        if (possibleTargets[i]) {
            target = possibleTargets[i];
            break;
        }
    }
    
    // 如果找到目标,在它之前插入
    if (target) {
        target.insertAdjacentHTML('beforebegin', footerHtml);
    }
}, 500);