跳转到内容

MediaWiki:Common.js:修订间差异

来自简中Robloxian Wiki
无编辑摘要
标签:已被回退
无编辑摘要
标签:手工回退
第1行: 第1行:
// ========== RSCA 导航替换 ==========
$(function() {
$(function() {
     // ========== 猫娘计数器 ==========
     // 隐藏 Vector 默认元素
    var PAD = 6;
     var toHide = ['p-logo', 'p-navigation', 'p-search', 'p-personal', 'p-tb', 'p-lang',
    var container = document.getElementById('neko-page-counter');
                  'mw-panel', 'mw-head-base', 'mw-page-base', 'p-banner', 'siteNotice',
   
                  'footer', 'catlinks'];
    if (container) {
     toHide.forEach(function(id) {
        var total = 0;
         var el = document.getElementById(id);
        $.ajax({
         if (el) el.style.display = 'none';
            url: mw.util.wikiScript('api'),
            data: {
                action: 'query',
                meta: 'siteinfo',
                siprop: 'statistics',
                format: 'json'
            },
            dataType: 'json',
            async: false,
            success: function(data) {
                if (data.query && data.query.statistics && data.query.statistics.pages) {
                    total = data.query.statistics.pages;
                }
            }
        });
        if (!total) total = 0;
        var digits = String(total).padStart(PAD, '0').split('');
        container.innerHTML = '';
        container.style.cssText = 'display:flex;align-items:flex-end;justify-content:center;gap:0;padding:10px;background:#0f0f1a;border-radius:8px;border:1px solid #2a2a40;min-height:100px;';
        var parentW = container.parentElement ? container.parentElement.clientWidth : 600;
        var imgW = Math.max(28, Math.min(100, Math.floor((parentW - 20) / PAD)));
        var imgH = Math.round(imgW * 1.25);
        var imageUrls = {
            '0': 'https://wiki.meltfi.top/images/d/df/0.gif',
            '1': 'https://wiki.meltfi.top/images/b/b5/1.gif',
            '2': 'https://wiki.meltfi.top/images/2/27/2.gif',
            '3': 'https://wiki.meltfi.top/images/0/06/3.gif',
            '4': 'https://wiki.meltfi.top/images/8/8f/4.gif',
            '5': 'https://wiki.meltfi.top/images/6/6a/5.gif',
            '6': 'https://wiki.meltfi.top/images/b/bd/6.gif',
            '7': 'https://wiki.meltfi.top/images/e/e7/7.gif',
            '8': 'https://wiki.meltfi.top/images/4/40/8.gif',
            '9': 'https://wiki.meltfi.top/images/3/30/9.gif',
        };
        digits.forEach(function(d) {
            var img = document.createElement('img');
            img.src = imageUrls[d];
            img.alt = d;
            img.style.cssText = 'width:' + imgW + 'px;height:' + imgH + 'px;object-fit:contain;image-rendering:pixelated;display:block;';
            img.onerror = function() {
                var fb = document.createElement('div');
                fb.textContent = d;
                fb.style.cssText = 'width:' + imgW + 'px;height:' + imgH + 'px;display:flex;align-items:center;justify-content:center;background:#333;color:#ff9ecd;font-size:' + Math.max(12, Math.floor(imgW * 0.4)) + 'px;font-weight:bold;font-family:monospace;border-radius:3px;';
                if (img.parentNode) img.parentNode.replaceChild(fb, img);
            };
            container.appendChild(img);
        });
    }
 
    // ========== RSCA 顶栏:直接插入到 body 最顶部 ==========
   
    // 1. 隐藏所有 Vector 元素
     var hideSelectors = [
        '#mw-navigation', '#mw-navigation-head', '#mw-navigation-toggle',
        '#mw-head', '#mw-head-base', '#mw-page-base',
        '#mw-panel', '#p-logo', '#p-navigation', '#p-search', '#p-personal', '#p-tb', '#p-lang',
        '#p-banner', '#siteNotice', '#centralNotice', '#footer', '#footer-info', '#footer-places', '#footer-icons',
        '#catlinks', '.mw-editsection', '.mw-editsection-like', '.mw-indicators',
        '#contentSub', '#contentSub2', '#jump-to-nav', '.breadcrumb', '.subpages',
        '.toc', '.toctoggle', '.toctogglesearch', '#p-cactions', '.searchButton', '#mw-search-top-table',
        '.vector-menu', '.vector-menu-tabs', '.vector-menu-tabs-legacy', '.vector-menu-content',
        '.vector-menu-content-list', '.vector-menu-heading', '.vector-menu-heading-label',
        '.vector-user-links', '.vector-user-links-legacy', '.vector-user-menu',
        '.vector-user-menu-legacy', '.vector-user-menu-anon-editor',
        '.vector-search-box', '.vector-search-box-input', '.vector-search-box-button',
        '.firstHeading', '#firstHeading', '.mw-page-title', '.page-title'
    ];
      
    hideSelectors.forEach(function(sel) {
         var els = document.querySelectorAll(sel);
         els.forEach(function(el) { el.style.display = 'none'; });
     });
     });
      
      
     // 2. 隐藏所有 h1 标题(最后手段)
     // 隐藏 Vector 菜单
     document.querySelectorAll('h1').forEach(function(h) { h.style.display = 'none'; });
     var menus = document.querySelectorAll('.vector-menu, .vector-menu-tabs, .vector-menu-content, .vector-user-links, .vector-user-menu, .vector-search-box');
    menus.forEach(function(m) { m.style.display = 'none'; });
      
      
     // 3. 在 body 最前面插入 RSCA 顶栏
     // 替换导航栏
     var rscaBar = document.createElement('div');
     var nav = document.getElementById('mw-navigation');
     rscaBar.id = 'rsca-top-bar';
     if (nav) {
    rscaBar.style.cssText = 'width:100%;background:#1a1a1a;border-bottom:2px solid #c41e3a;padding:0;margin:0;position:relative;top:0;left:0;z-index:99999;';
        nav.innerHTML = '<div style="max-width:960px;margin:0 auto;padding:10px 20px;display:flex;align-items:center;justify-content:space-between;background:#1a1a1a;border-bottom:2px solid #c41e3a;">' +
   
             '<div style="display:flex;align-items:center;gap:12px;">' +
    rscaBar.innerHTML =  
                 '<span style="font-size:1.5em;font-weight:900;letter-spacing:0.15em;color:#ccc;text-transform:uppercase;">RSCA</span>' +
        '<div style="max-width:960px;margin:0 auto;padding:12px 20px;display:flex;align-items:center;justify-content:space-between;box-sizing:border-box;">' +
                 '<span style="font-size:0.75em;color:#888;letter-spacing:0.08em;">Roblox Simplified Chinese Archives</span>' +
             '<div style="display:flex;align-items:center;gap:14px;">' +
                 '<span style="font-size:1.6em;font-weight:900;letter-spacing:0.12em;color:#ccc;text-transform:uppercase;">RSCA</span>' +
                 '<span style="font-size:0.78em;color:#888;letter-spacing:0.06em;">Roblox Simplified Chinese Archives</span>' +
             '</div>' +
             '</div>' +
             '<div style="display:flex;gap:2px;">' +
             '<div style="display:flex;gap:2px;">' +
                 '<a href="/index.php/帮助:入门" style="padding:7px 16px;color:#b0b0b0;font-size:0.88em;letter-spacing:0.05em;border-radius:4px;transition:all 0.2s;">入门</a>' +
                 '<a href="/index.php/帮助:入门" style="padding:6px 14px;color:#b0b0b0;font-size:0.85em;letter-spacing:0.05em;border-radius:4px;" onmouseover="this.style.background=\'#333\';this.style.color=\'#fff\'" onmouseout="this.style.background=\'\';this.style.color=\'#b0b0b0\'">入门</a>' +
                 '<a href="/index.php/帮助:联系我们" style="padding:7px 16px;color:#b0b0b0;font-size:0.88em;letter-spacing:0.05em;border-radius:4px;transition:all 0.2s;">联系</a>' +
                 '<a href="/index.php/帮助:联系我们" style="padding:6px 14px;color:#b0b0b0;font-size:0.85em;letter-spacing:0.05em;border-radius:4px;" onmouseover="this.style.background=\'#333\';this.style.color=\'#fff\'" onmouseout="this.style.background=\'\';this.style.color=\'#b0b0b0\'">联系</a>' +
                 '<a href="/index.php/特殊:随机" style="padding:7px 16px;color:#b0b0b0;font-size:0.88em;letter-spacing:0.05em;border-radius:4px;transition:all 0.2s;">随机</a>' +
                 '<a href="/index.php/特殊:随机" style="padding:6px 14px;color:#b0b0b0;font-size:0.85em;letter-spacing:0.05em;border-radius:4px;" onmouseover="this.style.background=\'#333\';this.style.color=\'#fff\'" onmouseout="this.style.background=\'\';this.style.color=\'#b0b0b0\'">随机</a>' +
                 '<a href="/index.php/特殊:最近更改" style="padding:7px 16px;color:#b0b0b0;font-size:0.88em;letter-spacing:0.05em;border-radius:4px;transition:all 0.2s;">最近更改</a>' +
                 '<a href="/index.php/特殊:最近更改" style="padding:6px 14px;color:#b0b0b0;font-size:0.85em;letter-spacing:0.05em;border-radius:4px;" onmouseover="this.style.background=\'#333\';this.style.color=\'#fff\'" onmouseout="this.style.background=\'\';this.style.color=\'#b0b0b0\'">最近更改</a>' +
             '</div>' +
             '</div>' +
         '</div>';
         '</div>';
        nav.style.display = 'block';
        nav.style.background = '#1a1a1a';
        nav.style.borderBottom = '2px solid #c41e3a';
        nav.style.height = 'auto';
        nav.style.position = 'static';
    }
      
      
     document.body.insertBefore(rscaBar, document.body.firstChild);
     // 隐藏搜索框
    var search = document.getElementById('p-search');
    if (search) search.style.display = 'none';
      
      
     // 4. 确保顶栏之后的内容有顶部间距
     // 隐藏用户菜单
     document.body.style.paddingTop = '0';
     var personal = document.getElementById('p-personal');
     document.body.style.marginTop = '0';
     if (personal) personal.style.display = 'none';
      
      
     // 5. 移除可能遮挡顶栏的固定元素
     // 隐藏侧边栏
     var fixedEls = document.querySelectorAll('[style*="position: fixed"], [style*="position:fixed"]');
     var panel = document.getElementById('mw-panel');
     fixedEls.forEach(function(el) {
    if (panel) panel.style.display = 'none';
        if (el.id !== 'rsca-top-bar') {
      
            el.style.top = '60px';
    // 隐藏页脚
        }
    var footer = document.getElementById('footer');
    });
    if (footer) footer.style.display = 'none';
   
    // 隐藏 logo
    var logo = document.getElementById('p-logo');
    if (logo) logo.style.display = 'none';
});
});

2026年9月6日 (日) 10:02的版本

// ========== RSCA 导航替换 ==========

$(function() {
    // 隐藏 Vector 默认元素
    var toHide = ['p-logo', 'p-navigation', 'p-search', 'p-personal', 'p-tb', 'p-lang',
                   'mw-panel', 'mw-head-base', 'mw-page-base', 'p-banner', 'siteNotice',
                   'footer', 'catlinks'];
    toHide.forEach(function(id) {
        var el = document.getElementById(id);
        if (el) el.style.display = 'none';
    });
    
    // 隐藏 Vector 菜单
    var menus = document.querySelectorAll('.vector-menu, .vector-menu-tabs, .vector-menu-content, .vector-user-links, .vector-user-menu, .vector-search-box');
    menus.forEach(function(m) { m.style.display = 'none'; });
    
    // 替换导航栏
    var nav = document.getElementById('mw-navigation');
    if (nav) {
        nav.innerHTML = '<div style="max-width:960px;margin:0 auto;padding:10px 20px;display:flex;align-items:center;justify-content:space-between;background:#1a1a1a;border-bottom:2px solid #c41e3a;">' +
            '<div style="display:flex;align-items:center;gap:12px;">' +
                '<span style="font-size:1.5em;font-weight:900;letter-spacing:0.15em;color:#ccc;text-transform:uppercase;">RSCA</span>' +
                '<span style="font-size:0.75em;color:#888;letter-spacing:0.08em;">Roblox Simplified Chinese Archives</span>' +
            '</div>' +
            '<div style="display:flex;gap:2px;">' +
                '<a href="/index.php/帮助:入门" style="padding:6px 14px;color:#b0b0b0;font-size:0.85em;letter-spacing:0.05em;border-radius:4px;" onmouseover="this.style.background=\'#333\';this.style.color=\'#fff\'" onmouseout="this.style.background=\'\';this.style.color=\'#b0b0b0\'">入门</a>' +
                '<a href="/index.php/帮助:联系我们" style="padding:6px 14px;color:#b0b0b0;font-size:0.85em;letter-spacing:0.05em;border-radius:4px;" onmouseover="this.style.background=\'#333\';this.style.color=\'#fff\'" onmouseout="this.style.background=\'\';this.style.color=\'#b0b0b0\'">联系</a>' +
                '<a href="/index.php/特殊:随机" style="padding:6px 14px;color:#b0b0b0;font-size:0.85em;letter-spacing:0.05em;border-radius:4px;" onmouseover="this.style.background=\'#333\';this.style.color=\'#fff\'" onmouseout="this.style.background=\'\';this.style.color=\'#b0b0b0\'">随机</a>' +
                '<a href="/index.php/特殊:最近更改" style="padding:6px 14px;color:#b0b0b0;font-size:0.85em;letter-spacing:0.05em;border-radius:4px;" onmouseover="this.style.background=\'#333\';this.style.color=\'#fff\'" onmouseout="this.style.background=\'\';this.style.color=\'#b0b0b0\'">最近更改</a>' +
            '</div>' +
        '</div>';
        nav.style.display = 'block';
        nav.style.background = '#1a1a1a';
        nav.style.borderBottom = '2px solid #c41e3a';
        nav.style.height = 'auto';
        nav.style.position = 'static';
    }
    
    // 隐藏搜索框
    var search = document.getElementById('p-search');
    if (search) search.style.display = 'none';
    
    // 隐藏用户菜单
    var personal = document.getElementById('p-personal');
    if (personal) personal.style.display = 'none';
    
    // 隐藏侧边栏
    var panel = document.getElementById('mw-panel');
    if (panel) panel.style.display = 'none';
    
    // 隐藏页脚
    var footer = document.getElementById('footer');
    if (footer) footer.style.display = 'none';
    
    // 隐藏 logo
    var logo = document.getElementById('p-logo');
    if (logo) logo.style.display = 'none';
});