User:Mmullie (WMF)/MarkAllRead.js

var count = parseInt( $( '.mw-echo-notifications-badge' ).text ), api = new mw.Api;

if ( count && confirm( 'Mark all notifications as read?' ) ) { api.postWithEditToken( mw.echo.desktop.appendUseLang( { 'action' : 'echomarkread', 'all' : true } ) ).done( function ( result ) {		mw.echo.overlay.updateCount( result.query.echomarkread.count, result.query.echomarkread.rawcount );		alert( 'All notifications marked as read' );	} ); }