LLWiki正在建设中,欢迎加入我们!
MediaWiki:Gadget-toc-custom.js
跳转到导航
跳转到搜索
注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的更改的影响。
- Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5或Ctrl-R(Mac为⌘-R)
- Google Chrome:按Ctrl-Shift-R(Mac为⌘-Shift-R)
- Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5。
//<nowiki> // 由ResourceLoader直接调用,不可使用ES6语法 // 引自[https://fgo.wiki/w/MediaWiki:Common.js] "use strict"; /*global wgUCS*/ mw.hook( 'wikipage.content' ).add(function($content) { if ($content.find( '#toc' ).length === 0) { return; } console.log('Hook: wikipage.content,开始添加悬浮目录'); // 注意这里不能使用 .data('content', ...) const toc = $content.find( '#toc' ), limit = toc.closest( '.toclimit' ), tocCustom = toc.clone().addClass( 'toc-custom' ).attr('data-content', wgUCS("目录", "目錄")).removeAttr('id') // 考虑到预览界面,这里不能用 .children( '.mw-parser-output' ) .appendTo( $content.find( '.mw-parser-output' ) ); tocCustom.children( '.toctogglecheckbox' ).remove(); if (limit.length === 0) { return; } tocCustom.addClass( limit.attr('class') ); }); //</nowiki> // [[category:桌面版小工具]] [[category:作为模块的小工具]] [[category:阅读工具]] [[category:默认开启的小工具]] // {{DEFAULTSORT:toc-custom.js}}