Github remove relative date stupidness

Removes relative date stamps on Github commits, and shows actual date/time created.

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        Github remove relative date stupidness
// @description Removes relative date stamps on Github commits, and shows actual date/time created.
// @namespace   http://www.wilcoxd.com
// @include     https://github.com*
// @version     1
// @grant       none
// ==/UserScript==

// created: WD-rpw 03-25-2013

/*
	if you don't like this there are two other Greasemonkey scripts that do the
	same thing, although in a more complicated way:

	  1. http://userscripts.org/scripts/show/107649
	  2. http://userscripts.org/scripts/show/107649

*/

(function() {

	function parseDate(date) {
    	var m = /^(\d{4})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)Z/.exec(date);
    	var tzOffset = new Date(+m[1], +m[2] - 1, +m[3], +m[4], +m[5], +m[6]).getTimezoneOffset();

    	return new Date(+m[1], +m[2] - 1, +m[3], +m[4], +m[5] - tzOffset, +m[6]);
	}
	function format(el) {
		$el = $(el);
		$el.removeAttr("is");
		var time = $el.attr('title')||$el.attr("datetime");
		var formatted = time + " UTC";
		var dateObj = parseDate(formatted);

		if (dateObj)
			formatted = dateObj.toLocaleString();

		$el.html( formatted );
	}

	function onDOMSubtreeModifiedHandler(e){
		var target = e.target;
		if(target.nodeType === 1 && /TIME/ig.test(target.nodeName)&&/ago/.test(target.innerHTML)) {
			format(target);
		}
	}
	$("time[is='relative-time']").each( function(index, el) {
		format(el);
	});

	document.addEventListener('DOMSubtreeModified', onDOMSubtreeModifiedHandler, false);
})();