GitHub Repo Creation Date

Display creation date of repositories on GitHub

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

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 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         GitHub Repo Creation Date
// @namespace    npm/vite-plugin-monkey
// @version      0.1.1
// @author       pacexy <[email protected]>
// @description  Display creation date of repositories on GitHub
// @license      MIT
// @icon         https://github.com/favicon.ico
// @homepage     https://github.com/pacexy/userscript-github-repo-creation-date#readme
// @homepageURL  https://github.com/pacexy/userscript-github-repo-creation-date#readme
// @source       https://github.com/pacexy/userscript-github-repo-creation-date.git
// @supportURL   https://github.com/pacexy/userscript-github-repo-creation-date/issues
// @match        https://github.com/*/*
// ==/UserScript==

(function () {
  'use strict';

  const name = "userscript-github-repo-creation-date";
  async function fetchRepo(owner, name2) {
    const response = await fetch(`https://ungh.cc/repos/${owner}/${name2}`);
    return response.json();
  }
  function parseCurrentPath() {
    const [, owner, name2] = window.location.pathname.split("/");
    if (!owner || !name2) {
      throw new Error("Invalid URL format");
    }
    return { owner, name: name2 };
  }
  function formatDate(date, format = "short") {
    const d = new Date(date);
    return d.toLocaleDateString("en-US", {
      year: "numeric",
      month: format,
      day: format === "long" ? "numeric" : void 0
    });
  }
  function inject(date) {
    const container = document.createElement("span");
    container.id = name;
    container.title = `Created on ${formatDate(date, "long")}`;
    container.textContent = `(${formatDate(date)})`;
    container.style.color = "var(--fgColor-disabled)";
    container.style.marginLeft = "8px";
    const root = document.querySelector(".Layout-sidebar h2");
    if (!root) {
      throw new Error("Root element not found");
    }
    root.append(container);
  }
  async function run() {
    const { owner, name: name2 } = parseCurrentPath();
    const { repo } = await fetchRepo(owner, name2);
    inject(repo.createdAt);
  }
  run();

})();