Created
May 7, 2023 20:50
-
-
Save HPZ07/6ceae50e64fd280f6031366858a29aa4 to your computer and use it in GitHub Desktop.
Disable YouTube Shorts Spacebar Scrolling
This file contains 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 Shorts spacebar scrolling | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Disables YouTube Shorts scrolling and pauses video on spacebar press | |
// @author HPZ07 | |
// @match https://www.youtube.com/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
document.addEventListener('keydown', function(e) { | |
if(!isShortsPage()){ | |
return; | |
} | |
if (e.keyCode === 32 && document.activeElement.tagName !== 'INPUT' && document.activeElement.tagName !== 'TEXTAREA') { | |
e.preventDefault(); | |
var video = document.querySelector('video.html5-main-video'); | |
if (video !== null && !isNaN(video.duration)) { | |
if (video.paused) { | |
video.play(); | |
} else { | |
video.pause(); | |
} | |
} | |
} | |
}); | |
function isShortsPage() { | |
return /^\/shorts/.test(location.pathname); | |
} | |
})(); |
i cant comment at shorts
Can a script be written which would adjust volume in shorts with up and down arrows?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use this script, you need to have Tampermonkey or a similar user script manager installed in your browser. Once installed, simply copy and paste the code into a new user script and save it. The script should automatically run on YouTube Shorts pages and disable the spacebar scrolling behavior.
Note that this script may not work if YouTube changes its code in the future. If that happens, you may need to update the script accordingly.