跳转到内容

User:Bencmq/script/LastEdit.js

维基百科,自由的百科全书
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
$.ajax({
    type: "GET",
    url: mw.util.wikiScript('api'),
    data: {
        action: 'query',
        list: 'allusers',
        format: 'json',
        augroup: 'bot',
        aulimit: '200'
    },
    dataType: 'json',
    success:function(jsondata) {
        for (var i = 0; i < jsondata.query.allusers.length; i++) {
            var username = jsondata.query.allusers[i].name;
            $.ajax({
                type: 'GET',
                url: mw.util.wikiScript('api'),
                data: {
                    action: 'query',
                    list: 'usercontribs',
                    format: 'json',
                    requestid: username,
                    uclimit : '1',
                    ucuser: username,
                    ucprop: 'timestamp'
                },
                dataType: 'json',
                success:function(jsondata) {
                    if (jsondata.query.usercontribs.length === 0) {
                        console.log(jsondata.requestid + " never");
                    } else {
                        console.log(jsondata.query.usercontribs[0].user + " " + jsondata.query.usercontribs[0].timestamp);
                    }
                }
            })
        }
    }
});