MediaWiki:RecentChangesShow.js

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
var api = new mw.Api();
api.get({
	action: 'query',
	list: 'recentchanges',
	rctype: 'edit',
	rcnamespace: 0,
	rclimit: 10,
}).done((data) => {
	if(data.query){ //有成功取到数据
		var pageList = [];
		var pageLinkList = document.createElement('ul');
		data.query.recentchanges.forEach((one) => {
			if(pageList.indexOf(one.title) < 0){
				pageList.push(one.title);
			}
		});
		pageList.forEach((one) => {
			var a = document.createElement('a');
			a.href = mw.util.getUrl(one);
			a.title = one;
			a.innerText = one;
			var li = document.createElement('li');
			li.appendChild(a);
			pageLinkList.appendChild(li);
		});
		$('.recent-changes.edit').html('').append(pageLinkList);
	}
});

api.get({
	action: 'query',
	list: 'recentchanges',
	rctype: 'new',
	rcnamespace: 0,
	rclimit: 10,
}).done((data) => {
	if(data.query){ //有成功取到数据
		var pageList = [];
		var pageLinkList = document.createElement('ul');
		data.query.recentchanges.forEach((one) => {
			if(pageList.indexOf(one.title) < 0){
				pageList.push(one.title);
			}
		});
		pageList.forEach((one) => {
			var a = document.createElement('a');
			a.href = mw.util.getUrl(one);
			a.title = one;
			a.innerText = one;
			var li = document.createElement('li');
			li.appendChild(a);
			pageLinkList.appendChild(li);
		});
		$('.recent-changes.add').html('').append(pageLinkList);
	}
});