Greasy Fork

来自缓存

Greasy Fork is available in English.

ShowMeWhen on NodeSeek

Display the exact create & edit time of posts on NodeSeek

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         ShowMeWhen on NodeSeek
// @license      AGPL-3.0
// @namespace    http://tampermonkey.net/
// @version      2025-06-23
// @description  Display the exact create & edit time of posts on NodeSeek
// @author       Casa
// @match        https://www.nodeseek.com/*
// @match        http://www.nodeseek.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const overrideStyle = document.createElement('style');
    overrideStyle.innerHTML = `
      .date-created time::after,
      .date-updated::after,
      .info-item.info-last-comment-time time::after {
         content: none !important;
      }
      .date-created time,
      .date-updated,
      .info-item.info-last-comment-time time {
         font-size: inherit !important;
         position: static !important;
      }
    `;
    document.head.appendChild(overrideStyle);

    function getAbsoluteTimeString(el) {
        return el.getAttribute('title') || el.getAttribute('datetime');
    }

    function parseTimeString(timeStr) {
        let isoString = timeStr.includes('T') ? timeStr : timeStr.replace(' ', 'T');
        return new Date(isoString);
    }

    function processTimeElement(el) {
        let rawStr = getAbsoluteTimeString(el);
        if (!rawStr) return;

        let timeForCompare = rawStr;
        if (el.classList.contains('date-updated')) {
            const regex = /(\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}(?::\d{2})?)/;
            const match = rawStr.match(regex);
            if (match) {
                timeForCompare = match[1];
            } else {
                return;
            }
        }

        const timeObj = parseTimeString(timeForCompare);
        if (isNaN(timeObj.getTime())) return;

        const todayStart = new Date();
        todayStart.setHours(0, 0, 0, 0);

        if (timeObj < todayStart) {
            el.textContent = rawStr;
            el.style.setProperty("font-size", "11px", "important");
            el.style.setProperty("color", "#858585", "important");
            el.style.setProperty("position", "relative", "important");
        }
    }

    function processAllTimeElements() {
        document.querySelectorAll('.date-created time').forEach(processTimeElement);
        document.querySelectorAll('.date-updated').forEach(processTimeElement);
        document.querySelectorAll('.info-item.info-last-comment-time time').forEach(processTimeElement);
    }

    if (document.readyState === "loading") {
        document.addEventListener("DOMContentLoaded", processAllTimeElements);
    } else {
        processAllTimeElements();
    }
})();