Udemy Hide Video Playback Controls

Hide Playback Controls by pressing Alt + h, and unhide it by ALT + d

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Udemy Hide Video Playback Controls
// @namespace    https://github.com/RahulSabinkar
// @version      2024-11-28
// @description  Hide Playback Controls by pressing Alt + h, and unhide it by ALT + d
// @author       Rahul Sabinkar
// @match        https://www.udemy.com/course/*
// @icon         https://www.udemy.com/staticx/udemy/images/v7/apple-touch-icon.png
// @license      MIT
// @grant        none
// ==/UserScript==

(function () {
  "use strict";
  window.addEventListener("keydown", (event) => {
    const controls = document.querySelector(
      ".shaka-control-bar--control-bar-container--OfnMI"
    );
    const nextAndPrevious = document.querySelectorAll(
      ".next-and-previous--container--kZxyo"
    );
    const headerGradient = document.querySelector(
      ".video-viewer--header-gradient--x4Zw0"
    );
    const headerTitle = document.querySelector(
      ".video-viewer--title-overlay--YZQuH"
    );
    if (event.key === "h" && event.altKey) {
      controls.setAttribute("style", "opacity: 0 !important");
      nextAndPrevious.forEach((element) => {
        element.setAttribute("style", "opacity: 0 !important");
      });
      headerGradient.setAttribute("style", "display: none !important");
      headerTitle.setAttribute("style", "display: none !important");
    } else if (event.key === "d" && event.altKey) {
      controls.setAttribute("style", "opacity: 1 !important");
      nextAndPrevious.forEach((element) => {
        element.setAttribute("style", "opacity: 1 !important");
      });
      headerGradient.setAttribute("style", "display: block !important");
      headerTitle.setAttribute("style", "display: block !important");
    }
  });
})();