Skip to content

Instantly share code, notes, and snippets.

@ThenTech
Created January 25, 2017 04:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThenTech/91b217dedbe468ac96649350a25d1b44 to your computer and use it in GitHub Desktop.
Save ThenTech/91b217dedbe468ac96649350a25d1b44 to your computer and use it in GitHub Desktop.
Youtube: Space to Pause
// ==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();
}
});
@thienha1
Copy link

Can you make scripts that set a timer to automatically pause/stop on all Youtube embed videos? Like pause a video after X seconds!!?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment