// ==UserScript== // @name No youtube numpad // @match https://www.youtube.com/* // @author Stabosa87 // @grant none // @run-at document-start // ==/UserScript== (function () { 'use strict'; const keyset = new Set([ 'Digit0','Digit1','Digit2','Digit3','Digit4', 'Digit5','Digit6','Digit7','Digit8','Digit9', 'Numpad0','Numpad1','Numpad2','Numpad3','Numpad4', 'Numpad5','Numpad6','Numpad7','Numpad8','Numpad9' ]); function typing(el) { if (!el) return false; const tag = el.tagName; return ( tag === 'INPUT' || tag === 'TEXTAREA' || el.isContentEditable ); } function handler(e) { if (!keyset.has(e.code)) return; if (typing(document.activeElement)) return; e.preventDefault(); e.stopImmediatePropagation(); } document.addEventListener('keydown', handler, true); })();