注意:在保存之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。
- Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5或Ctrl-R(Mac为⌘-R)
- Google Chrome:按Ctrl-Shift-R(Mac为⌘-Shift-R)
- Internet Explorer:按住Ctrl的同时单击刷新,或按Ctrl-F5
- Opera:前往菜单 → 设置(Mac为Opera → Preferences),然后隐私和安全 → 清除浏览数据 → 缓存的图片和文件。
// 由[[Special:Mypage/common.js]]调用,可以使用ES6语法 // 生成JS文件大小 "use strict"; mw.myTools = function(table) { table.find( 'th' ).first().after( '<th style="width:0">大小(KB)</th>' ); const items = table.find( 'td:first-child' ), titles = items.children( 'a' ).map(function() { return this.title; }).toArray(); mw.loader.using( 'mediawiki.api' ).then(() => { console.log( 'API request: 查询JS页面大小' ); const timerStart = mw.now(); new mw.Api().get({ action:'query', prop:'info', titles:titles.join( '|' ), formatversion:2 }) .then(data => { console.log( `End API request: 已获得JS页面大小,用时 ${mw.now() - timerStart} ms` ); const lengths = Object.fromEntries( data.query.pages.map(ele => [ele.title, ele.length]) ); items.after(i => { return $('<td>').addClass( 'video-link' ).css('text-align', 'right') .text( (lengths[ titles[i] ] / 1024).toFixed(1) ); }); }); }); };