Youtube: UpDown to Scroll

Bind the spacebar to play/pause the video.

目前为 2017-03-21 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Youtube: UpDown to Scroll
  3. // @description Bind the spacebar to play/pause the video.
  4. // @author Chris H (Zren)
  5. // @icon https://youtube.com/favicon.ico
  6. // @namespace http://xshade.ca
  7. // @version 1
  8. // @include http*://*.youtube.com/*
  9. // @include http*://youtube.com/*
  10. // @include http*://*.youtu.be/*
  11. // @include http*://youtu.be/*
  12. // ==/UserScript==
  13.  
  14. window.addEventListener('keydown', function(e) {
  15. var validTarget = e.target === document.querySelector('#movie_player') || e.target === document.querySelector('#player-api');
  16. if (validTarget) {
  17. if (e.keyCode === 38) { // ArrowUp
  18. e.stopPropagation()
  19. } else if (e.keyCode === 40) { // ArrowDown
  20. e.stopPropagation()
  21. }
  22. }
  23. }, true);