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.
$.when(mw.loader.using(['mediawiki.util', 'mediawiki.api']), $.ready).done(function() {
	var href = mw.config.get( 'wgServer' ) + mw.config.get( 'wgScript' )
	href = href + "?title="+mw.util.wikiUrlencode(mw.config.get('wgPageName'))+"&action=purge";
	$("a[href='"+href+"']").on( 'click', function (e) {
		new mw.Api().post( { action: 'purge', titles: mw.config.get( 'wgPageName' ) } ).then(function () {
			location.reload();
		}, function () {
			mw.notify( 'Purge failed', { type: 'error' } );
		});
		e.preventDefault();
	});
});