Utente:Daimona Eaytoy/Massblock.js: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
m todo
m Estraggo handler dal loop e accorpo
Riga 6:
* Overwrite values in getLocalMessage to localize.
*
* @todo Use durations dropdown, handleHandle async loop nicely, fix protect "protections", protection doesn't work, use azioni-dopo-blocco.js, edit and protect numbers aren't updated.
*/
( function( mw, $ ) {
// OOUI element
var submitBtn,
// Like wgBlockAllowsUTEdit
blockAllowsTalkEdit;
 
Riga 51 ⟶ 52:
wpMassBlockProtectUser = $( "#wpMassBlockProtectUser input" ).prop( 'checked' );
 
var isInfty = isInfinity( wpMassBlockExpiry );
var count = 0;
 
var errorHandler = function( error, user ) {
failed.push( "Special:Block/" + user );
error.push( e );
};
 
var successHandler = function( response, user ) {
blocked++;
if ( wpMassBlockMessage !== "" ) {
doEditPage( 'User talk:' + user, wpMassBlockMessage, wpMassBlockSummaryTalk, !isInfty )
.done( function( data ) {
talkpageedited++;
} )
.fail( function( e ) {
errorHandler( e, user );
} );
}
if ( !isInfty ) {
// No pages should be protected, and the UP should be left as is
return;
}
 
if ( wpMassBlockProtectTalk ) {
doProtectPage( 'User talk:' + user )
.done( function( data ) {
talkpageprotected++;
} )
.fail( function( e ) {
errorHandler( e, user );
} );
}
if ( wpMassBlockTag !== "" ) {
doEditPage( 'User:' + user, wpMassBlockTag, wpMassBlockSummaryUser )
.done( function( data ) {
userpageedited++;
} )
.fail( function( e ) {
errorHandler( e, user );
} );
}
if ( wpMassBlockProtectUser ) {
doProtectPage( 'User:' + user )
.done( function( data ) {
userpageprotected++;
} )
.fail( function( e ) {
errorHandler( e, user );
} );
}
 
};
 
for ( i = 0; i < users.length; i++ ) {
let user = users[ i ].trim(),;
 
api = new mw.Api();
apinew mw.Api().postWithToken( "csrf", {
action: 'block',
allowusertalk: wpMassBlockTalkpage,
Riga 67 ⟶ 121:
user: user
} )
.thendone( function( data ) {
functionsuccessHandler( data, )user {);
} )
var isInfty = isInfinity( wpMassBlockExpiry );
.fail( function( e ) {
blocked++;
if errorHandler( wpMassBlockMessagee, !== ""user ) {;
} )
doEditPage( 'User talk:' + user, wpMassBlockMessage, wpMassBlockSummaryTalk, !isInfty )
.done( function( data ) {
talkpageedited++;
} )
.fail( function( e ) {
//If not edited, add the title to the "failed" array and a description of the error to the "error" array.
failed.push( 'User talk:' + user );
error.push( e );
} );
}
if ( !isInfty ) {
// No pages should be protected, and the UP should be left as is
return;
}
 
if ( wpMassBlockProtectTalk ) {
doProtectPage( 'User talk:' + user )
.done( function( data ) {
talkpageprotected++;
} )
.fail( function( e ) {
//If not edited, add the title to the "failed" array and a description of the error to the "error" array.
failed.push( 'User talk:' + user );
error.push( e );
} );
}
if ( wpMassBlockTag !== "" ) {
doEditPage( 'User:' + user, wpMassBlockTag, wpMassBlockSummaryUser )
.done( function( data ) {
userpageedited++;
} )
.fail( function( e ) {
//If not edited, add the title to the "failed" array and a description of the error to the "error" array.
failed.push( 'User:' + user );
error.push( e );
} );
}
if ( wpMassBlockProtectUser ) {
doProtectPage( 'User:' + user )
.done( function( data ) {
userpageprotected++;
} )
.fail( function( e ) {
//If not edited, add the title to the "failed" array and a description of the error to the "error" array.
failed.push( 'User:' + user );
error.push( e );
} );
}
},
function( e ) {
// If not blocked, add the title to the "failed" array and a description of the error to the "error" array.
failed.push( "Special:Block/" + user );
error.push( e );
}
)
.always(
function() {