你正在訪問的內容是外部程式的映像位址,僅用於使用者加速訪問,本站無法保證其可靠性。當前的連結位址(單點即可複製)為 https://greasyfork.org.cn/zh-CN/scripts/527825-github-creation-date/discussions/304394,源站連結 點此以跳轉。
Displays the creation date of a GitHub repository when clicked.
Do you have a Github repository for contributions? I prefer this version that displays the creation date automatically without needing a click:
(function () { "use strict"; const fetchRepoInfo = async (owner, repo) => { const apiUrl = `https://api.github.com/repos/${owner}/${repo}`; const response = await fetch(apiUrl, { headers: { Accept: "application/vnd.github.v3+json" }, }); if (!response.ok) { throw new Error(`Failed to fetch repository info (Status: ${response.status})`); } return response.json(); }; const insertCreationDate = async () => { const [, owner, repo] = window.location.pathname.split("/"); // Exclude paths that are not main repo pages if (!owner || !repo || repo.includes('.')) return; try { const repoInfo = await fetchRepoInfo(owner, repo); const createdAt = new Date(repoInfo.created_at).toLocaleString(); const repoTitleComponent = document.querySelector('div[id="repo-title-component"]'); if (repoTitleComponent) { const dateElement = document.createElement("span"); dateElement.textContent = ` • Created: ${createdAt}`; dateElement.style.fontSize = "12px"; dateElement.style.marginLeft = "8px"; dateElement.style.color = "#57606a"; repoTitleComponent.appendChild(dateElement); } } catch (error) { console.error("Error fetching creation date:", error); } }; insertCreationDate(); })();
This is great
https://github.com/maanimis
Do you have a Github repository for contributions? I prefer this version that displays the creation date automatically without needing a click: