User:Jack Phoenix/monobook.js

From translatewiki.net

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
$( function() {
	if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Translate' ) {
		/**
		 * Show the _full_, untruncated message (well, wiki page if we're being exact)
		 * name on Special:Translate, i.e. MediaWiki:Some_message/fi instead of
		 * ...ssage/fi
		 */
		$( 'tr td > a[title^="Edit"]' ).each( function( index ) {
			var foo = $( this ).attr( 'title' ).replace( /Edit \"/, '' );
			foo = foo.replace( /\"/, '' );
			$( this ).text( foo );
		} );
	} // if Special:Translate

	// Changes links on Special:Translations to point to regular wikitext editor (?action=edit)
	// instead of Special:Translate
	// Probably atrocious performance-wise, but oh well...
	if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Translations' ) {
		$( '.mw-sp-translate-table tr.mw-sp-translate-fuzzy td a' ).each( function ( i ) {
			if ( !$( this ).attr( 'title' ) ) {
				var url = $( this ).attr( 'href' ).
					replace(
						/Special\:Translate\&showMessage=/,
						'MediaWiki:'
					).
					replace( /\&group=(.*)\&/, '').
					replace( /\language=/, '/' );
				url += '&action=edit';
				// Set it
				$( this ).attr( 'href', url );
			}
		} ); 
	}
} );