Disable YouTube Number Keyboard Seek Shortcuts

disables the 0-9 keyboard shortcuts

  1. // ==UserScript==
  2. // @name Disable YouTube Number Keyboard Seek Shortcuts
  3. // @namespace https://github.com/timmontague/youtube-disable-number-seek
  4. // @description disables the 0-9 keyboard shortcuts
  5. // @author timm
  6. // @version 1.0.1
  7.  
  8. // @match *://www.youtube.com/*
  9.  
  10. // @match *://vid.puffyan.us/*
  11. // @match *://invidious.fdn.fr/*
  12. // @match *://invidious.048596.xyz/*
  13. // @match *://invidious.site/*
  14. // @match *://yewtu.be/*
  15. // @match *://invidiou.site/*
  16. // @match *://invidious.himiko.cloud/*
  17. // @match *://invidious.snopyta.org/*
  18. // @match *://invidious.namazso.eu/*
  19. // @match *://invidious.xyz/*
  20. // @match *://ytprivate.com/*
  21. // @match *://invidious.kavin.rocks/*
  22. // @match *://invidious.tinfoil-hat.net/*
  23. // @match *://tube.connect.cafe/*
  24. // @match *://invidious.tube/*
  25. // ==/UserScript==
  26.  
  27. function keyboard_event_handler(e) {
  28. // Don't prevent entering numbers in input areas
  29. if (e.target.tagName == 'INPUT' ||
  30. e.target.tagName == 'SELECT' ||
  31. e.target.tagName == 'TEXTAREA' ||
  32. e.target.isContentEditable) {
  33. return;
  34. }
  35. // Trap number keys
  36. if (e.key >= '0' && e.key <= '9') {
  37. e.stopImmediatePropagation();
  38. }
  39. }
  40. window.addEventListener('keydown', keyboard_event_handler, true);