From 6364c65127e564deb303e0f8995cace8e39a0aa4 Mon Sep 17 00:00:00 2001 From: Niki Wix Skaarup Date: Sat, 3 May 2025 02:06:28 +0200 Subject: [PATCH] added youtube playback rate --- src/routes/index.html | 14 ++++- .../userscripts/youtube/youtube.user.ts | 54 +++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 src/server/userscripts/youtube/youtube.user.ts diff --git a/src/routes/index.html b/src/routes/index.html index 5a587d5..62e6afb 100644 --- a/src/routes/index.html +++ b/src/routes/index.html @@ -25,7 +25,8 @@ Userscripts + >Userscripts
@@ -100,6 +101,17 @@ > updated via hotkeys +
  • + Youtube playbackRate + - Add buttons to increase/decrease the playback rate of youtube videos in the + userscript extension +
  • diff --git a/src/server/userscripts/youtube/youtube.user.ts b/src/server/userscripts/youtube/youtube.user.ts new file mode 100644 index 0000000..1d0fece --- /dev/null +++ b/src/server/userscripts/youtube/youtube.user.ts @@ -0,0 +1,54 @@ +// ==UserScript== +// @name youtube.com +// @namespace https://userscripts.skaarup.dev +// @match https://www.youtube.com/watch* +// @version 1.0 +// @author nws +// @description youtube video playback rate changer +// @updateURL https://userscripts.skaarup.dev/scripts/youtube.user.js +// @downloadURL https://userscripts.skaarup.dev/scripts/youtube.user.js +// @grant none +// @grant GM_registerMenuCommand +// ==/UserScript== + +GM_registerMenuCommand( + 'PlaybackRate Up', + (event) => { + const videos = Array.from(document.querySelectorAll('video')); + + for (const video of videos) { + if (video.paused) continue; + + const currentPlaybackRate = video.playbackRate; + + video.playbackRate = currentPlaybackRate + 0.5; + + console.log(`PlaybackRate changed from ${currentPlaybackRate} to ${video.playbackRate}`); + } + }, + { + title: 'increase video playbackRate by 0.5' + } +); + +GM_registerMenuCommand( + 'PlaybackRate Down', + (event) => { + const videos = Array.from(document.querySelectorAll('video')); + + for (const video of videos) { + if (video.paused) continue; + + const currentPlaybackRate = video.playbackRate; + + if (currentPlaybackRate < 0.5) continue; + + video.playbackRate = currentPlaybackRate - 0.5; + + console.log(`PlaybackRate changed from ${currentPlaybackRate} to ${video.playbackRate}`); + } + }, + { + title: 'decrease video playbackRate by 0.5' + } +);