User:UBX/edit-rate.js

$(function {	// test if user is seeing their own user page.	// only the current uuser's edit count is available through mw.config	// but it's possible to get other users' data as well;	// see User:PleaseStand/userinfo.js and User:UBX/LiveEditCounter.js for example	if( mw.config.get('wgPageName').indexOf('User:' + mw.config.get('wgUserName')) == 0 ) {		// Get values		var edits = mw.config.get('wgUserEditCount');		var date = $('#edit-rate-regdate').text;		var now = new Date;		var reg = new Date( date );		// Make calculations		var diff = Math.abs(now.getTime - reg.getTime);		var hours = Math.ceil(diff / (1000 * 60 * 60)); // http://stackoverflow.com/a/3224854/266309		var rate = Math.round((hours / edits) * 10) / 10; // http://stackoverflow.com/a/11832950/266309		// Show result		$('#edit-rate').text( rate );	} });