Udemy Hide Video Playback Controls

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

  1. // ==UserScript==
  2. // @name Udemy Hide Video Playback Controls
  3. // @namespace https://github.com/RahulSabinkar
  4. // @version 2024-11-28
  5. // @description Hide Playback Controls by pressing Alt + h, and unhide it by ALT + d
  6. // @author Rahul Sabinkar
  7. // @match https://www.udemy.com/course/*
  8. // @icon https://www.udemy.com/staticx/udemy/images/v7/apple-touch-icon.png
  9. // @license MIT
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. "use strict";
  15. window.addEventListener("keydown", (event) => {
  16. const controls = document.querySelector(
  17. ".shaka-control-bar--control-bar-container--OfnMI"
  18. );
  19. const nextAndPrevious = document.querySelectorAll(
  20. ".next-and-previous--container--kZxyo"
  21. );
  22. const headerGradient = document.querySelector(
  23. ".video-viewer--header-gradient--x4Zw0"
  24. );
  25. const headerTitle = document.querySelector(
  26. ".video-viewer--title-overlay--YZQuH"
  27. );
  28. if (event.key === "h" && event.altKey) {
  29. controls.setAttribute("style", "opacity: 0 !important");
  30. nextAndPrevious.forEach((element) => {
  31. element.setAttribute("style", "opacity: 0 !important");
  32. });
  33. headerGradient.setAttribute("style", "display: none !important");
  34. headerTitle.setAttribute("style", "display: none !important");
  35. } else if (event.key === "d" && event.altKey) {
  36. controls.setAttribute("style", "opacity: 1 !important");
  37. nextAndPrevious.forEach((element) => {
  38. element.setAttribute("style", "opacity: 1 !important");
  39. });
  40. headerGradient.setAttribute("style", "display: block !important");
  41. headerTitle.setAttribute("style", "display: block !important");
  42. }
  43. });
  44. })();