YouTube Hide UI on Arrow Keys, Show on Mouse Move

Ok tuşları UI'yi açmasın ama mouse hareketinde görünsün (tüm .ytp- elemanları otomatik algılanır)

当前为 2025-02-15 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name YouTube Hide UI on Arrow Keys, Show on Mouse Move
  3. // @version 1.7
  4. // @namespace https://github.com/KaanAlper/youtube-ui-hide
  5. // @license GPL-3.0
  6. // @description Ok tuşları UI'yi açmasın ama mouse hareketinde görünsün (tüm .ytp- elemanları otomatik algılanır)
  7. // @author Kaan Alper Karaaslan
  8. // @match http://*.youtube.com/*
  9. // @match http://youtube.com/*
  10. // @match https://*.youtube.com/*
  11. // @match https://youtube.com/*
  12. // @grant none
  13.  
  14. // ==/UserScript==
  15.  
  16. (function() {
  17. 'use strict';
  18.  
  19. let hideTimeout;
  20.  
  21. let hideUI = () => {
  22. document.querySelectorAll('[class^="ytp-"]').forEach(el => {
  23. el.style.opacity = '0';
  24. el.style.pointerEvents = 'none';
  25. });
  26. };
  27.  
  28. let showUI = () => {
  29. document.querySelectorAll('[class^="ytp-"]').forEach(el => {
  30. el.style.opacity = '1';
  31. el.style.pointerEvents = 'auto';
  32. });
  33. };
  34.  
  35. document.addEventListener('keydown', function(event) {
  36. if (['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'].includes(event.key)) {
  37. clearTimeout(hideTimeout);
  38. setTimeout(hideUI, 100); // 100ms sonra UI tamamen gizle
  39. }
  40. });
  41.  
  42. document.addEventListener('mousemove', function() {
  43. clearTimeout(hideTimeout);
  44. showUI();
  45. hideTimeout = setTimeout(hideUI, 2000); // 2 saniye sonra tekrar gizle
  46. });
  47.  
  48. })();