Greasy Fork is available in English.
Stop the anoying 0 to 9 YouTube shortcuts from ruining your wathing experience while allowing all the other shortcuts to work
< Feedback on Disable YouTube number shortcuts
I realised it also needs a e.key === ' '
condition
if (e.key === ' ' || isNaN(e.key) || e.isComposing || e.ctrlKey || e.altKey) return;`
The source code is based on a very old stackoverflow post
window.opera
any more. return false
in a event listener callback is a totally wrong concept. No effect on it.cancelBubble
is already depreciated.Obviously this script is just created by newbie.
(function () {
const keys = new Set('0123456789'.split(''));
// keys.add(' '); // You can add other keys. Check in https://www.toptal.com/developers/keycode
document.addEventListener('keydown', function (e) {
if (keys.has(e.key) || e.isComposing || e.ctrlKey || e.altKey) return;
e.stopPropagation();
e.stopImmediatePropagation();
}, true);
})();
Hi, what about using
isNaN
instead ofkeys
andkeys.indexOf
?