Last active
April 25, 2025 03:29
-
-
Save HPZ07/26ae9f23bec793144f26d9deb6d932a5 to your computer and use it in GitHub Desktop.
Disable YouTube Spacebar Scrolling
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
// ==UserScript== | |
// @name Disable YouTube spacebar scrolling | |
// @namespace http://tampermonkey.net/ | |
// @version 0.2 | |
// @description Disables spacebar scrolling and forces it to pause the video instead | |
// @author HPZ07 | |
// @match https://www.youtube.com/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
window.addEventListener('keydown', function(e) { | |
if (e.keyCode === 32 && e.target === document.body && isWatchPage()) { | |
e.preventDefault(); | |
var video = document.querySelector('video.html5-main-video'); | |
if (video.currentTime > 0 && !video.paused && !video.ended) { | |
video.play(); | |
} else { | |
video.pause(); | |
} | |
} | |
}); | |
function isWatchPage() { | |
return /^\/watch/.test(location.pathname); | |
} | |
})(); |
AMAZING! ๐
Thank you ๐
I don't suppose a TikTok variant to stop comment typing from scrolling would be similar? Any chance you'd be willing to give it a try?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This should resolve the Alt-Tab issue.
Fix YouTube's Alt-Tab Pause/Play Issue
@f4T1H21
@alexwh Thanks for the suggestion.