Sharepoint Keyboard Shortcuts

More sensible keyboard shortcuts for SharePoint Stream video player

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

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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        Sharepoint Keyboard Shortcuts
// @namespace   Violentmonkey Scripts
// @match       *://*.sharepoint.com/*/stream.aspx*
// @grant       none
// @version     1.0
// @author      CyrilSLi
// @description More sensible keyboard shortcuts for SharePoint Stream video player
// @license     MIT
// ==/UserScript==
function keydown(ev){
    const player = document.getElementsByClassName("oneplayer-root")[0];
    if (player.contains(ev.target) && ev.target !== player){
        ev.stopImmediatePropagation();
        const keys = {
            "ArrowLeft": document.querySelector('[aria-description*="Alt + J"]'),
            " ": document.querySelector('[aria-description*="Alt + K"]'),
            "ArrowRight": document.querySelector('[aria-description*="Alt + L"]'),

            "j": document.querySelector('[aria-description*="Alt + J"]'),
            "k": document.querySelector('[aria-description*="Alt + K"]'),
            "l": document.querySelector('[aria-description*="Alt + L"]'),

            "f": document.querySelector('[aria-description*="Alt + Enter"]'),
            "m": document.querySelector('[aria-description*="Alt + M"]'),
            "c": document.querySelector('[aria-description*="Alt + C"]'),
        }
        for (const key in keys){
            if (ev.key === key){
                keys[key].click();
            }
        }
    }
}
window.addEventListener("keydown", keydown, true);