跳到正文
Novark

MediaWiki:Citizen.js

Phase1EmergencyAdmin​(留言 | 贡献)2026年11月3日 (二) 14:08的版本 (启用星轨档案皮肤:清理重复主题注入与模板覆盖,按皮肤隔离保留资源)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

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

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5或Ctrl-R(Mac为⌘-R)
  • Google Chrome:按Ctrl-Shift-R(Mac为⌘-Shift-R)
  • Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5。
/* Accessible names for Citizen collapse buttons whose labels live in hidden icons. */
( function () {
	'use strict';
	function label() {
		document.querySelectorAll( '#citizen-toc .citizen-toc-toggle' ).forEach( function ( b ) {
			if ( b.getAttribute( 'aria-label' ) ) { return; }
			var t = ( b.textContent || '' ).replace( /\s+/g, ' ' ).trim();
			if ( t ) { b.setAttribute( 'aria-label', t ); }
		} );
		document.querySelectorAll( '.citizen-section-toggle' ).forEach( function ( b ) {
			if ( b.getAttribute( 'aria-label' ) ) { return; }
			var h = b.closest( '.citizen-section-heading' );
			if ( !h ) { return; }
			var clone = h.cloneNode( true );
			clone.querySelectorAll( 'button, .citizen-section-toggle, .mw-editsection' ).forEach( function ( x ) { x.remove(); } );
			var title = ( clone.textContent || '' ).replace( /\s+/g, ' ' ).trim();
			if ( title ) { b.setAttribute( 'aria-label', '折叠或展开「' + title + '」章节' ); }
		} );
	}
	function boot() { label(); setTimeout( label, 350 ); }
	if ( document.readyState === 'loading' ) { document.addEventListener( 'DOMContentLoaded', boot ); }
	else { boot(); }
} )();