NPR player controller

'c': loading; 'z': rewind; 'x':fast forward.

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

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

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         NPR player controller
// @namespace    http://tampermonkey.net/
// @version      0.5
// @description  'c': loading; 'z': rewind; 'x':fast forward.
// @author       You
// @match        *://*.npr.org/*
// @grant        none
 // @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    var loading = 87; // w
    var rewind = 90; // z
    var fastForward = 88; // x

    function logKey(e){
        switch(e.keyCode){
                case loading:
                    document.querySelector(".player-play-pause-stop").click();
                    break;
                case rewind:
                    document.getElementsByClassName("player-rewind")[0].click();
                    break;
                case fastForward:
                    document.getElementsByClassName("player-fast-forward")[0].click();
                    break;
       }
    }
    document.addEventListener("keydown", logKey);
})();