LLWiki正在建设中,欢迎加入我们

“User:Bhsd/tool.js”的版本间差异

跳转到导航 跳转到搜索
// 生成JS文件大小
"use strict";
mw.myToolsmyCopyright = function(tablecmtitle) {
mw.loader.using( 'mediawiki.api' ).then(() => {
const api = new mw.Api();
api.get({action: 'query',
list: 'categorymembers',
cmtitle: 'Category:' + cmtitle,
cmprop: 'ids',
cmtype: 'file',
cmlimit: 'max',
formatversion: 2
}).then(data => {
api.get({action: 'query',
prop: 'categories',
pageids: data.query.categorymembers.map(ele => ele.pageid).join('|'),
clcategories: 'Category:原作者保留权利的文件',
formatversion: 2
}).then(res => {
res.query.pages.filter(ele => !ele.categories).forEach(ele => {
api.postWithToken('csrf', {action: 'edit',
pageid: ele.pageid,
prependtext: '==授权协议==\n{{copyright}}\n',
summary: '使用API批量添加授权协议',
minor: 1,
bot: 1
});
});
});
});
});
};
 
mw.myJsSize = function(table) {
table.find( 'th' ).first().after( '<th style="width:0">大小(KB)</th>' );
const items = table.find( 'td:first-child' ),