ZDF Player With Keyboard

Press cursor to skip some seconds back and forth, f fullscreen, p play

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         ZDF Player With Keyboard
// @namespace    ZDF
// @version      0.3
// @description  Press cursor to skip some seconds back and forth, f fullscreen, p play
// @match        https://www.zdf.de/show/*
// @match        https://www.zdf.de/comedy/*
// @match        https://www.zdf.de/gesellschaft/*
// @match        https://www.zdf.de/play/*
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
  'use strict';

  var toggleFullScreen = 0;
  var togglePlay = 0;

  window.addEventListener('keydown', function(e) {

    var buttonElement;

    if (e.key === 'ArrowLeft') {
      buttonElement = document.querySelector("button[aria-label='10s rückwärts']");
      // console.log("key <- was pressed " + buttonElement);
      buttonElement.click();
    } else if (e.key === 'ArrowRight') {
      buttonElement = document.querySelector("button[aria-label='10s vorwärts']");
      // console.log("key -> was pressed " + buttonElement);
      buttonElement.click();
    } else if (e.key === 'f') {
      buttonElement = document.querySelector("button.button-fullscreen");
      if (toggleFullScreen == 0) {
        toggleFullScreen = 1;
      } else {
        toggleFullScreen = 0;
        buttonElement = document.querySelector("button.button-fullscreen-exit");
      }
      buttonElement.click();
    } else if (e.key === 'p') {
      buttonElement = document.querySelector("button[aria-label='Abspielen']");
      if (togglePlay == 0) {
        togglePlay = 1;
      } else {
        togglePlay = 0;
        buttonElement = document.querySelector("button[aria-label='Anhalten']");
      }
      buttonElement.click();
    }

  });

})();