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

MediaWiki:Common.js:修订间差异

MediaWiki界面页面
无编辑摘要
无编辑摘要
第1行: 第1行:
(function() {
(function() {
     if (window.__globalFooterAdded) return;
    // 防止重复执行的全局标志
     if (window.__globalFooterAdded) {
        return;
    }
      
      
    // 要插入的 HTML
     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>' +
第7行: 第11行:
         '</div>';
         '</div>';
      
      
    // 插入函数
     function insertFooter() {
     function insertFooter() {
         if (document.getElementById('global-footer-links')) return true;
         if (document.getElementById('global-footer-links')) {
       
        // 优先查找手机端页脚(Minerva 常见结构)
        var mobileFooter = document.querySelector('.mw-footer-container, .minerva-footer, footer');
        if (mobileFooter) {
            mobileFooter.insertAdjacentHTML('beforebegin', footerHtml);
            window.__globalFooterAdded = true;
             return true;
             return true;
         }
         }
          
          
         // 备选:PC 端页脚
         // 手机端常用容器(Minerva 皮肤)
         var pcFooter = document.querySelector('#footer, #mw-footer, .footer');
         var mobileSelectors = [
         if (pcFooter) {
            '.mw-body',          // Minerva 主内容区
            pcFooter.insertAdjacentHTML('beforebegin', footerHtml);
            '.content',          // 通用内容区
            window.__globalFooterAdded = true;
            'main',              // HTML5 主标签
            return true;
            '.mw-footer-container', // Minerva 页脚容器
            '.minerva-footer'    // Minerva 页脚
        ];
       
        // PC 端常用容器
        var pcSelectors = [
            '#footer',           // Vector 皮肤页脚
            '#mw-footer',         // 通用页脚
            'footer',            // HTML5 页脚
            '.footer'             // 通用页脚类
        ];
       
        // 先找页脚(PC 和手机)
        var allSelectors = mobileSelectors.concat(pcSelectors);
         for (var i = 0; i < allSelectors.length; i++) {
            var element = document.querySelector(allSelectors[i]);
            if (element) {
                // 如果是内容区(.mw-body 等),用 append;如果是页脚,用 before
                if (allSelectors[i] === '.mw-body' || allSelectors[i] === '.content' || allSelectors[i] === 'main') {
                    element.insertAdjacentHTML('beforeend', footerHtml);
                } else {
                    element.insertAdjacentHTML('beforebegin', footerHtml);
                }
                window.__globalFooterAdded = true;
                return true;
            }
         }
         }
          
          
         // 最后备选:内容区末尾
         // 最后的备选:找任何主要内容区
         var content = document.querySelector('#mw-content-text, .mw-body-content, #content, .mw-body');
         var lastResort = document.querySelector('#mw-content-text, .mw-body-content, #content');
         if (content) {
         if (lastResort) {
             content.insertAdjacentHTML('beforeend', footerHtml);
             lastResort.insertAdjacentHTML('beforeend', footerHtml);
             window.__globalFooterAdded = true;
             window.__globalFooterAdded = true;
             return true;
             return true;
第37行: 第61行:
     }
     }
      
      
     // 执行插入
     // 执行插入(兼容各种加载时机)
     if (document.readyState === 'loading') {
     function tryInsert() {
        document.addEventListener('DOMContentLoaded', function() {
        if (insertFooter()) return;
            setTimeout(insertFooter, 200);
       
        // 如果 DOM 还没准备好,等待
        if (document.readyState === 'loading') {
            document.addEventListener('DOMContentLoaded', function() {
                setTimeout(insertFooter, 300);
            });
        }
       
        // 监听 DOM 变化(应对动态加载内容)
        var observer = new MutationObserver(function() {
            if (insertFooter()) {
                observer.disconnect();
            }
         });
         });
    } else {
        observer.observe(document.body, { childList: true, subtree: true });
         setTimeout(insertFooter, 200);
         setTimeout(function() { observer.disconnect(); }, 10000);
     }
     }
      
      
     // 监听动态加载内容(如手机端的无限滚动)
     // 立即执行
     var observer = new MutationObserver(function() {
     tryInsert();
        if (!window.__globalFooterAdded) insertFooter();
    });
    observer.observe(document.body, { childList: true, subtree: true });
    setTimeout(function() { observer.disconnect(); }, 8000);
})();
})();

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

(function() {
    // 防止重复执行的全局标志
    if (window.__globalFooterAdded) {
        return;
    }
    
    // 要插入的 HTML
    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>';
    
    // 插入函数
    function insertFooter() {
        if (document.getElementById('global-footer-links')) {
            return true;
        }
        
        // 手机端常用容器(Minerva 皮肤)
        var mobileSelectors = [
            '.mw-body',           // Minerva 主内容区
            '.content',           // 通用内容区
            'main',               // HTML5 主标签
            '.mw-footer-container', // Minerva 页脚容器
            '.minerva-footer'     // Minerva 页脚
        ];
        
        // PC 端常用容器
        var pcSelectors = [
            '#footer',            // Vector 皮肤页脚
            '#mw-footer',         // 通用页脚
            'footer',             // HTML5 页脚
            '.footer'             // 通用页脚类
        ];
        
        // 先找页脚(PC 和手机)
        var allSelectors = mobileSelectors.concat(pcSelectors);
        for (var i = 0; i < allSelectors.length; i++) {
            var element = document.querySelector(allSelectors[i]);
            if (element) {
                // 如果是内容区(.mw-body 等),用 append;如果是页脚,用 before
                if (allSelectors[i] === '.mw-body' || allSelectors[i] === '.content' || allSelectors[i] === 'main') {
                    element.insertAdjacentHTML('beforeend', footerHtml);
                } else {
                    element.insertAdjacentHTML('beforebegin', footerHtml);
                }
                window.__globalFooterAdded = true;
                return true;
            }
        }
        
        // 最后的备选:找任何主要内容区
        var lastResort = document.querySelector('#mw-content-text, .mw-body-content, #content');
        if (lastResort) {
            lastResort.insertAdjacentHTML('beforeend', footerHtml);
            window.__globalFooterAdded = true;
            return true;
        }
        
        return false;
    }
    
    // 执行插入(兼容各种加载时机)
    function tryInsert() {
        if (insertFooter()) return;
        
        // 如果 DOM 还没准备好,等待
        if (document.readyState === 'loading') {
            document.addEventListener('DOMContentLoaded', function() {
                setTimeout(insertFooter, 300);
            });
        }
        
        // 监听 DOM 变化(应对动态加载内容)
        var observer = new MutationObserver(function() {
            if (insertFooter()) {
                observer.disconnect();
            }
        });
        observer.observe(document.body, { childList: true, subtree: true });
        setTimeout(function() { observer.disconnect(); }, 10000);
    }
    
    // 立即执行
    tryInsert();
})();