✨🎊 Postal Wiki 三周年! 🎊✨
🎂 2026.09.11 — 邮路三载,百科同行

用户:Hehua/common.js:修订间差异

来自Postal Wiki
无编辑摘要
标签已被回退
无编辑摘要
标签手工回退
第9行: 第9行:
);
);
// User:Hehua/common.js
// User:Hehua/common.js
// 这段代码只有你自己能看到
// 使用皮肤检测,确保只在Timeless皮肤运行
if (mw.config.get('skin') === 'timeless') {
if (mw.config.get('skin') === 'timeless') {
    console.log('Hehua的个人JS已加载,正在添加UTC时钟...');
      
      
     // 检查小工具系统状态
     // 等待所需模块
     function checkGadgetSystem() {
     mw.loader.using(['mediawiki.util', 'mediawiki.api', 'jquery']).then(function() {
        console.log('=== 小工具系统检查 ===');
          
          
         // 检查wgGadgets配置
         function addPersonalClock() {
        console.log('wgGadgets(客户端):', mw.config.get('wgGadgets'));
            // 避免重复添加
       
            if ($('#utcdate-hehua').length) return true;
        // 检查Special:Gadgets的API响应
           
        $.ajax({
            // 添加到个人工具栏
             url: mw.util.getUrl('Special:Gadgets', { format: 'json' }),
            var node = mw.util.addPortletLink(
            dataType: 'json'
                'p-personal',
        }).done(function(data) {
                mw.util.getUrl(mw.config.get('wgPageName'), {action: 'purge'}),
            console.log('Special:Gadgets API响应:', data);
                '加载中...',
                'utcdate-hehua',
                'UTC时间(个人版)- 点击刷新页面'
            );
           
            if (!node) {
                console.log('无法添加时钟到个人工具栏');
                return false;
            }
           
            // 样式
            $(node).find('a').css({
                'font-weight': 'bold',
                'font-size': '110%',
                'color': '#36c', // 蓝色,便于识别
                'border-left': '1px solid #ccc',
                'padding-left': '10px'
            });
              
            // 点击事件
            $(node).on('click', function(e) {
                e.preventDefault();
                new mw.Api().post({
                    action: 'purge',
                    titles: mw.config.get('wgPageName')
                }).then(function() {
                    location.reload();
                }, function() {
                    mw.notify('刷新失败', {type: 'error'});
                });
            });
              
              
             if (data && data.query && data.query.gadgets) {
             // 更新时间函数
                 console.log('服务器返回的小工具:', Object.keys(data.query.gadgets));
            function updateClock() {
                var now = new Date();
                var hh = now.getUTCHours().toString().padStart(2, '0');
                 var mm = now.getUTCMinutes().toString().padStart(2, '0');
                var ss = now.getUTCSeconds().toString().padStart(2, '0');
                $(node).find('a').text(hh + ':' + mm + ':' + ss + ' UTC');
               
                // 精确计时
                setTimeout(updateClock, 1000 - now.getUTCMilliseconds());
             }
             }
        }).fail(function() {
           
             console.log('无法获取Special:Gadgets数据');
            updateClock();
         });
             console.log('个人版UTC时钟添加成功');
            return true;
         }
          
          
         // 检查load.php请求
         // 尝试添加(Timeless可能延迟加载DOM)
         var rlRequests = [];
         var attempts = 0;
         $('script[src*="load.php"]').each(function() {
         var interval = setInterval(function() {
             var src = $(this).attr('src');
             if (addPersonalClock() || attempts >= 8) {
            if (src.includes('modules=ext.gadget')) {
                clearInterval(interval);
                rlRequests.push(src);
                if (attempts >= 8) {
                    console.log('添加个人时钟失败,尝试8次后放弃');
                }
             }
             }
         });
            attempts++;
         }, 500);
          
          
        console.log('包含ext.gadget的load.php请求:', rlRequests.length);
    }).catch(function(err) {
        rlRequests.forEach(function(req, i) {
        console.error('加载依赖模块失败:', err);
            console.log('请求 ' + i + ':', req);
     });
        });
     }
   
    // 页面加载后运行检查
    setTimeout(checkGadgetSystem, 2000);
};
};

2026年1月8日 (四) 11:50的版本

mw.loader.load('https://wikiplus-app.com/Main.js');
importScript('User:Hehua/hotcat.js');
// InPageEdit NEXT
document.body.append(
  Object.assign(document.createElement('script'), {
    src: 'https://gcore.jsdelivr.net/npm/@inpageedit/core/dist/index.js',
    type: 'module',
  })
);
// User:Hehua/common.js
// 这段代码只有你自己能看到

// 使用皮肤检测,确保只在Timeless皮肤运行
if (mw.config.get('skin') === 'timeless') {
    console.log('Hehua的个人JS已加载,正在添加UTC时钟...');
    
    // 等待所需模块
    mw.loader.using(['mediawiki.util', 'mediawiki.api', 'jquery']).then(function() {
        
        function addPersonalClock() {
            // 避免重复添加
            if ($('#utcdate-hehua').length) return true;
            
            // 添加到个人工具栏
            var node = mw.util.addPortletLink(
                'p-personal',
                mw.util.getUrl(mw.config.get('wgPageName'), {action: 'purge'}),
                '加载中...',
                'utcdate-hehua',
                'UTC时间(个人版)- 点击刷新页面'
            );
            
            if (!node) {
                console.log('无法添加时钟到个人工具栏');
                return false;
            }
            
            // 样式
            $(node).find('a').css({
                'font-weight': 'bold',
                'font-size': '110%',
                'color': '#36c', // 蓝色,便于识别
                'border-left': '1px solid #ccc',
                'padding-left': '10px'
            });
            
            // 点击事件
            $(node).on('click', function(e) {
                e.preventDefault();
                new mw.Api().post({
                    action: 'purge',
                    titles: mw.config.get('wgPageName')
                }).then(function() {
                    location.reload();
                }, function() {
                    mw.notify('刷新失败', {type: 'error'});
                });
            });
            
            // 更新时间函数
            function updateClock() {
                var now = new Date();
                var hh = now.getUTCHours().toString().padStart(2, '0');
                var mm = now.getUTCMinutes().toString().padStart(2, '0');
                var ss = now.getUTCSeconds().toString().padStart(2, '0');
                $(node).find('a').text(hh + ':' + mm + ':' + ss + ' UTC');
                
                // 精确计时
                setTimeout(updateClock, 1000 - now.getUTCMilliseconds());
            }
            
            updateClock();
            console.log('个人版UTC时钟添加成功');
            return true;
        }
        
        // 尝试添加(Timeless可能延迟加载DOM)
        var attempts = 0;
        var interval = setInterval(function() {
            if (addPersonalClock() || attempts >= 8) {
                clearInterval(interval);
                if (attempts >= 8) {
                    console.log('添加个人时钟失败,尝试8次后放弃');
                }
            }
            attempts++;
        }, 500);
        
    }).catch(function(err) {
        console.error('加载依赖模块失败:', err);
    });
};