Greasy Fork is available in English.

GitHub Profile Time Converter

Convert GitHub profile local time from 24-hour format (e.g. “00:00”) to the 12-hour AM/PM style.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         GitHub Profile Time Converter
// @namespace    https://github.com/GooglyBlox
// @version      1.1
// @description  Convert GitHub profile local time from 24-hour format (e.g. “00:00”) to the 12-hour AM/PM style.
// @author       GooglyBlox
// @match        https://github.com/*
// @match        https://gist.github.com/*
// @grant        none
// @run-at       document-end
// @license      MIT
// ==/UserScript==

(function () {
  'use strict';

  function convertTo12Hour(timeStr) {
    const parts = timeStr.split(':');
    if (parts.length !== 2) return timeStr;
    let hours = parseInt(parts[0], 10);
    const minutes = parts[1];
    const suffix = hours >= 12 ? 'PM' : 'AM';
    hours = hours % 12;
    if (hours === 0) hours = 12;
    return hours + ':' + minutes + ' ' + suffix;
  }

  function updateLocalTime() {
    const localTimeItem = document.querySelector('li[itemprop="localTime"]');
    if (!localTimeItem) return;

    const labelEl = localTimeItem.querySelector('.p-label');
    if (!labelEl || !labelEl.firstChild) return;

    if (labelEl.textContent.match(/\b(AM|PM)\b/)) return;

    const timeRegex = /(\d{2}:\d{2})/;
    const originalText = labelEl.firstChild.textContent;
    const match = originalText.match(timeRegex);
    if (!match) return;

    const originalTime = match[1];
    const convertedTime = convertTo12Hour(originalTime);

    labelEl.firstChild.textContent = originalText.replace(originalTime, convertedTime);
  }

  updateLocalTime();

  const observer = new MutationObserver((mutations) => {
    mutations.forEach(() => {
      updateLocalTime();
    });
  });

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