Shift C Toggle Youtube Video Controls

這是為了切換Youtube VidVideo Controls

当前为 2023-01-11 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Shift C Toggle Youtube Video Controls
  3. // @name:en Shift C Toggle Youtube Video Controls
  4. // @name:ja Shift C Toggle Youtube Video Controls
  5. // @name:zh-TW Shift C Toggle Youtube Video Controls
  6. // @name:zh-CN Shift C Toggle Youtube Video Controls
  7. // @name Shift C Toggle Youtube Video Controls
  8. // @namespace http://tampermonkey.net/
  9. // @version 0.1.0
  10. // @description This is to toggle Youtube be Video Controls
  11. // @description:ja Youtube Video Controls 要素を切り替えるためのものです。
  12. // @description:zh-TW 這是為了切換Youtube Video Controls 元素
  13. // @description:zh-CN 這是為了切換Youtube VidVideo Controls
  14. // @description:en This is to toggle Youtueo Controls 元素
  15. // @author CY Fung
  16. // @match https://www.youtube.com/*
  17. // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
  18. // @grant none
  19. // @license MIT
  20. // ==/UserScript==
  21.  
  22. /* jshint esversion:6 */
  23. (function() {
  24. 'use strict';
  25.  
  26. const allowList = [
  27. 'DIV', 'SPAN', 'BODY', 'HTML', 'VIDEO', 'A',
  28. 'YTD-PLAYER', 'YTD-WATCH-FLEXY', 'YTD-PAGE-MANAGER', 'YTD-MINIPLAYER'
  29. ];
  30.  
  31.  
  32. document.documentElement.appendChild(document.createElement('style')).textContent=
  33. `
  34. html.hide-controls .html5-video-container ~ * {
  35. visibility: collapse;
  36. pointer-events: none;
  37. }
  38. `
  39.  
  40. function pageKeyDownfunction(evt) {
  41. //passive = false
  42. //capture = true
  43.  
  44. if (evt.code === 'KeyC' && evt.shiftKey) {
  45.  
  46. if (!allowList.includes(evt.target.nodeName)) return;
  47.  
  48. if(!document.querySelector('html ytd-watch-flexy #movie_player video')) return
  49.  
  50. evt.preventDefault();
  51. evt.stopPropagation();
  52. evt.stopImmediatePropagation();
  53.  
  54. document.documentElement.classList.toggle('hide-controls')
  55.  
  56. }
  57. }
  58.  
  59. document.addEventListener('keydown', pageKeyDownfunction, true)
  60.  
  61. //ytp-ce-video ytp-ce-top-left-quad ytp-ce-size-853 ytp-ce-element-show
  62.  
  63. // Your code here...
  64. })();