User:BZPN/MassRollback2.js: Difference between revisions

From Test Wiki
Content deleted Content added
BZPN (talk | contribs)
No edit summary
BZPN (talk | contribs)
No edit summary
 
Line 537: Line 537:
mw.notify('Successfully rolled back 1 edit.', { type: 'success' });
mw.notify('Successfully rolled back 1 edit.', { type: 'success' });
if (confirmResult.leaveWarning) {
if (confirmResult.leaveWarning) {
await self.leaveUserWarning(confirmResult.warningType);
await self.leaveUserWarning(confirmResult.warningType, edit.user || null);
}
}
if (confirmResult.reportVIP) {
if (confirmResult.reportVIP) {
Line 1,032: Line 1,032:
mw.notify(`Successfully rolled back ${selected.length} edits.`, { type: 'success' });
mw.notify(`Successfully rolled back ${selected.length} edits.`, { type: 'success' });
if (confirmResult.leaveWarning) {
if (confirmResult.leaveWarning) {
const targetUser = (selected[0] && selected[0].user) ? selected[0].user : null;
await this.leaveUserWarning(confirmResult.warningType);
await this.leaveUserWarning(confirmResult.warningType, targetUser);
}
}
if (confirmResult.reportVIP) {
if (confirmResult.reportVIP) {
Line 1,064: Line 1,065:
mw.notify(`Successfully rolled back ${selected.length} filtered edits.`, { type: 'success' });
mw.notify(`Successfully rolled back ${selected.length} filtered edits.`, { type: 'success' });
if (confirmResult.leaveWarning) {
if (confirmResult.leaveWarning) {
const targetUser = (selected[0] && selected[0].user) ? selected[0].user : null;
await this.leaveUserWarning(confirmResult.warningType);
await this.leaveUserWarning(confirmResult.warningType, targetUser);
}
}
if (confirmResult.reportVIP) {
if (confirmResult.reportVIP) {
Line 1,098: Line 1,100:
mw.notify(`Successfully rolled back all ${contributions.length} edits.`, { type: 'success' });
mw.notify(`Successfully rolled back all ${contributions.length} edits.`, { type: 'success' });
if (confirmResult.leaveWarning) {
if (confirmResult.leaveWarning) {
const targetUser = (contributions[0] && contributions[0].user) ? contributions[0].user : null;
await this.leaveUserWarning(confirmResult.warningType);
await this.leaveUserWarning(confirmResult.warningType, targetUser);
}
}
if (confirmResult.reportVIP) {
if (confirmResult.reportVIP) {
Line 1,173: Line 1,176:


// Leave a talk page warning using a chosen template (subst) under current month section
// Leave a talk page warning using a chosen template (subst) under current month section
leaveUserWarning: async function(templateName) {
leaveUserWarning: async function(templateName, targetUser) {
const api = new mw.Api();
const api = new mw.Api();
const userName = mw.config.get('wgRelevantUserName');
const userName = targetUser || mw.config.get('wgRelevantUserName');
if (!userName) {
mw.notify('Could not determine user name for talk page warning.', { type: 'error' });
return;
}
const title = `User talk:${userName}`;
const title = `User talk:${userName}`;