|
|
| (একই ব্যবহারকারী দ্বারা সম্পাদিত ৫টি মধ্যবর্তী সংশোধন দেখানো হচ্ছে না) |
| ১ নং লাইন: |
১ নং লাইন: |
| // Mass Rollback Tool - Language Independent
| | mw.notify("My userscript loaded!"); |
| $(function() {
| |
| // Check if we're on any Special:Contributions page
| |
| var isContribPage = mw.config.get('wgCanonicalSpecialPageName') === 'Contributions' ||
| |
| window.location.href.indexOf('Special:Contributions') > -1 ||
| |
| window.location.href.indexOf('বিশেষ:অবদান') > -1;
| |
|
| |
| console.log('Is contrib page?', isContribPage);
| |
| console.log('Page name:', mw.config.get('wgCanonicalSpecialPageName'));
| |
|
| |
| if (!isContribPage) {
| |
| console.log('Not on contributions page, exiting');
| |
| return;
| |
| }
| |
|
| |
| console.log('Creating button...');
| |
|
| |
| // Add mass rollback button
| |
| var $button = $('<button>')
| |
| .attr('id', 'mass-rollback-btn')
| |
| .text('Mass Rollback All')
| |
| .css({
| |
| 'margin': '10px',
| |
| 'padding': '10px 20px',
| |
| 'background': '#d33',
| |
| 'color': 'white',
| |
| 'border': 'none',
| |
| 'cursor': 'pointer',
| |
| 'font-weight': 'bold'
| |
| })
| |
| .click(function() {
| |
| if (!confirm('Are you sure you want to rollback ALL visible edits?')) return;
| |
|
| |
| var $rollbackLinks = $('.mw-rollback-link a');
| |
| var total = $rollbackLinks.length;
| |
|
| |
| console.log('Found rollback links:', total);
| |
|
| |
| if (total === 0) {
| |
| alert('No rollback links found on this page!');
| |
| return;
| |
| }
| |
|
| |
| var done = 0;
| |
| mw.notify('Starting mass rollback of ' + total + ' edits...');
| |
|
| |
| $rollbackLinks.each(function(i) {
| |
| var link = this;
| |
| setTimeout(function() {
| |
| $.get(link.href).done(function() {
| |
| done++;
| |
| mw.notify('Rolled back ' + done + '/' + total);
| |
| if (done === total) {
| |
| mw.notify('Mass rollback complete! Refreshing...', {type: 'success'});
| |
| setTimeout(function() { location.reload(); }, 2000);
| |
| }
| |
| }).fail(function() {
| |
| mw.notify('Error rolling back edit ' + (i+1), {type: 'error'});
| |
| });
| |
| }, i * 1000);
| |
| });
| |
| });
| |
|
| |
| // Try multiple places to add the button
| |
| if ($('#mw-content-text').length) {
| |
| $('#mw-content-text').prepend($button);
| |
| console.log('Button added to #mw-content-text');
| |
| } else if ($('.mw-body-content').length) {
| |
| $('.mw-body-content').prepend($button);
| |
| console.log('Button added to .mw-body-content');
| |
| } else {
| |
| $('body').prepend($button);
| |
| console.log('Button added to body');
| |
| }
| |
|
| |
| console.log('Button element:', $('#mass-rollback-btn').length);
| |
| });
| |