Greasy Fork is available in English.

Video Speed Buttons

Add speed buttons to any HTML5 <video> element. Comes with a loader for YouTube and Vimeo

< Feedback on Video Speed Buttons

Question/comment

§
Posted: 26. 03. 2024

I encountered some sites where the player would reset the speed automatically about one second after setting a new speed using this script:
while it doesn't perfectly, i added this code to ensure persistence, in the ev_keyboard function, just before the return part.:

---- start of existing code
setPlaybackRate(video_el, DEFAULT_SPEED);
anchor.insertBefore(container, anchor.firstChild);
document.body.addEventListener("keydown", ev_keyboard);
---- end of existing code
---- new code
setInterval(() => {
if(video_el && video_el.playbackRate !== buttons.selected.speed) {
video_el.playbackRate = buttons.selected.speed;
}
}, 250);
---- end of new code
(return code below)

Dunno if anyone can improve on that, but probably you can. thanks

Braden BestAuthor
§
Posted: 31. 05. 2024

What I ended up doing was change the speed changing function to edit a data structure containing a reference to the video element and the current speed. An independent loop called the "enforcer" then uses this data structure to update the video speed on an interval (currently 500ms).

It's not perfect. Sometimes on youtube, the loop will just break (I suspect youtube is replacing the video element with a new one). However, this only happens after the page has been open for a long time. A lot of things on youtube break over this (it's a shockingly unstable UI), and the solution is to simply refresh the page.

This script is over-engineered anyway. I could have accomplished the buttons using a simple array instead of a linked list, for example. I'm considering doing a more extensive update in the future, but I don't have the time for it now. For now, it works and is not annoying to use.

Post reply

Sign in to post a reply.