User:Qwerfjkl/scripts/re-review.js
Appearance
< User:Qwerfjkl | scripts
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
This user script seems to have a documentation page at User:Qwerfjkl/scripts/re-review. |
// 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]])'
});
} );
} );
} );