User:MZMcBride/global.js

From Meta, a Wikimedia project coordination wiki

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.
/* Live UTC clock (with purge link Easter egg) */
mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:MZMcBride/liveclock.js&action=raw&ctype=text/javascript');

/* Add a "null edit" link to the toolbox in the sidebar */
mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:MZMcBride/nulledit.js&action=raw&ctype=text/javascript');

/* Make user groups more obvious when viewing user pages */
mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Splarka/sysopdectector.js&action=raw&ctype=text/javascript');

/* Make the personal tools narrower */
jQuery( function( $ ) {
	$("li#pt-userpage a").text('me');
	$("li#pt-mytalk a").text('Talk');
	$("li#pt-preferences a").text('Prefs');
	$("li#pt-watchlist a").text('Watchlist');
	$("li#pt-newmessages a").text('Noise');
	$("li#pt-mycontris a").text('Contribs');
	$("li#pt-logout a").text('Die');
} );

/* Make the "last modified" text a bit narrower */
if ($("li#lastmod").text()) {
  var lastmodtext = $("li#lastmod").text();
  var cleanlastmodtext = lastmodtext.replace(/This page was last edited on (.+?),? at (.+?)(\s\(UTC\))?\./, '$2, $1');
  $("li#lastmod").html('<a href="'+mw.config.get( 'wgServer' ) +'">'+cleanlastmodtext+'</a>');
} else if (!$("li#lastmod").text()) {
  $("ul#f-list").prepend('<li id="lastmod"><a href="'+mw.config.get( 'wgServer' ) +'">'+'main page'+'</a></li>');
}

/* Set skin to MonoBook */
mw.loader.using("mediawiki.user", function() {
	if ( mw.user.options.get('skin') !== 'monobook' && mw.user.options.get('skin') !== 'timeless' ) {
		( new mw.Api() ).postWithToken( 'options', {
			action: "options",
			change: "skin=monobook"
		} ).done( function() {
			mw.loader.using([], function(){
				mw.notify( "Skin has been changed to MonoBook. Please refresh the page." );
			} );
		} );
	}
} );

/* Comment links */
mw.loader.load('https://meta.wikimedia.org/w/index.php?title=User:ESanders_(WMF)/commentlinks.js&action=raw&ctype=text/javascript');