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

Contenuto cancellato Contenuto aggiunto
m +trim e beautify
semplificazione funzioni, +protezione se il blocco è infinito (da concludere)
Riga 22:
talkpageedited = 0,
userpageedited = 0,
talkpageprotected = 0,
userpageprotected = 0,
failed = [],
error = [];
Riga 34 ⟶ 36:
wpMassBlockExpiry = document.getElementById( "wpMassBlockExpiry" ).value.trim();
var wpMassBlockSummaryTalk = document.getElementById( "wpMassBlockSummaryTalk" ).value.trim(),
wpMassBlockSummaryUser = document.getElementById( "wpMassBlockSummaryUser" ).value.trim();,
wpMassBlockProtectTalk = document.getElementById( "wpMassBlockProtectTalk" ).checked,
wpMassBlockProtectUser = document.getElementById( "wpMassBlockProtectUser" ).checked;
 
for ( i = 0; i < users.length; i++ ) {
Riga 56 ⟶ 60:
blocked++;
if ( wpMassBlockMessage !== "" ) {
doEditPage( 'User talk:' + user, wpMassBlockMessage, wpMassBlockSummaryTalk )
doEditTalk();
} ) .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 );
doEditTalk( } );
}
if ( wpMassBlockProtectTalk ) {
failed.push 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 )
doEditUserPage();
.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 ( wpMassBlockProtectUserPage ) {
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 );
} );
}
},
Riga 72 ⟶ 114:
 
// Hackeroni ripperoni
alert(
alert( msg[ 'result-alert' ].replace( '$1', blocked ).replace( '$2', talkpageedited ).replace( '$3', userpageedited ) );
.replace( '$4', talkpageprotected ).replace( '$5', userpageprotected )
);
 
if ( failed.length > 0 ) {
Riga 84 ⟶ 129:
}
 
function doEditUserPagedoEditPage( title, text, summary ) {
newreturn mw.Api().postWithEditToken( {
action: 'edit',
title: 'User:' + usertitle,
text: wpMassBlockTagtext,
summary: wpMassBlockSummaryUsersummary,
watchlist: 'nochange'
} ).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 talk:" + user );
error.push( e );
} );
}
 
function doEditTalkdoProtectPage( title ) {
return new mw.Api().postWithEditTokenpostWithToken( 'csrf', {
action: 'editprotect',
title: 'User talk:' + usertitle,
protections: protections,
text: wpMassBlockMessage,
reason: 'utente bloccato infinito',
summary: wpMassBlockSummaryTalk,
watchlist: 'nochange',
format: 'json',
} ).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 );
} );
}
Riga 129 ⟶ 163:
'exptime': 'Expiration time (blank for indefinite):',
'talksummary': 'Edit summary for talk page edit:',
'talkprotect': 'Protect the talk:',
'upsummary': 'Edit summary for user page edit:',
'upprotect': 'Protect the user page:',
'anononly': 'Block anonymous users only (IPs only):',
'autoblock': 'Enable autoblock (accounts only):',
Riga 137 ⟶ 173:
'override': 'Override existing blocks:',
'submit-text': 'Block',
'result-alert': 'Blocked $1 users,. editedEdited $2 talk pages and $3 user pages. Protected $4 talk pages and $5 user pages.',
'failed-actions': 'Failed actions:'
};
Riga 162 ⟶ 198:
'exptime': 'Durata del blocco (lasciare vuoto per blocco infinito):',
'talksummary': 'Oggetto per la modifica della talk:',
'talkprotect': 'Proteggi la talk:',
'upsummary': 'Oggetto per la modifica della pagina utente:',
'upprotect': 'Proteggi la pagina utente:',
'anononly': 'Blocca solo utenti anonimi:',
'autoblock': 'Attiva autoblocco (solo utenti registrati):',
Riga 170 ⟶ 208:
'override': 'Sovrascrivi eventuali blocchi:',
'submit-text': 'Scatena l\'inferno!',
'result-alert': 'Bloccati $1 utenti,. modificateModificate $2 talk e $3 pagine utente. Protette $4 talk e $5 pagine utente.',
'failed-actions': 'Azioni non riuscite:'
};
Riga 192 ⟶ 230:
msg[ 'blockusers' ] + '<br />' +
'<textarea tabindex="1" accesskey="," name="wpMassBlockUsers" id="wpMassBlockUsers" rows="10" cols="80"></textarea>' +
'<span id="wpMassBlockTalkMsgLegend">' + msg[ 'talkmsg' ] + '</span><br />' +
'<textarea tabindex="2" accesskey="," name="wpMassBlockMessage" id="wpMassBlockMessage" rows="10" cols="80"></textarea>' +
'<span id="wpMassBlockUserMsgLegend">' + msg[ 'upmsg' ] + '</span><br />' +
'<textarea tabindex="3" accesskey="," name="wpMassBlockTag" id="wpMassBlockTag" rows="10" cols="80"></textarea>' +
'<br /><br /><table style="background-color:transparent">' +
Riga 215 ⟶ 253:
'<tr><td>' + msg[ 'exptime' ] + '</td>' +
'<td><input type="text" id="wpMassBlockExpiry" name="wpMassBlockExpiry" maxlength="255" /></td></tr>' +
'<tr id ="wpMassBlockTalkSummaryRow"><td>' + msg[ 'talksummary' ] + '</td>' +
'<td><input type="text" id="wpMassBlockSummaryTalk" name="wpMassBlockSummaryTalk" maxlength="255" /></td></tr>' +
'<tr id ="wpMassBlockTalkProtectRow"><td>' + msg[ 'upsummarytalkprotect' ] + '</td>' +
'<td><input type="checkbox" id="wpMassBlockProtectTalk" name="wpMassBlockProtectTalk" /></td></tr>' +
'<tr id ="wpMassBlockUserSummaryRow"><td>' + msg[ 'upsummary' ] + '</td>' +
'<td><input type="text" id="wpMassBlockSummaryUser" name="wpMassBlockSummaryUser" maxlength="255" /></td></tr>' +
'<tr id ="wpMassBlockUserProtectRow"><td>' + msg[ 'upprotect' ] + '</td>' +
'<td><input type="checkbox" id="wpMassBlockProtectUser" name="wpMassBlockProtectUser" /></td></tr>' +
'<tr><td>' + msg[ 'anononly' ] + '</td><td><input type="checkbox" id="wpMassBlockAnononly" name="wpMassBlockAnononly" /></td></tr>' +
'<tr><td>' + msg[ 'autoblock' ] + '</td><td><input type="checkbox" id="wpMassBlockAutoblock" name="wpMassBlockAutoblock" checked="checked" /></td></tr>' +
Riga 238 ⟶ 280:
 
document.getElementById( "wpMassBlockReason" ).setAttribute( "maxlength", maxlength );
};
document.getElementById( 'wpMassBlockExpiry' ).onchange = function() {
var show = /^(indefinite|indefinito|infinito|)$/i.test(this.value.trim());
var toggle = [ 'wpMassBlockTalkMsgLegend', 'wpMassBlockUserMsgLegend', 'wpMassBlockMessage', 'wpMassBlockTag',
'wpMassBlockTalkSummaryRow', 'wpMassBlockTalkProtectRow', 'wpMassBlockUserSummaryRow', 'wpMassBlockUserProtectRow'];
for ( var id in toggle ) {
$('#' + id).toggle( show );
}
};
}