User:Steven Sun/myPatrolMarks.js

维基百科,自由的百科全书

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

// 在 [[User:Steven_Sun/未巡查页面]] 中再次筛选未巡查页面

(function() {
    if(mw.config.values.wgPageName !== 'User:Steven_Sun/未巡查页面') {
        return;
    }

	mw.loader.using(['mediawiki.api']).done(function() {
        document.styleSheets[0].insertRule('.not-patrolled {background-color: yellow}')
        document.styleSheets[0].insertRule('.not-patrolled.mw-redirect {background-color: yellowgreen}')

        let api = new mw.Api();

        $('.wikitable td>a:not(.userlink)').each((i, e) => {
            let pagename = e.innerText;
            let oldid = e.parentNode.parentNode.children[1].innerText;
            api.get({
                'action': 'query',
                'format': 'json',
                'list': 'logevents',
                'letype': 'patrol',
                'letitle': pagename
            }).then(data => {
                if (data.query.logevents.length == 0) {
                    e.classList.add('not-patrolled');
                } else {
                    if (data.query.logevents[0].params.curid != oldid) {
                        // e.classList.add('not-patrolled');
                    }
                }
            });
        });

	});

})();