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.6
  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. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. let hideTimeout;
  19.  
  20. let hideUI = () => {
  21. document.querySelectorAll('[class^="ytp-"]').forEach(el => {
  22. el.style.opacity = '0';
  23. el.style.pointerEvents = 'none';
  24. });
  25. };
  26.  
  27. let showUI = () => {
  28. document.querySelectorAll('[class^="ytp-"]').forEach(el => {
  29. el.style.opacity = '1';
  30. el.style.pointerEvents = 'auto';
  31. });
  32. };
  33.  
  34. document.addEventListener('keydown', function(event) {
  35. if (['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'].includes(event.key)) {
  36. clearTimeout(hideTimeout);
  37. setTimeout(hideUI, 100); // 100ms sonra UI tamamen gizle
  38. }
  39. });
  40.  
  41. document.addEventListener('mousemove', function() {
  42. clearTimeout(hideTimeout);
  43. showUI();
  44. hideTimeout = setTimeout(hideUI, 2000); // 2 saniye sonra tekrar gizle
  45. });
  46.  
  47. })();