优酷影院模式

自动转到更宽的 YouTube 屏幕

当前为 2022-01-24 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name:ko 유튜브 극장모드
  3. // @name Youtube Theatermode
  4. // @name:ru Youtube Театральный режим
  5. // @name:jp Youtubeシアターモード
  6. // @name:zh-CN 优酷影院模式
  7. // @name:zh-TW 優酷影院模式
  8.  
  9. // @description:ko 유튜브 화면을 자동으로 꽉 찬 화면으로 바꿉니다.
  10. // @description Turn to wider Youtube screen automatially.
  11. // @description:ru Автоматически переключайтесь на более широкий экран Youtube.
  12. // @description:jp 自動的に広いYouTube画面に移動します
  13. // @description:zh-CN 自动转到更宽的 YouTube 屏幕
  14. // @description:zh-TW 自動轉到更寬的 YouTube 屏幕
  15.  
  16. // @namespace https://ndaesik.tistory.com/
  17. // @version 2022.01.24.22:53
  18. // @author ndaesik
  19. // @icon https://lh3.googleusercontent.com/iLZyxGK7l1343U4E7eAfgKbRWW6qhzCJq-Z92M60JzCMntFyaFF2GUQVRxPhfGcy6qRISLjHv4fX1vtq0TZkZMAzBjM
  20. // @match https://www.youtube.com/*
  21. // ==/UserScript==
  22. var DEFstyle = `
  23. /* search results to turn dark when it's dark mode. */
  24. [dark] .gstl_50.sbdd_a * {background-color:#232323!important; border-color:#282828!important}
  25. [dark] .gsfs,[dark] .sbpqs_a{color:#FFF!important}
  26.  
  27. /* theator mode wider */
  28. ytd-app:not([guide-persistent-and-visible]) [theater] #player.ytd-watch {height: 100vh!important; max-height: 100vh!important}
  29.  
  30. :is(ytd-watch-flexy[theater],ytd-watch-flexy[fullscreen]) #player-theater-container.ytd-watch-flexy,
  31. ytd-app:not([guide-persistent-and-visible]) [theater] #player video {
  32. width: 100%!important; height: 100vh!important; max-height: 100vh!important; max-width: 100%!important; left: 0!important}`
  33.  
  34. var TOGstyle = `
  35. ytd-app:not([guide-persistent-and-visible]) :is(
  36. ytd-masthead,
  37. #masthead-container.ytd-app::after
  38. ) {transform: translateY(-56px); transition: transform .1s .5s ease-out}
  39.  
  40. ytd-app:not([guide-persistent-and-visible]) :is(
  41. #masthead-container:hover ytd-masthead,
  42. #masthead-container:hover.ytd-app::after
  43. ) {transform: translateY(0px)}
  44.  
  45. ytd-app:not([guide-persistent-and-visible]) ytd-page-manager {margin-top: 0!important;}
  46. ytd-app:not([guide-persistent-and-visible]) :is(
  47. #player-theater-container:empty~#columns #primary,
  48. #player-theater-container:empty~#columns #secondary
  49. ) {padding-top: 56px}
  50.  
  51. ytd-app:not([guide-persistent-and-visible]) :is(
  52. .ytp-chrome-top.ytp-share-button-visible, #iv-drawer .iv-drawer-header, #iv-drawer .iv-drawer-content
  53. ) {margin-top: 30px}
  54.  
  55. ytd-app:not([guide-persistent-and-visible]) [theater] :is(
  56. #iv-drawer .iv-drawer-header, #iv-drawer .iv-drawer-content,
  57. .ytp-chrome-top.ytp-share-button-visible, .ytp-multicam-menu-header, .ytp-multicam-menu-items,
  58. .ytp-playlist-menu-header, .ytp-playlist-menu-items, .ytp-share-panel-close
  59. ) {margin-top: 56px}
  60.  
  61. ytd-app:not([guide-persistent-and-visible]) .ytp-tooltip.ytp-tooltip-opaque.ytp-bottom {right: 60px!important; top: 35px!important}
  62. ytd-app:not([guide-persistent-and-visible]) [theater] .ytp-tooltip.ytp-tooltip-opaque.ytp-bottom {right: 60px!important; top: 60px!important}`
  63.  
  64. var DEF = document.createElement("style")
  65. DEF.innerText = DEFstyle
  66. document.head.appendChild(DEF)
  67. var TOG = document.createElement("style")
  68. TOG.innerText = TOGstyle
  69. TOG.className = "TOGstyle"
  70.  
  71. window.addEventListener("yt-navigate-finish", () => {
  72. document.head.appendChild(TOG)
  73. setTimeout(() => {if ((document.querySelector("#ytd-player").offsetWidth + 50) < window.innerWidth) document.querySelector(".ytp-size-button").click()}, 1500)
  74. if (!(document.URL.indexOf("watch") > -1)) document.querySelector(".TOGstyle").remove()
  75. window.scrollTo(0, 0);
  76. })
  77.  
  78. window.addEventListener("mouseup", () => {
  79. setTimeout(() => {(document.querySelector("#ytd-player").offsetWidth + 50) < window.innerWidth ? document.querySelector(".TOGstyle").remove() : document.head.appendChild(TOG)}, 100)
  80. })