以绝对时间显示 YouTube 的视频上传日期 (yyyy-mm-dd 或其他自定义格式)

显示具体日期而不是“2 星期前”,“1 年前”这种相对日期。可自定义日期和时间格式。

< 脚本 以绝对时间显示 YouTube 的视频上传日期 (yyyy-mm-dd 或其他自定义格式) 的反馈

提问 / 留言

§
发布于:2025-08-31

The script is not working (31/08/2025)
YouTube might have made some changes on their website, so the script is currently broken.

§
发布于:2025-09-01

Yes, I see the same problem.

Just like last time YouTube broke it, it is fine in "List view". But not in "Grid view" (for me on the Subscriptions page)

InMirrors作者
§
发布于:2025-09-07

Mostly fixed, there are still some minor issues, but it's usable.

§
发布于:2025-09-07

Thankyou so much, @InMirrors!

§
发布于:2025-09-08

Unfortunately it is not working for me on the Subscriptions page.

InMirrors作者
§
发布于:2025-09-09

It works in grid view. For list view, modify the config to the following:

            {
                id: 'Subscriptions',
                urlPattern: /subscriptions/,
                videoContainerSelector: '#dismissible.ytd-shelf-renderer',
                metaSpansSelector: '#metadata-line > span',
                vidLinkSelector: 'h3 > a',
                shouldCreateDateSpan: false,
            },
§
发布于:2025-09-09

That's strange. It's grid view that isn't working for me! still not working sorry.

looks like it is only videoContainerSelector that changes?

InMirrors作者
§
发布于:2025-09-09

Yes, only videoContainerSelector is different. Try the following.

videoContainerSelector: '#dismissible.ytd-rich-grid-media',
// or the less accurate one
videoContainerSelector: '#dismissible',

If it doesn't work, disable other scripts and extensions and try again.

§
发布于:2025-09-09

Thanks, I've already got other extensions off while trying to get it working.
with debug mode on: (and I put a prefix in the console logging otherwise it's very hard to find the logged errors in amoungst everything else!)

videoContainerSelector: 'ytd-rich-grid-media.ytd-rich-item-renderer', // this doesn't have any warnings, but it doesn't change the page

videoContainerSelector: '#dismissible.ytd-shelf-renderer', // warnings in console: AbsDates: No metaSpan found for [Subscriptions]

videoContainerSelector: '#dismissible.ytd-rich-grid-media', // no error, but doesn't work

videoContainerSelector: '#dismissible', // warnings in console: AbsDates: No metaSpan found for [Subscriptions]

Another greasyfork I use, which I have temporarily turned off, is https://github.com/EvHaus/youtube-hide-watched
It has had the same problem of constantly trying to keep up with YouTube.

In that one, it has to try 4 different selectors
(
item.closest('.ytd-grid-renderer') ||
item.closest('.ytd-item-section-renderer') ||
item.closest('.ytd-rich-grid-row') ||
item.closest('.ytd-rich-grid-renderer') ||
)

I tried a search in the DOM of all 4 when I had the subscriptions page loaded. The only one which matched was 'ytd-rich-grid-renderer', so I also tried:

videoContainerSelector: 'ytd-rich-grid-renderer',

The result was the console warning No metaSpan found for [Subscriptions] as before.

HTH

InMirrors作者
§
发布于:2025-09-09

To find the appropriate selector, you should:

  1. Right-click on the video title, click "Inspect" and the dev panel will locate the specific element.
  2. Search upwards in the element tree for an element that includes the video's cover and title but excludes other videos. There may be multiple such elements; any one of them will work.
  3. Enter document.querySelectorAll('your-selector') in the console. You can preview the selected content without pressing Enter. The correct selector on my end selects 100 elements. Your test results may vary, but they shouldn't be too far off. If it's not suitable, try a different selector.
  4. Press Enter to execute the statement. The selected elements will appear in the console. Click to expand the return results and hover your mouse over different elements to see if one element corresponds to one video.
  5. After verifying that it's correct, fill in videoContainerSelector. If everything is normal, you shouldn't need to modify the other selectors in the configuration.

Future script updates will optimize the handling of metaSpan. If you encounter issues at this step, it is recommended to wait for subsequent updates.

This has happened before, you reported issues on the subscriptions page but it tested fine on my end. I'm not sure why. If YouTube provides different page structures to different users, you may have to modify the script yourself to adapt to your YouTube page.

InMirrors作者
§
发布于:2025-09-09

If the two selectors I provided earlier pass the test according to the steps above, then the problem is likely not with videoContainerSelector. I suggest waiting for an update.

§
发布于:2025-09-20

Thank you @InMirrors
The script is now working properly.

§
发布于:2025-09-20

Thankyou very much @InMirrors ! The new version 0.6 is working for me too, including on the Subscriptions page :)

发布留言

登录以发布留言。