emby shortcut

try to take over the world!

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         emby shortcut
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  try to take over the world!
// @author       You
// @include	     *:8096/web/index*
// @grant        none
// @require		 https://unpkg.com/[email protected]/dist/hotkeys.min.js
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    hotkeys('enter', function() {
        var body = document.querySelector("body");
        if(document.fullscreen) document.exitFullscreen();
        else if(document.querySelector("video") != null )body.requestFullscreen();
        return false;//屏蔽其他event
    });

    hotkeys('space', function() {
        if(document.querySelector("video") != null ){
            if(document.querySelector("video").paused) document.querySelector("video").play()
            else document.querySelector("video").pause();
        }
        return false;
    });

    //方向键
    hotkeys('left,right,up,down', function (event, handler){
        event.preventDefault()
        switch (handler.key) {
            case 'right': document.querySelector(".btnOsdFastForward").click();
                break;
            case 'left': document.querySelector(".btnRewind").click();
                break;
            case 'up' : if(document.querySelector("video") != null ) document.querySelector("video").volume !== 1 ? document.querySelector("video").volume += 0.05 : 1;
                break;
            case 'down' : if(document.querySelector("video") != null ) document.querySelector("video").volume !== 0 ? document.querySelector("video").volume -= 0.05 : 1;
                break;
                //default: alert(event);
        }
    });
})();