« Utilisateur:Framawiki/spamblock.js » : différence entre les versions
De Anekdotos
Aucun résumé des modifications |
Aucun résumé des modifications |
||
Ligne 2 : | Ligne 2 : | ||
// (c) fantastique 0x010C | // (c) fantastique 0x010C | ||
// | // Le script est chargé pour tous les admins du site (via [[MediaWiki:Group-sysop.js]]) | ||
// | // Pour l'utiliser aller sur https://anekdotos.net/index.php?title=Sp%C3%A9cial:Journal&offset=&limit=500&type=newusers&useskin=vector&user= | ||
mw.loader.load('mediawiki.api'); | mw.loader.load('mediawiki.api'); |
Version du 1 septembre 2018 à 23:20
// Importé de [[:w:fr:Utilisateur:0x010C/script/SpamBlock.js]] // (c) fantastique 0x010C // Le script est chargé pour tous les admins du site (via [[MediaWiki:Group-sysop.js]]) // Pour l'utiliser aller sur https://anekdotos.net/index.php?title=Sp%C3%A9cial:Journal&offset=&limit=500&type=newusers&useskin=vector&user= mw.loader.load('mediawiki.api'); mw.loader.load('mediawiki.util'); function block( username ) { var api = new mw.Api(); return api.postWithToken( 'csrf', { action: 'block', user: username, expiry: 'never', reason: 'spam', nocreate: '1', autoblock: '1', noemail: '1', tags: 'spamblock' } ); } function spamblock() { $( '.mw-logline-newusers' ).each( function() { if ( $( this ).find( ':checked' ).length ) { var self = this; block( $( this ).find( 'a.new.mw-userlink' ).text() ) .then( function( data ) { console.log( data.block.id ); $( self ).css( 'background', '#b1f968' ); $( self ).append( $( '<i>' ).html( '<small>Blocage #' + data.block.id + '</small>' ) ); } ) .fail( function( data ) { if ( data === 'alreadyblocked' ) { $( self ).css( 'background', '#f9f968' ); } else { alert('failed'); alert(data); $( self ).css( 'background', '#fc4c49' ); } } ); } } ); } if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Log' && mw.util.getParamValue( 'type' ) === 'newusers' ) { var button = $( '<button>' ).text( 'Bloquer en masse des comptes créé en rafale' ); button.click( function( e ) { e.preventDefault(); spamblock(); } ); $( '.mw-checkbox-toggle-controls' ).eq( 0 ).before( button ); }