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); | |
} | |
})(); |
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
i cant comment at shorts