GitHub commit timestamps

Displays absolute time for commits (if less than 18 hours ago)

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name        GitHub commit timestamps
// @namespace   http://rasmuswriedtlarsen.com
// @version     0.3
// @description Displays absolute time for commits (if less than 18 hours ago)
// @match       https://github.com/*
// @copyright   2014, Rasmus Wriedt Larsen
// @require     https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
// @require     https://cdnjs.cloudflare.com/ajax/libs/sugar/1.3.9/sugar.min.js
// ==/UserScript==

var msPrHour = 60 * 60 * 1000;

counter = 0

var updateTimes = function(event) {
    //console.log(counter++)

    $("time.js-relative-date").each( function () {
        var commitTime = new Date ($(this).attr("datetime"));
        var diff = (Date.now() - commitTime);

        newTitle = commitTime.format("{yyyy}-{MM}-{dd} {HH}:{mm}:{ss}")

        if ( diff < 18 * msPrHour)
        {
            var formattedTime = commitTime.format("{HH}:{mm}")

            $(this).html(formattedTime);
            $(this).removeClass("js-relative-date");
        }

        $(this).attr("title", newTitle)
    });
};

// setInterval( function(){$('time').change();}, 5 * 1000 );

// $('time').change();

function init()
{
  // Make sure this is really an HTML page, as Chrome runs these scripts on just about everything
  if (!(document.documentElement instanceof HTMLElement))
    return;

  updateTimes(null);
  // TODO: very hacky solution to updating when page reloads ...
  document.addEventListener("DOMNodeInserted", updateTimes, true);
}

// In Chrome 18 the document might not be initialized yet
if (document.documentElement)
  init();
else
  window.setTimeout(init, 0);