Last active
March 13, 2023 10:55
-
-
Save aquilax/ab0f53869a9702311d6918907b17b932 to your computer and use it in GitHub Desktop.
Uses `<` and `>` to change the playback speed (defaults to 1.5x)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
((_w) => { | |
const _d = _w.document; | |
if (!_d.querySelector('#speeder')) { | |
const getSpeed = s => s/10 | |
let speed = 15; | |
let speedEl = document.createElement("span"); | |
speedEl.id = 'speeder'; | |
speedEl.innerText = ` ${getSpeed(speed)}x`; | |
_d.querySelector('#channel-link > span').appendChild(speedEl); | |
_d.querySelectorAll('video').forEach(v => v.playbackRate = getSpeed(speed)); | |
_w.addEventListener('keydown', (e) => { | |
const {key} = e; | |
if( ['<', '>'].includes(key)) { | |
if (key === '<') speed -= 1; | |
if (key === '>') speed += 1; | |
speedEl.innerText = ` ${getSpeed(speed)}x`; | |
_d.querySelectorAll('video').forEach(v => v.playbackRate = getSpeed(speed)) | |
} | |
}) | |
} | |
})(window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment