Created
January 25, 2017 04:54
-
-
Save ThenTech/91b217dedbe468ac96649350a25d1b44 to your computer and use it in GitHub Desktop.
Youtube: Space to Pause
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 Youtube: Space to Pause | |
// @description Press space or Return to pause video. | |
// @author Wosser1sProductions | |
// @icon https://youtube.com/favicon.ico | |
// @version 1.1 | |
// @include http*://*.youtube.com/* | |
// @include http*://youtube.com/* | |
// @include http*://*.youtu.be/* | |
// @include http*://youtu.be/* | |
// ==/UserScript== | |
window.addEventListener('keydown', e => { | |
var playButton = document.querySelector('button.ytp-play-button'); | |
var validTarget = e.target === document.body || e.target === document.querySelector('#player-api'); | |
if (validTarget && (e.keyCode === 32 || e.keyCode === 13) && playButton) { | |
e.preventDefault(); | |
playButton.click(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you make scripts that set a timer to automatically pause/stop on all Youtube embed videos? Like pause a video after X seconds!!?