User:Liangent/Scripts/CherryPick.js
外观
< User:Liangent | Scripts
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
( function( $, mw ) {
mw.loader.using( [ 'mediawiki.util', 'mediawiki.Uri' ], function() {
$( function() {
var oldHref = $( '#mw-diff-otitle1 a' ).prop( 'href' );
var newHref = $( '#mw-diff-ntitle1 a' ).prop( 'href' );
if ( !oldHref || !newHref ) {
return;
}
var oldRevId = new mw.Uri( oldHref ).query.oldid;
var newRevId = new mw.Uri( newHref ).query.oldid;
if ( !oldRevId || !newRevId ) {
return;
}
$( mw.util.addPortletLink( 'p-cactions', '#', 'Cherry-Pick' ) ).click( function( e ) {
e.preventDefault();
var page = prompt( 'Cherry-Pick to:' );
if ( page === null ) {
return;
}
if ( page === '' ) {
page = null;
}
location.href = mw.util.getUrl( page, {
action: 'edit',
undo: oldRevId,
undoafter: newRevId,
summary: 'cherry-picking revision ' + newRevId
+ ' until ' + oldRevId
+ ' from [[' + mw.config.get( 'wgPageName' ) + ']]'
} );
} );
} );
} );
} )( jQuery, mediaWiki );