Youtube Video's Published Date

Show YouTube video's publishing date, best to have these 2 uBlock origin filters "www.youtube.com##span.yt-formatted-string.style-scope.bold:nth-of-type(3)" & "www.youtube.com###owner-sub-count"

目前為 2025-05-01 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Youtube Video's Published Date
// @namespace    https://tampermonkey.net/
// @version      1.0
// @description  Show YouTube video's publishing date, best to have these 2 uBlock origin filters "www.youtube.com##span.yt-formatted-string.style-scope.bold:nth-of-type(3)" & "www.youtube.com###owner-sub-count"
// @author       dpi0
// @include      *://*youtube.com/*
// @grant        none
// @homepageURL https://github.com/dpi0/scripts/blob/main/greasyfork/youtube-video-published-date.js
// @originalhomepageURL https://greasyfork.org/en/scripts/423791-youtube-videos-publishing-date
// @supportURL  https://github.com/dpi0/scripts/issues
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    const observer = new MutationObserver(() => {
        const infoStrings = document.querySelector('#info-strings');
        const subCount = document.querySelector('#owner-sub-count');
        if (infoStrings && subCount) {
            observer.disconnect();

            // Move the publishing date below the sub count
            infoStrings.remove();
            subCount.after(infoStrings);

            // Remove extra spans and apply styles
            infoStrings.querySelectorAll('span').forEach(e => e.remove());

            const isDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
            infoStrings.style.fontSize = '15px';
            infoStrings.style.fontWeight = '540';
            infoStrings.style.color = isDark ? '#f1f1f1' : '#0f0f0f';
        }
    });

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