优酷影院模式

自动转到更宽的 YouTube 屏幕

当前为 2022-05-21 提交的版本,查看 最新版本

  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.05.21.09.57
  18. // @author ndaesik
  19. // @icon https://lh3.googleusercontent.com/iLZyxGK7l1343U4E7eAfgKbRWW6qhzCJq-Z92M60JzCMntFyaFF2GUQVRxPhfGcy6qRISLjHv4fX1vtq0TZkZMAzBjM
  20. // @match *://*.youtube.com/*
  21. // ==/UserScript==
  22. let DEF = document.createElement(`style`)
  23. , TOG = document.createElement(`style`)
  24. DEF.innerText = `
  25. #chips-wrapper.ytd-feed-filter-chip-bar-renderer {top:56px}
  26. [dark] .gstl_50.sbdd_a * {background-color:#232323!important; border-color:#282828!important}
  27. [dark] .gsfs,[dark] .sbpqs_a{color:#FFF!important}
  28. [dark] .sbqs_c:before {filter: invert(1)!important}
  29. ytd-app:not([guide-persistent-and-visible]) [theater] #player.ytd-watch {height: 100vh!important; max-height: 100vh!important}
  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. document.head.appendChild(DEF)
  34. TOG.innerText = `
  35. 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}
  36. 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)}
  37. ytd-app:not([guide-persistent-and-visible]) ytd-page-manager {margin-top: 0!important}`
  38. TOG.className = "TOGstyle"
  39.  
  40. let vidWid = () => {return document.querySelector(`#ytd-player`)?.offsetWidth + 50}
  41. , winWid = () => {return window.innerWidth}
  42. `yt-navigate-finish load`.split(` `).forEach((e) => {
  43. window.addEventListener(e, () => {
  44. document.head.appendChild(TOG)
  45. let full = setInterval(() => {(50 < vidWid() && vidWid() < winWid()) ? document.querySelectorAll(`.ytp-size-button`)?.forEach(e=>e.click()) : clearInterval(full)},100)
  46. setTimeout(() => {if (document.querySelector(`ytd-watch-flexy`) == null) document.querySelector(`.TOGstyle`)?.remove()}, 100)
  47. setTimeout(() => {clearInterval(full)}, 10000)
  48. window.scrollTo(0, 0)
  49. })
  50. })
  51. window.addEventListener(`mouseup`, () => {
  52. setTimeout(() => {
  53. (vidWid() < winWid() || document.URL.indexOf(`watch`) == -1) ?
  54. document.querySelector(`.TOGstyle`)?.remove() : document.head.appendChild(TOG)
  55. }, 100)
  56. })