User:MSchottlender-WMF/GadgetEchoMarkAllRead.js

/** * Experimental! This gadget will mark all notifications as read when the popup opens. * Currently set to only mark 'alerts' as read. * * Depends on merging and deploying https://gerrit.wikimedia.org/r/#/c/312940/ */ $(function {	mw.hook( 'ext.echo.popup.onInitialize' ).add( function ( type, controller ) { if ( type === 'alert' ) { // If you copy this gadget, please keep this on; if errors occur, it is useful to see when and // how the gadget ran on the popup window.console.log( 'Gadget running: Marking all notifications of type "' + type + '" as read.' );

// Add pending animation for consistency $( '#pt-notifications-alert .oo-ui-popupWidget-head' ).addClass( 'oo-ui-pendingElement-pending' ); controller.markAllRead( 'local' ) .always( function {					// Remove pending aninmation					$( '#pt-notifications-alert .oo-ui-popupWidget-head' ).removeClass( 'oo-ui-pendingElement-pending' );				} ); }	} ); } );