AWS Cloudwatch Timeago

Show timeago in AWS CloudWatch Last Event Time

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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         AWS Cloudwatch Timeago
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  Show timeago in AWS CloudWatch Last Event Time
// @author       himalay
// @match        https://*.console.aws.amazon.com/cloudwatch/home*
// @grant        none
// ==/UserScript==

(function () {
    var waitInterval = setInterval(function () {
        var tBody = document.querySelector("#gwt-debug-dataTable tbody");
        if (tBody) {
            clearInterval(waitInterval);
            var observer = new MutationObserver(function (mutations) {
                mutations.forEach(function (mutation) {
                    if (!mutation.addedNodes) return;

                    mutation.addedNodes.forEach(function (node) {
                        var el = node.querySelector(".GIYU-ANBMNB > div");
                        if (el) {
                            var dateText = el.textContent.trim();
                            if (dateText) {
                                var timeAgo = ago(new Date(dateText).getTime());
                                el.innerHTML += ` (${timeAgo})`;
                            }
                        }
                    });
                });
            });

            observer.observe(tBody, {
                childList: true,
                subtree: false,
                attributes: false,
                characterData: false,
            });
        }
    }, 100);

    function ago(v){v=0|(Date.now()-v)/1e3;var a,b={second:60,minute:60,hour:24,day:7,week:4.35,month:12,year:1e4},c;for(a in b){c=v%b[a];if(!(v=0|v/b[a]))return c+' '+(c-1?a+'s':a)}}
})();