Jump to content

User:Gary/highlight my username in history.js

From Wikipedia, the free encyclopedia
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.
/*
	HIGHLIGHT MY USERNAME IN HISTORY
	Description: Highlights your username in history pages.
*/

$(function()
{
	if (mw.config.get('wgAction') !== 'history') return;
	
	mw.loader.using( ['mediawiki.util'], function () {
		// Added here instead of user's style.css so that it comes with the script.
		mw.util.addCSS('a.history-highlight { background-color: #D1DCFF; }');
		
		$('.mw-userlink').each(function()
		{
			var $this = $(this);
			if ($this.text() == mw.config.get('wgUserName'))
				$this.addClass('history-highlight');
		});
	});
});