ব্যবহারকারী:ARI/common.js: সংশোধিত সংস্করণের মধ্যে পার্থক্য
অবয়ব
সম্পাদনা সারাংশ নেই |
সম্পাদনা সারাংশ নেই |
||
| ১ নং লাইন: | ১ নং লাইন: | ||
mw.loader.using(['mediawiki.api'], function () { | |||
mw.loader.using( [ | |||
if (mw.config.get('wgCanonicalSpecialPageName') !== 'Contributions') return; | |||
const api = new mw.Api(); | |||
const username = mw.util.getParamValue('user'); | |||
if (!username) return; | |||
const btn = $('<button>') | |||
.text('Rollback all visible edits') | |||
.css({ | |||
marginLeft: '10px', | |||
padding: '4px 8px', | |||
fontSize: '90%' | |||
}) | |||
.on('click', async function () { | |||
if (!confirm('Rollback all visible top edits by "' + username + '" ?')) return; | |||
let rolled = 0; | |||
try { | |||
const data = await api.get({ | |||
action: 'query', | |||
list: 'usercontribs', | |||
ucuser: username, | |||
uclimit: 100, | |||
ucprop: 'title|flags' | |||
}); | |||
for (const edit of data.query.usercontribs) { | |||
if (!edit.top) continue; | |||
await api.postWithToken('csrf', { | |||
action: 'rollback', | |||
title: edit.title, | |||
user: username, | |||
summary: 'Rollback spam edits' | |||
}); | |||
rolled++; | |||
await new Promise(r => setTimeout(r, 1200)); // VERY important | |||
} | |||
alert('Rollback finished. Reverted: ' + rolled + ' edits.'); | |||
} catch (e) { | |||
console.error(e); | |||
alert('Stopped due to an error. Check console.'); | |||
} | |||
}); | |||
$('#firstHeading').append(btn); | |||
}); | |||
} ); | |||
২৩:৪৩, ৬ জানুয়ারি ২০২৬ তারিখে সংশোধিত সংস্করণ
mw.loader.using(['mediawiki.api'], function () {
if (mw.config.get('wgCanonicalSpecialPageName') !== 'Contributions') return;
const api = new mw.Api();
const username = mw.util.getParamValue('user');
if (!username) return;
const btn = $('<button>')
.text('Rollback all visible edits')
.css({
marginLeft: '10px',
padding: '4px 8px',
fontSize: '90%'
})
.on('click', async function () {
if (!confirm('Rollback all visible top edits by "' + username + '" ?')) return;
let rolled = 0;
try {
const data = await api.get({
action: 'query',
list: 'usercontribs',
ucuser: username,
uclimit: 100,
ucprop: 'title|flags'
});
for (const edit of data.query.usercontribs) {
if (!edit.top) continue;
await api.postWithToken('csrf', {
action: 'rollback',
title: edit.title,
user: username,
summary: 'Rollback spam edits'
});
rolled++;
await new Promise(r => setTimeout(r, 1200)); // VERY important
}
alert('Rollback finished. Reverted: ' + rolled + ' edits.');
} catch (e) {
console.error(e);
alert('Stopped due to an error. Check console.');
}
});
$('#firstHeading').append(btn);
});