MediaWiki:PrivateMessageAlert/code.js

( function {   var original = document.title;    var timeout;

window.blinkTitle = function(newMsg) {

function step { document.title = ( document.title == original ) ? newMsg : original; timeout = setTimeout(step, 1000); }

cancelBlinkTitle(timeout); step; };   window.cancelBlinkTitle = function { clearTimeout(timeout); document.title = original; }; } ); $(function { if ( mw.config.get( 'wgCanonicalSpecialPageName' ) == 'Chat' ) {

$( '#PrivateChatList' ).bind("DOMSubtreeModified", function {

if ( !document.hasFocus ) {

var usr = $( ".PrivateChatList .User" ).has( ".splotch" ).attr( "data-user" ); blinkTitle("New Message from " + usr + "!"); }       });    } }); window.onfocus = function { cancelBlinkTitle; };