GitLab - show absolute timestamps

Replaces relative GitLab timestamps with their full title

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         GitLab - show absolute timestamps
// @namespace    https://gitlab.com/
// @version      1.0
// @description  Replaces relative GitLab timestamps with their full title
// @match        https://gitlab.com/*
// @grant        none
// @license      CC0-1.0
// ==/UserScript==
(function () {
    'use strict';

    function replaceTimes(root = document) {
        root.querySelectorAll('time[title]').forEach(time => {
            const title = time.getAttribute('title');

            if (title && time.textContent !== title) {
                time.textContent = title;
            }
        });
    }

    // Elementy obecne przy załadowaniu strony
    replaceTimes();

    // Elementy dodawane dynamicznie przez GitLaba
    const observer = new MutationObserver(mutations => {
        for (const mutation of mutations) {
            for (const node of mutation.addedNodes) {
                if (node.nodeType !== Node.ELEMENT_NODE) {
                    continue;
                }

                if (node.matches && node.matches('time[title]')) {
                    node.textContent = node.getAttribute('title');
                }

                replaceTimes(node);
            }
        }
    });

    observer.observe(document.body, {
        childList: true,
        subtree: true
    });
})();