User:Zzuuzz/scripts/badimagelist.js

// Sorts the list and highlights any redirects at MediaWiki:Bad image list

function sortBIL { var box = $('#wpTextbox1'); var content = box.val; var start = content.indexOf('*'); var prepend = content.substr(0, start); var items = content.substr(start).split(/\*/); box.val(prepend + items.sort(sortBIL2).join('*')); }

function sortBIL2(a, b) { return a.replace(/\./g, "\t").localeCompare(b.replace(/\./g, "\t")); }

$(document).ready(function {	if( mw.config.get('wgPageName') === 'MediaWiki:Bad_image_list' ) {		$('.mw-redirect').css( {'background-color': 'yellow', 'font-weight': 'bold'} );		if ( 'edit' === mw.config.get( 'wgAction' ) || 'submit' === mw.config.get( 'wgAction' ) ) {			mw.util.addPortletLink('p-cactions', 'javascript:sortBIL', 'Sort');		}	} });