polywock / globalSpeed

Web extension to set a default speed for video and audio
https://chrome.google.com/webstore/detail/global-speed-youtube-netf/jpbjcnkcffbooppibceonlgknpkniiff?hl=en
1.67k stars 192 forks source link

Query (no problem) #574

Open PepeParada opened 1 month ago

PepeParada commented 1 month ago

Hi. I have a specific question. First, the extension is great and works great for me. It makes my life easier.

That said, my question: will it be possible to use URL Rules for Youtube, and differentiate a regular video from a live? I don't know if there is a way to identify a live and a video from the url.

I was thinking about it because in my youtube vanced app (on android), it allows you to set a speed of 1.50x (example) for videos, and another speed (normal) for lives. Which is good because if you enter a live, it will not be set to a fast speed by default. It occurred to me that maybe something like this can be done on PC with Global Speed. `` thanks!

p.s.: ah, i usually use yt dlp and i know there is a way to differentiate lives from videos on youtube. but maybe it's just for that function.

polywock commented 1 month ago

Hello. Not possible to determine if it's live from the URL, but you can determine it from the page structure.

You can create a javascript URL rule that changes speed to 1x if a video is live, or 2x speed if not.

video = null 
setInterval(() => {
    video = document.querySelector("video.html5-main-video")
}, 5000)

setInterval(() => {
     video = video ?? document.querySelector("video.html5-main-video")
     if (!video) return 
     const isLive = document.querySelector(".ytp-live .ytp-live-badge.ytp-button[disabled]")
     video.playbackRate = isLive ? 1 : 2
}, 500)

However this won't work because Global Speed is aggressive. You also need to create another URL rule that turns off Global Speed if the URL contains "youtube.com".

https://github.com/user-attachments/assets/ef73c7b3-5367-44f2-b0eb-be8549f261d6