nonumpad
This commit is contained in:
@@ -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);
|
||||
})();
|
||||
Reference in New Issue
Block a user