Greasy Fork镜像 支持简体中文。

優酷全屏模式

YouTube畫面自動轉換成100高、100寬的畫面。

目前為 2024-12-18 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name:ko 유튜브 풀스크린
  3. // @name Youtube Fullscreen Mode
  4. // @name:ru Youtube Полный режим
  5. // @name:ja Youtubeフルスクリーンモードの
  6. // @name:zh-CN 优酷全屏模式
  7. // @name:zh-TW 優酷全屏模式
  8.  
  9. // @description:ko 유튜브 화면을 자동으로 꽉 찬 화면으로 바꿉니다.
  10. // @description Automatically switch YouTube screens to 100 height and 100 width screens.
  11. // @description:ru Автоматическое переключение экрана на YouTube на экран высотой 100 и шириной 100.
  12. // @description:ja ユーチューブ画面を高さ100、広さ100画面に自動転換。
  13. // @description:zh-CN YouTube画面自动转换成100高、100宽的画面。
  14. // @description:zh-TW YouTube畫面自動轉換成100高、100寬的畫面。
  15.  
  16. // @namespace https://ndaesik.tistory.com/
  17. // @version 2024.12.18.2152
  18. // @author ndaesik
  19. // @icon https://lh3.googleusercontent.com/iLZyxGK7l1343U4E7eAfgKbRWW6qhzCJq-Z92M60JzCMntFyaFF2GUQVRxPhfGcy6qRISLjHv4fX1vtq0TZkZMAzBjM
  20. // @match *://*.youtube.com/*
  21. // @grant window.focus
  22. // ==/UserScript==
  23.  
  24. const suggestBoxToDarkCSS = document.createElement('style');
  25. suggestBoxToDarkCSS.innerText = `
  26. [dark] {color-scheme: dark;}`.replaceAll(';','!important;')
  27.  
  28. const fullscreenVideoCSS = document.createElement('style');
  29. fullscreenVideoCSS.innerText = `
  30. ytd-app:not([guide-persistent-and-visible]) [theater] #player video,
  31. :is(ytd-watch-flexy[theater],ytd-watch-flexy[fullscreen]) #full-bleed-container {
  32. height: 100vh; max-height: 100vh; min-height: 100vh;}`.replaceAll(';','!important;')
  33.  
  34. const autoHideTopCSS = document.createElement('style');
  35. autoHideTopCSS.innerText = `
  36. #masthead-container.ytd-app:hover, #masthead-container.ytd-app:focus-within {width:100%;}
  37. #masthead-container.ytd-app,
  38. #masthead-container.ytd-app:not(:hover):not(:focus-within) {width:calc(50% - 150px);}
  39. #masthead-container.ytd-app:not(:hover):not(:focus-within) {transition:width 0.4s ease-out 0.4s;}
  40. ytd-app:not([guide-persistent-and-visible]) :is(#masthead-container ytd-masthead, #masthead-container.ytd-app::after) {transform: translateY(-56px); transition: transform .1s .3s ease-out;}
  41. ytd-app:not([guide-persistent-and-visible]) :is(#masthead-container:hover ytd-masthead, #masthead-container:hover.ytd-app::after, #masthead-container:focus-within ytd-masthead) {transform: translateY(0px);}
  42. ytd-app:not([guide-persistent-and-visible]) ytd-page-manager {margin-top: 0;}`.replaceAll(';','!important;')
  43. autoHideTopCSS.className = "autoHideTopCSS";
  44.  
  45. function isWatchPage() {
  46. return !(document.URL.indexOf('watch') == -1)
  47. };
  48.  
  49. function isTheaterMode() {
  50. let scrollbarWidth = window.innerWidth - document.querySelector('ytd-app')?.offsetWidth;
  51. let playerWidth = document.querySelector('#ytd-player')?.offsetWidth;
  52. let chatWidth = (!document.querySelector('ytd-live-chat-frame').attributes.collapsed && document.querySelector('ytd-live-chat-frame')?.offsetWidth) || 0;
  53. let isWidePlayer = scrollbarWidth + playerWidth + chatWidth === window.innerWidth;
  54. return (isWatchPage() && isWidePlayer);
  55. }
  56.  
  57. function alwaysTheaterMode() {
  58. let clickModeButtonRepeatly = setInterval(() => {
  59. if (isTheaterMode()) {
  60. clearInterval(clickModeButtonRepeatly);
  61. } else {
  62. document.querySelectorAll('.ytp-size-button')?.forEach((e) => e.click());
  63. }
  64. }, 100);
  65.  
  66. setTimeout(() => {
  67. clearInterval(clickModeButtonRepeatly);
  68. }, 10000);
  69. }
  70.  
  71. ['yt-navigate-finish', 'load', 'unload', 'locationchange'].forEach( e => {
  72. window.addEventListener( e, _ => {
  73. isWatchPage() ? document.head.appendChild(autoHideTopCSS) : false;
  74. document.head.appendChild(suggestBoxToDarkCSS);
  75. document.head.appendChild(fullscreenVideoCSS);
  76. alwaysTheaterMode();
  77. window.scrollTo(0, 0);
  78. });
  79. });
  80.  
  81. window.addEventListener('click', _ => {
  82. setTimeout( _ => {
  83. if ( !isWatchPage() || !isTheaterMode() ) {
  84. document.querySelector('.autoHideTopCSS')?.remove()
  85. } else if ( isTheaterMode() ) {
  86. document.head.appendChild(autoHideTopCSS)
  87. }
  88. }, 100);
  89. });

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址