Disable YouTube number shortcuts

Stop the anoying 0 to 9 YouTube shortcuts from ruining your wathing experience while allowing all the other shortcuts to work

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Disable YouTube number shortcuts
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Stop the anoying 0 to 9 YouTube shortcuts from ruining your wathing experience while allowing all the other shortcuts to work
// @author       Éric Beaudoin (based on code by Martin J.H. from StackOverflow)
// @match        *://*.youtube.com/*
// @match        *://*.youtube.com
// @match        *://youtube.com/*
// @match        *://youtube.com
// @icon         https://www.google.com/s2/favicons?domain=youtube.com
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    // The keys that we want to intercept (from keydownEvent.key)
    var keys = "0123456789";

    (window.opera ? document.body : document).addEventListener('keydown', function(e) {
        //console.log(`==> event.key: ${ e.key}, event.isComposing: ${ e.isComposing }, keys.indexOf(event.key): ${ keys.indexOf(e.key) } ` ); //uncomment to find more key
        if (keys.indexOf(e.key) != -1 && !(e.isComposing || e.ctrlKey || e.altKey)) {
            e.cancelBubble = true;
            e.stopImmediatePropagation();
            //console.log(`==> intercepted: ${ e.key }`);
        }
        return false;
    }, !window.opera);
})();