Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
function edit(){

function editPages( info ) {
	$.ajax({
		url: mw.util.wikiScript( 'api' ),
		type: 'POST',
		dataType: 'json',
		data: {
			format: 'json',
			action: 'edit',
			title: info.title,
			text: info.text, 
			summary: info.summary,
			token: mw.user.tokens.get( 'editToken' )
		}
	})
	
	
	.done (function( data ) {
		if ( data && data.edit && data.edit.result && data.edit.result == 'Success' ) {
//	mw.notify( 'Updated' );
//		mw.notify( 'Re updating in 1 min' );
		setTimeout('edit()',10);
		} else {
			alert( 'Stopped, restart please.' );
		}
	})
	.fail ( function() {
			alert( 'Stopped, restart please.' );
	});
}
var count= Math.floor((Math.random() * 10) + 1);
		editPages({
	title: wgPageName,
	text: "{{"+"subst:Currentdate"+"}}<span style='display:none'>"+count+"</span>",
	summary: 'Updating time using script'
});
	}



addOnloadHook(function() {

	 if (document.editform) {

     mw.util.addPortletLink("p-cactions", "javascript:edits()", "run");
	 }
});
function edits(){

	if (confirm('Replace whole content with current date and time?')){
		edit();
}}