跳转到内容

User:Streetdeck/js/PatrollCount.js

维基百科,自由的百科全书
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
javascript:
(function(){

mw.loader.using(['mediawiki.api']).done(function(){

var patroll = mw.util.addPortletLink(
	'p-personal',
	'#',
	'patrollcount',
	'pt-mypatroll',
	'patrollcount',
	'',
	'#pt-mycontris'
);
var path = mw.config.get('wgArticlePath');
patroll.innerHTML =
	'(Talk <a id="unpatrollTalk" href="' + path.replace('$1', 'Special:最新页面?hidepatrolled=1&namespace=1') + '">?</a>)' +
	'(User <a id="unpatrollUser" href="' + path.replace('$1', 'Special:最新页面?hidepatrolled=1&namespace=2') + '">?</a>)' +
	'(UT <a id="unpatrollUsertalk" href="' + path.replace('$1', 'Special:最新页面?hidepatrolled=1&namespace=3') + '">?</a>)' +
	'(Cat <a id="unpatrollCategory" href="' + path.replace('$1', 'Special:最新页面?hidepatrolled=1&namespace=14') + '">?</a>)' +
	'(File <a id="unpatrollFile" href="' + path.replace('$1', 'Special:最新页面?hidepatrolled=1&namespace=6') + '">?</a>)';

var api = new mw.Api();
function getPatrollCount() {
	api.get({
		action: "query",
		format: "json",
		list: "recentchanges",
		rcnamespace: "1",
		rcshow: "!patrolled",
		rclimit: "max",
		rctype: "new"
		}).done( function ( data ) {
			unpatrollTalk.innerHTML = data.query.recentchanges.length;
		});
	api.get({
		action: "query",
		format: "json",
		list: "recentchanges",
		rcnamespace: "2",
		rcshow: "!patrolled",
		rclimit: "max",
		rctype: "new"
		}).done( function ( data ) {
			unpatrollUser.innerHTML = data.query.recentchanges.length;
		});
	api.get({
		action: "query",
		format: "json",
		list: "recentchanges",
		rcnamespace: "3",
		rcshow: "!patrolled",
		rclimit: "max",
		rctype: "new"
		}).done( function ( data ) {
			unpatrollUsertalk.innerHTML = data.query.recentchanges.length;
		});
		api.get({
		action: "query",
		format: "json",
		list: "recentchanges",
		rcnamespace: "14",
		rcshow: "!patrolled",
		rclimit: "max",
		rctype: "new"
		}).done( function ( data ) {
			unpatrollCategory.innerHTML = data.query.recentchanges.length;
		});
		api.get({
		action: "query",
		format: "json",
		list: "recentchanges",
		rcnamespace: "6",
		rcshow: "!patrolled",
		rclimit: "max",
		rctype: "new"
		}).done( function ( data ) {
			unpatrollFile.innerHTML = data.query.recentchanges.length;
		});
}
if (typeof window.PatrollCountInterval === "number") {
	setInterval(getPatrollCount, PatrollCountInterval);
}
getPatrollCount();

});

})();