Jump to content

User:SilverLocust/sandbox.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
$(".mw-newpages-pagename").on('click', function(e) {
	e.preventDefault();
	var title = this.innerText,
		message = 'Mark ' + title + ' as reviewed?',
		params = {
			action: 'query',
			format: 'json',
			titles: title,
			prop: 'info',
		},
		api = new mw.Api(),
		pid;
	api.get( params ).done( function ( data ) {
		var pages = data.query.pages,
			p;
		for ( p in pages ) {
			pid = p;
		}
	} );
	if(confirm(message)) {
		api.postWithEditToken('pagetriageaction',
			{
				action: 'pagetriageaction',
				reviewed: 1,
				skipnotif: 1,
				pageid: pid
			}
        );
	}
});