Smooth YouTube livestream

5/11/2025, 9:27:12 PM

Author
𝖢𝖸 𝖥𝗎𝗇𝗀
Daily installs
1
Total installs
2
Ratings
0 0 0
Version
0.1.3
Created
2025-05-11
Updated
2025-05-11
Size
4.36 KB
License
MIT
Applies to

This userscript is designed to improve the smoothness of YouTube livestreams. Here's what it does:

  1. Trigger: It listens for the canplay event, which fires when a media element (like a video) is ready to play.
  2. Check if it's a livestream: It checks whether the element with class .ytp-live-badge.ytp-live-badge-is-livehead is present. This badge indicates a live stream.
  3. Target media elements: If a media element (like a video) is part of YouTube's player and is playing at normal speed (playbackRate === 1), it temporarily changes the playback speed to 0.968.
  4. Revert after 30 seconds: After 30 seconds, it sets the playback rate back to 1.0.

🧠 Purpose: Slightly slowing down a live stream for a short time helps buffer and can make the stream smoother, especially if you're falling slightly behind due to latency or network issues.


这个用户脚本是为了改善 YouTube 直播流的流畅度而设计的。其工作原理如下:

  1. 事件监听:监听 canplay 事件(当媒体元素准备好播放时触发)。
  2. 判断是否为直播:检查页面上是否存在 .ytp-live-badge.ytp-live-badge-is-livehead 元素(这是直播标志)。
  3. 处理媒体元素:如果检测到是 YouTube 播放器中的视频并且播放速度是正常(1.0),就将播放速度短暂设置为 0.968
  4. 30秒后恢复:30秒后再将播放速度恢复为 1.0

🧠 目的:这种微调播放速度的方式可以帮助视频稍微“追上”直播的实时进度,从而提升观看流畅度,特别是在出现网络延迟或缓冲时。