// Taken from [[WP:US/G]]
// the line "text: info.text," will cause the call
// to replace entire page content with supplied data.
// alternatively, one can append or prepend the data to the page, by using
// "appendtext: info.text," or "prependtext: info.text," instead.
// when using "appendtext", it is possible to append the text to a specific section,
// by setting the optional field "section".
function rereviewPage( info ) {
$.ajax({
url: mw.util.wikiScript( 'api' ),
type: 'POST',
dataType: 'json',
data: {
format: 'json',
action: 'edit',
title: info.title,
section: 13, // Manually set
appendtext: info.text,
summary: info.summary,
token: mw.user.tokens.get( 'csrfToken' )
}
})
.then (function( data ) {
if ( data && data.edit && data.edit.result && data.edit.result == 'Success' ) {
mw.notify('Re-review successful!' );
} else {
alert( 'The edit query returned an error. =(' );
}
})
.catch ( function() {
alert( 'The ajax request failed.' );
});
}
// Make sure the utilities module is loaded (will only load if not already)
mw.loader.using( 'mediawiki.util', function () {
// Wait for the page to be parsed
$( document ).ready( function () {
// 'More' tab in vector skin
var link = mw.util.addPortletLink( 'p-cactions', '#', 'Re-review', 'ca-rereview', 'Remotely re-review an article');
$( link ).click( function ( event ) {
event.preventDefault();
var user = prompt('User:', '');
if (user === null)
{
mw.notify('Re-review cancelled.');
return;
}
else if (user === "")
{
mw.notify('Re-review cancelled.');
return;
}
else
{
}
var description = prompt('Description:', 'Correctly marked as reviewed.');
if (description === null)
{
mw.notify('Re-review cancelled.');
return;
}
else if (description === "")
{
mw.notify('Re-review cancelled.');
return;
}
else
{
}
rereviewPage({
title: 'Wikipedia:New_pages_patrol/Backlog_drives/November_2021/Re-reviews',
text: '\n# [['+mw.config.get('wgPageName').replace(/_/g, ' ')+']] — [[User:'+user+']] — ' + description,
summary: '+1 (via [[User:Qwerfjkl/scripts/re-review|script]])'
});
} );
} );
} );