User:Liangent/Scripts/CherryPick.js

( 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 );