MediaWiki:Common.js:修订间差异

HW
HW留言 | 贡献
HW
HW留言 | 贡献
 
(未显示同一用户的1个中间版本)
第8行: 第8行:
                     return;
                     return;
                 }
                 }
                if ( $link.closest( '#p-views' ).length || $link.closest( '#p-cactions' ).length || $link.closest( '#p-tb' ).length || $link.closest( '#right-navigation' ).length || $link.closest( '#p-personal' ).length ) {
                    return;
const excludeContainers = [
                }
'#p-views',
'#p-cactions',
'#p-tb',
'#right-navigation',
'#p-personal',
'.mw-portlet-personal'
];
// 检查是否匹配任意一个排除容器
const isExcluded = excludeContainers.some(selector => $link.closest(selector).length);
if (isExcluded) {
return;
}
 
                 var href = $link.attr( 'href' );
                 var href = $link.attr( 'href' );
                 if ( !href ) return;
                 if ( !href ) return;
第81行: 第93行:
     } );
     } );
} );
} );
//重定向
(function() {
    const url = new URL(window.location.href);
    const pathname = url.pathname;
    const searchParams = url.searchParams;
   
    const isIndexPhp = pathname === '/index.php';
    const hasOnlyTitleParam = searchParams.size === 1 && searchParams.has('title');
    const titleValue = searchParams.get('title') || '';
    const hasValidTitle = titleValue.trim() !== '';
    if (isIndexPhp && hasOnlyTitleParam && hasValidTitle) {
        const targetUrl = `/wiki/${encodeURIComponent(titleValue)}`;
        window.location.replace(targetUrl);
    }
})();