Youtube Theater Fill Up Window

make theater mode fill up window

目前为 2023-03-09 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Youtube Theater Fill Up Window
  3. // @name:zh-TW Youtube Theater Fill Up Window
  4. // @namespace https://gf.qytechs.cn/scripts/454092
  5. // @version 1.0.4
  6. // @description make theater mode fill up window
  7. // @description:zh-TW 讓劇院模式填滿視窗
  8. // @author Derek
  9. // @match *://www.youtube.com/*
  10. // @grant none
  11. // @noframes
  12. // ==/UserScript==
  13.  
  14. let $ = (element) => document.querySelector(element)
  15. let getScrollbarWidth = () => {
  16. let dummy = document.createElement('div')
  17. $('body').appendChild(dummy)
  18. dummy.style.overflowY = 'scroll'
  19. let clientWidth = dummy.clientWidth
  20. let offsetWidth = dummy.offsetWidth
  21. document.body.removeChild(dummy)
  22. return offsetWidth - clientWidth + 1
  23. }
  24.  
  25. let css = `
  26. #masthead-container {
  27. display: none !important;
  28. }
  29. ytd-page-manager {
  30. margin: 0 !important;
  31. }
  32. #player-theater-container {
  33. min-height: 100vh !important;
  34. min-width: calc(100vw - ${getScrollbarWidth()}px) !important;
  35. }
  36. `
  37.  
  38. let theaterMode = () => {
  39. if ($('#player-theater-container>#player-container') && !$('#theater-mode')) {
  40. let theaterStyle = document.createElement('style')
  41. theaterStyle.setAttribute('id', 'theater-mode')
  42. theaterStyle.appendChild(document.createTextNode(css))
  43. $('head').appendChild(theaterStyle)
  44. } else if (!$('#player-theater-container>#player-container') && $('#theater-mode')) $('head').removeChild($('#theater-mode'))
  45. }
  46.  
  47. let main = () => {
  48. if (window.location.href.includes('/watch?v=')) {
  49. if ($('ytd-watch-flexy').isTheater_()) theaterMode()
  50. let observer = new MutationObserver(theaterMode)
  51. observer.observe($('#player-theater-container'), { childList: true })
  52. } else if ($('#theater-mode')) $('head').removeChild($('#theater-mode'))
  53. }
  54.  
  55. document.addEventListener('yt-navigate-finish', main)

QingJ © 2025

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