AWS Cloudwatch Timeago

Show timeago in AWS CloudWatch Last Event Time

Versione datata 14/04/2020. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==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)}}
})();