added youtube playback rate
This commit is contained in:
parent
7dd96ac108
commit
6364c65127
2 changed files with 67 additions and 1 deletions
|
@ -25,7 +25,8 @@
|
|||
<a
|
||||
href="/"
|
||||
class="block text-center underline decoration-transparent transition-colors hover:decoration-pink-600"
|
||||
>Userscripts</a>
|
||||
>Userscripts</a
|
||||
>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-end gap-2 py-2 md:gap-4">
|
||||
|
@ -100,6 +101,17 @@
|
|||
>
|
||||
updated via hotkeys
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="/scripts/youtube.user.js"
|
||||
class="underline decoration-indigo-500 transition-colors hover:decoration-pink-600"
|
||||
target="_blank"
|
||||
referrerpolicy="no-referrer"
|
||||
>Youtube playbackRate</a
|
||||
>
|
||||
- Add buttons to increase/decrease the playback rate of youtube videos in the
|
||||
userscript extension
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
</article>
|
||||
|
|
54
src/server/userscripts/youtube/youtube.user.ts
Normal file
54
src/server/userscripts/youtube/youtube.user.ts
Normal file
|
@ -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'
|
||||
}
|
||||
);
|
Loading…
Add table
Add a link
Reference in a new issue