Jump to content

User:Grutness/common.js

From Wikipedia, the free encyclopedia
This is the current revision of this page, as edited by Grutness (talk | contribs) at 12:41, 27 May 2016. The present address (URL) is a permanent link to this version.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
importScript("User:Writ Keeper/Scripts/orangeBar.js");

if ( mw.config.values.wgCanonicalSpecialPageName === 'Whatlinkshere' ) {
	$( function() {
		'use strict';
		var ul = $( '#mw-whatlinkshere-list' );
		ul.before( '<button id="whatlinksheresort">Sort</button>' );
		$( '#whatlinksheresort' ).click( function() {
			var li = ul.children( 'li' );
			li.detach().sort( function( a, b ) {
				return $( a ).find( 'a' ).first().text().localeCompare( $( b ).find( 'a' ).first().text() );
			} );
			ul.append( li );
		} );
	} );
}