$( document ).ready( () => {
"use strict";
if ( mw.config.get( "wgAction" ) === "history" ) {
const HC = document.getElementById( "mw-history-compare" );
if ( HC ) {
const BTNS = HC.querySelectorAll( 'input[value="Compare selected revisions"]' ),
TOP = BTNS[ 0 ], BTM = BTNS[ 1 ],
encapsulate = () => {
const LSB = HC.querySelector( "li.selected.before" ),
LSA = HC.querySelector( "li.selected.after" );
if ( TOP && LSB ) {
LSB.before( TOP );
}
if ( BTM && LSA ) {
LSA.after( BTM );
}
/* move buttons added by User:Enterprisey/cv-revdel.js along with the "Compare selected revisions" buttons */
HC.querySelectorAll( "button.cv-rd-add-range" ).forEach( ( b, i ) => BTNS[ i ]?.before( b ) );
};
encapsulate();
HC.addEventListener( "change", encapsulate, { passive: true } );
}
}
} );