User:Liangent/Scripts/UndoRange.js

维基百科,自由的百科全书

注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。

( function( $, mw ) { mw.loader.using( [
    'mediawiki.util'
], function() { $( function() {
    if ( mw.config.get( 'wgAction' ) == 'history' ) {
        $( '#mw-history-compare .mw-history-compareselectedversions-button' ).after(
            $( '<input type="submit" />' )
                .val( 'UndoRange' )
                .click( function( e ) {
                    $( '#mw-history-compare input[name=diff]' ).attr( 'name', 'undo' );
                    $( '#mw-history-compare input[name=oldid]' ).attr( 'name', 'undoafter' );
                    $( '#mw-history-compare input[name=action]' ).val( 'edit' );
                    $( '<input type="hidden" name="summary" />' ).val(
                        'UndoRange: ' + $( '#mw-history-compare input:checked[name=undoafter]' ).val()
                            + ' ~ ' + $( '#mw-history-compare input:checked[name=undo]' ).val()
                    ).insertAfter( this );
                } )
        );
    }
} ); } ); } )( jQuery, mediaWiki );