|
|
| (একই ব্যবহারকারী দ্বারা সম্পাদিত ১১টি মধ্যবর্তী সংশোধন দেখানো হচ্ছে না) |
| ১ নং লাইন: |
১ নং লাইন: |
| mw.loader.using(['mediawiki.api'], function () { | | mw.notify("My userscript loaded!"); |
| | |
| 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.notify("My userscript loaded!");