User:Eissink/watchlist-update-title.js

/** * Updates the document title when the watchlist undergoes a live update * Should work on any wiki. * Per request by Jürgen Eissink * * Watchlist - Wikipedia * (1) Watchlist - Wikipedia    // after first update * * The title is reset when the window comes into focus. * */

if (mw.config.get('wgCanonicalSpecialPageName') === 'Watchlist') { var watchlistUpdateNumber = null; var watchlistHeading = document.title; mw.hook('wikipage.content').add(function {		if ( watchlistUpdateNumber === null ) { // prevent action immediately after hook is added		   watchlistUpdateNumber = 0;		    return;		}		watchlistUpdateNumber += 0.5;		document.title = '(' + watchlistUpdateNumber + ') ' + watchlistHeading;	}); $(window).focus(function {		watchlistUpdateNumber = 0;		document.title = watchlistHeading;	}); }