全站通知:

用户:33961147/purgeAll.js

来自bilibili游戏中心 - WIKI
跳到导航 跳到搜索

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

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Internet Explorer或Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
  • Opera:Ctrl-F5
$.getJSON( mw.util.wikiScript('api'), { format: 'json', action: 'parse', text: `{{Special:NewPages|limit=1|namespace=all}}`, contentmodel: 'wikitext' })
	.done( function ( data ) {
		var pageName = $(data.parse.text["*"]).find("a.mw-newpages-pagename").attr("title");
		$.getJSON( mw.util.wikiScript('api'), { format: 'json', action: 'query', prop: "info", titles: pageName })
			.done( function ( data ) { console.log(window.maxPageId = parseInt(Object.keys(data.query.pages)[0])); getPages() });
});	


function getPages(wiki = mw.config.values.wgGameName, minId = 0, maxId = window.maxPageId, size = 50) {
	let result = {}
	console.log(wiki, minId, maxId, size)
	query(minId)

	function query(start) {
		let arr = []
		let flag = true
		for (let i = start; i < start + size; i++) {
			arr.push(i)
			if (i >= maxId) {
				flag = false
				break
			}
		}
		new mw.Api().post({
            "action": "purge",
            "format": "json",
			"formatversion": "2",
            "titles": arr.join("|")
        }).then((data) => {
			console.log(arr[arr.length - 1], maxId, data)
			if(arr[arr.length - 1] <= maxId ) {
				query(start + size)
			} else {
				console.log("刷完啦")
			}
		})
	}
}