Skip to content

Instantly share code, notes, and snippets.

Created May 7, 2023 20:50
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Disable YouTube Shorts Spacebar Scrolling
// ==UserScript==
// @name Disable YouTube Shorts spacebar scrolling
// @namespace
// @version 0.1
// @description Disables YouTube Shorts scrolling and pauses video on spacebar press
// @author HPZ07
// @match*
// @grant none
// ==/UserScript==
(function() {
'use strict';
document.addEventListener('keydown', function(e) {
if (e.keyCode === 32 && document.activeElement.tagName !== 'INPUT' && document.activeElement.tagName !== 'TEXTAREA') {
var video = document.querySelector('video.html5-main-video');
if (video !== null && !isNaN(video.duration)) {
if (video.paused) {;
} else {
function isShortsPage() {
return /^\/shorts/.test(location.pathname);
Copy link

HPZ07 commented May 7, 2023

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.

Copy link

i cant comment at shorts

Copy link

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