Wikipedysta:Mathieu Mars/common.js
importScript('Wikipedysta:Kaligula/js/markAsDone.js');
var hotcat_no_autocommit = 0;
// disFixIfRedirsOnly=true
importScript('Wikipedysta:Matma Rex/disFixer.js');
var wp_sk_show_as_button = true; // pokazuj przycisk
var wp_sk_redir_enabled = true; // ajaksowe redirecty
importScript('Wikipedysta:PS./flagi.js');
// Przyciski nad polem edycji
importScript('Wikipedysta:ToSter/snippets.js');
$(document).ready(function() {
window.sniparray = [
'{{Wikiprojekt:Czy wiesz/weryfikacja|Tytuł|+|liczba obrazków|?|Autor|Wstawiający|?|?|?}}',
'{{sub"+"st:Czy wiesz - autor | tytuł strony = [[tytuł]] | dzień = {{sub"+"st:LOCALDAY}} | miesiąc = {{sub"+"st:LOCALMONTHNAMEGEN}} | rok = {{sub"+"st:CURRENTYEAR}} | więcej stron = }}'
];
});
importScript('Wikipedysta:Tufor/QuickReCat.js');
// dodatki do [[WP:SK]]
mw.loader.using( 'ext.gadget.wp_sk' ).done( function () {
// importScript('Wikipedysta:ToSter/wpsk_user.js');
importScript('Wikipedysta:Beno/wp_sk.js');
importScript('Wikipedysta:Malarz pl/wp sk.js');
importScript('Wikipedysta:Malarz pl/wp si.js');
} );
/**
* Add rollback buttons with 'markbot' functionality. Based on
* mediawiki.page.rollback module from MW core.
*
* @author Peter Bowman
*/
( function ( mw, $ ) {
mw.hook( 'wikipage.content' ).add( function ( $content ) {
var api,
$rollbackLinks = $content.find( '.mw-rollback-link' );
if ( !$rollbackLinks.length ) {
return;
}
mw.loader.using( [
'mediawiki.util',
'mediawiki.user',
'mediawiki.api',
'jquery.spinner'
] )
.then( function ( require ) {
api = new mw.Api( { parameters: {
errorformat: 'html',
errorlang: mw.config.get( 'wgUserLanguage' ),
errorsuselocal: true
} } );
return mw.user.getRights();
} )
.then( function ( rights ) {
if ( rights.indexOf( 'markbotedits' ) === -1 ) {
return $.Deferred().reject();
}
return api.loadMessagesIfMissing( [ 'actioncomplete', 'rollbackfailed' ] );
} )
.done( function () {
var isDiff = !!mw.util.getParamValue( 'diff' ),
isHistory = mw.config.get( 'wgAction' ) === 'history',
isContribs = mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Contributions';
$rollbackLinks.each( function () {
var $spinner, $container,
$this = $( this ),
$link = $this.find( 'a' ).first().clone(),
url = $link.attr( 'href' ) + '&bot=1',
page = mw.util.getParamValue( 'title', url ),
user = mw.util.getParamValue( 'from', url );
if ( mw.user.options.get( 'norollbackdiff' ) ) {
url += '&hidediff=1';
}
$link.text( 'mb' ).attr( 'href', url );
$container = $( '<span>' )
.addClass( 'bot-rollback-link' )
.append( $link );
if ( isDiff || isContribs ) {
mw.util.addCSS( [
'.bot-rollback-link::before { content: "[" }',
'.bot-rollback-link::after { content: "]" }'
].join( '' ) );
$this.after( ' ', $container );
} else if ( isHistory ) {
$container = $( '<span>' ).append( $container ).insertAfter( $this.parent() );
}
$link.one( 'click', function ( e ) {
if ( !page || !user ) {
// Let native browsing handle the link
return true;
}
// Hide the link and create a spinner to show it inside the brackets.
$spinner = $.createSpinner( { size: 'small', type: 'inline' } );
$link.hide().after( $spinner );
api.rollback( page, user, { markbot: true } )
.then( function ( data ) {
mw.notify( $.parseHTML( data.messageHtml ), {
title: mw.msg( 'actioncomplete' )
} );
$this.remove();
$container.remove();
}, function ( errorCode, data ) {
mw.notify( api.getErrorMessage( data ), {
type: errorCode === 'alreadyrolled' ? 'warn' : 'error',
title: mw.msg( 'rollbackfailed' ),
autoHide: false
} );
// Restore the link (enables user to try again)
$spinner.remove();
$link.show();
} );
e.preventDefault();
} );
} );
} );
} );
}( mediaWiki, jQuery ) );
( function ( mw, $ ) {
var api, user;
var stats = {
rollbackDone: 0,
rollbackFailed: 0,
deleteDone: 0,
deleteFailed: 0
};
var rollbackQuery = {
markbot: true,
summary: 'rewert – obchodzenie blokady'
};
var msgOptions = {
autoHide: false
};
var rollbackMsgOptions = {
tag: 'rollback'
};
var deleteMsgOptions = {
tag: 'delete'
};
function recursiveRollback( pages, index ) {
mw.notify(
'Rewertowanie... ' + ( index = index || 1 ),
$.extend( {}, msgOptions, rollbackMsgOptions )
);
return api.rollback( pages.pop(), user, rollbackQuery ).then( function () {
stats.rollbackDone++;
return pages.length ? recursiveRollback( pages, ++index ) : undefined;
}, function () {
stats.rollbackFailed++;
return pages.length ? recursiveRollback( pages, ++index ) : undefined;
} );
}
function recursiveDelete( pages, index ) {
var query = {
formatversion: 2,
action: 'delete',
title: pages.pop(),
reason: 'Masowe usuwanie wkładu ' + user
};
mw.notify(
'Usuwanie... ' + ( index = index || 1 ),
$.extend( {}, msgOptions, deleteMsgOptions )
);
return api.postWithToken( 'delete', query ).then( function () {
stats.deleteDone++;
return pages.length ? recursiveDelete( pages, ++index ) : undefined;
}, function () {
stats.deleteFailed++;
return pages.length ? recursiveDelete( pages, ++index ) : undefined;
} );
}
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Contributions' ) {
$.when(
mw.loader.using( 'mediawiki.api' ),
$.ready
).done( function () {
api = new mw.Api();
user = mw.config.get( 'wgRelevantUserName' );
$( '<input>' )
.attr( {
type: 'submit',
value: 'Zablokuj i usuń wkład'
} )
.prependTo( '#mw-content-text' )
.on( 'click', function ( e ) {
var rollbackList, deleteList;
if ( confirm( 'Jesteś tego pewien?' ) ) {
rollbackQuery.summary = prompt( 'Wskaż uzasadnienie rewertu', rollbackQuery.summary );
api.postWithToken( 'block', {
action: 'block',
user: user,
expiry: prompt( 'Wskaż czas trwania blokady', 'infinite' ),
reason: prompt( 'Wskaż powód blokady', 'obchodzenie blokady' ),
nocreate: true,
autoblock: true,
reblock: true
} )
.then( function () {
mw.notify( 'Zablokowanie się powiodło.', msgOptions );
return api.get( {
formatversion: 2,
list: 'usercontribs',
ucuser: user,
uclimit: 'max'
} );
}, function () {
mw.notify( 'Wystąpił błąd podczas nakładania blokady.', $.extend( {}, msgOptions, {
type: 'error'
} ) );
} )
.then( function ( data ) {
var worklist = {};
$.each( data.query.usercontribs, function ( i, contrib ) {
var obj = worklist.hasOwnProperty( contrib.title )
? worklist[ contrib.title ]
: {
top: false,
new: false
};
obj.top |= contrib.top;
obj.new |= contrib.new;
worklist[ contrib.title ] = obj;
} );
rollbackList = $.grep( Object.keys( worklist ), function ( title ) {
var obj = worklist[ title ];
return obj.top && !obj.new;
} );
deleteList = $.grep( Object.keys( worklist ), function ( title ) {
var obj = worklist[ title ];
return obj.top && obj.new;
} );
mw.notify( mw.format(
'Pobrano wkład użytkownika: $1 edycji, $2 do przetworzenia (nowych: $3, bieżących: $4).',
Object.keys( worklist ).length,
rollbackList.length + deleteList.length,
deleteList.length,
rollbackList.length
), msgOptions );
} )
.then( function () {
if ( rollbackList.length ) {
return recursiveRollback( rollbackList ).then( function () {
var msg = mw.format(
'Zrewertowanych: $1, błędów: $2.',
stats.rollbackDone,
stats.rollbackFailed
);
mw.notify( msg, $.extend( {}, msgOptions, rollbackMsgOptions, {
type: stats.rollbackFailed ? 'warn' : 'info'
} ) );
} );
}
} )
.then( function () {
if ( deleteList.length ) {
return recursiveDelete( deleteList ).then( function () {
var msg = mw.format(
'Usuniętych: $1, błędów: $2.',
stats.deleteDone,
stats.deleteFailed
);
mw.notify( msg, $.extend( {}, msgOptions, deleteMsgOptions, {
type: stats.deleteFailed ? 'warn' : 'info'
} ) );
} );
}
} );
}
return false;
} );
} );
}
}( mediaWiki, jQuery ) );
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.