From 2159526b5d4f010cfdffd1e12465ff6b368110db Mon Sep 17 00:00:00 2001 From: "stab.ing" Date: Wed, 6 May 2026 02:38:04 -0500 Subject: [PATCH] nonumpad --- scripts/nonumpad.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 scripts/nonumpad.js diff --git a/scripts/nonumpad.js b/scripts/nonumpad.js new file mode 100644 index 0000000..a47f3e2 --- /dev/null +++ b/scripts/nonumpad.js @@ -0,0 +1,38 @@ +// ==UserScript== +// @name No youtube numpad +// @match https://www.youtube.com/watch* +// @author Stabosa87 +// @grant none +// ==/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; + if (tag === 'INPUT' || tag === 'TEXTAREA') return true; + if (el.isContentEditable) return true; + + return false; + } + + function handler(e) { + if (!keyset.has(e.code)) return; + if (typing(document.activeElement)) return; + + e.preventDefault(); + e.stopPropagation(); + e.stopImmediatePropagation(); + } + + document.addEventListener('keydown', handler, true); +})();