Youtube: UpDown to Scroll

Scroll up/down when using home/end/up/down arrow instead of controlling the volume.

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

  1. // ==UserScript==
  2. // @name Youtube: UpDown to Scroll
  3. // @description Scroll up/down when using home/end/up/down arrow instead of controlling the volume.
  4. // @author Chris H (Zren)
  5. // @icon https://youtube.com/favicon.ico
  6. // @namespace http://xshade.ca
  7. // @version 3
  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 === 35) { // End
  18. e.stopPropagation()
  19. } else if (e.keyCode === 36) { // Home
  20. e.stopPropagation()
  21. } else if (e.keyCode === 38) { // ArrowUp
  22. e.stopPropagation()
  23. } else if (e.keyCode === 40) { // ArrowDown
  24. e.stopPropagation()
  25. }
  26. }
  27. }, true);