跳转到内容

MediaWiki:Common.js

来自槌基百科
LocalAdmin留言 | 贡献2026年3月12日 (四) 11:26的版本 (Add JS to hide 首页 from AllPages list)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的更改的影响。

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
/* Common.js — site-wide JavaScript */

/* Hide the main page (首页) entry from the AllPages list on the homepage */
$( function () {
    var allpages = document.querySelector( '.mw-allpages-chunk' );
    if ( !allpages ) { return; }
    allpages.querySelectorAll( 'li' ).forEach( function ( li ) {
        var a = li.querySelector( 'a' );
        if ( a && ( a.title === '首页' || a.title === 'Main Page' ) ) {
            li.remove();
        }
    } );
} );