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' + } +);