User:Jack who built the house/toHlist.js

mw.loader.using( 'jquery.textSelection' ).done(function {

window.toHlist = function { var classList = 'hlist'; var text = $( '#wpTextbox1' ).textSelection( 'getContents' ).replace( //g, ' ' ); var newText = text.replace( /(\n\|-\s*align=["']?center["']?\s*\n\||\|\s*list\d*\s*=)([^]*?\n\s*)(?=\||\}\})/gi, function ( s, m1, m2 ) {		var m2r = m2.replace( /\{\{(?:[nN]o(?:wrap|br)|[sS])\|([^•·\}]+?)\s*(?:(?:\{\{)?•(?:\}\})?|(?:\'\'\'|\{\{)?·(?:\'\'\'|\}\})?|\{\{\*\}\})\s*\}\}\s*/g, '$1\n* ' );		m2r = m2r.replace( /\s*?(\{\{[·•*!](w(rap)?)?\}\}|·|•|&#124;)(?: )?\s*?/g, '\n* ' );		if ( m2 !== m2r ) {			m2r = m2r.replace( /^(\s*)]+| ?)>([^]*?)\n?<\/div>(\s*)$/, '$1$2$3' );			m2r = m2r.replace( /^(\s*)\{\{[nN]owrap begin\}\}([^]*?)\n?\{\{[nN]owrap end\}\}(\s*)$/, '$1$2$3'			);			m2r = m2r.replace( /^(\s*) ([^]*?)\n?<\/center>(\s*)$/, '$1$2$3' );			m2r = '\n* ' + m2r.replace( /^\s*/g, '' );			m2r = m2r.replace( /\* \{\{(?:[nN]o(?:wrap|br)|[sS])\|([^\}]+?)\s*\}\}(\s*)$/, '* $1$2' ); 			m2r = m2r.replace( / *(\s*)$/, '$1' );			var prevM2r = m2r;			// Artifacts with . They are left, if there were templates inside, like in Russian Wikipedia			m2r = m2r.replace( /\* \}\}\n/g, '* ' );			m2r = m2r.replace( /\* \{\{(?:[nN]o(?:wrap|br)|[sS])\|/g, '* ' );			m2r = m2r.replace( /(\n\* )([^{].+)\}\}(\s*)$/, '$1$2$3' );		}		return m1 + m2r;	} ); $( '#wpTextbox1' ).textSelection( 'setContents', newText ); var summaryText = $( '#wpSummary' ).val; if ( text !== newText && !/hlist/.test( summaryText ) ) { $( '#wpSummary' ).val( summaryText + ( /[^,; \/]$/.test( summaryText ) ? ', ' : '' ) +			'move to the standard list markup using a script'		); } }; window.toHlist;

} );