YouTube CSS

Adds compact CSS style for mobile and desktop site YouTube

当前为 2024-12-05 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name YouTube CSS
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.2
  5. // @description Adds compact CSS style for mobile and desktop site YouTube
  6. // @author Agreasyforkuser
  7. // @match https://*.youtube.com/*
  8. // @exclude https://*.youtube.com/tv*
  9. // @icon https://www.google.com/s2/favicons?domain=youtube.com
  10. // @grant GM_addStyle
  11. // ==/UserScript==
  12.  
  13. var currentURL = window.location.href;
  14.  
  15.  
  16. //--------------------------------------------------------------------------------------------------------------------------------
  17. if (currentURL.startsWith("https://www.youtube.com")) {
  18.  
  19.  
  20. GM_addStyle(`
  21.  
  22. ytd-thumbnail a.ytd-thumbnail, #ytd-player, yt-img-shadow.ytd-video-renderer {border-radius:0px !important}
  23.  
  24.  
  25. /* transparent searchbar */
  26. #masthead-container {z-index:0 !important}
  27. /* placeholder text in searchbar */
  28. ::-moz-placeholder {color:transparent !important}
  29. ::-webkit-input-placeholder {color:transparent !important}
  30. #chips-wrapper.ytd-feed-filter-chip-bar-renderer {background-color: transparent !important}
  31.  
  32.  
  33. /* sidebar expand button */
  34. #start.ytd-masthead:not(:hover) button.yt-icon-button {opacity: 0 !important}
  35.  
  36.  
  37. #country-code.ytd-topbar-logo-renderer {display: none !important}
  38. #buttons.ytd-masthead:not(:hover) {opacity:0}
  39.  
  40. yt-chip-cloud-chip-renderer.yt-chip-cloud-renderer {margin-top: 0 !important; margin-bottom: 0 !important}
  41. #contents.ytd-rich-grid-renderer {padding-top:0 !important}
  42.  
  43.  
  44. ytd-comments-header-renderer {margin: 0 !important}
  45. ytd-mini-guide-entry-renderer[system-icons]:not(:hover) .title.ytd-mini-guide-entry-renderer {opacity:0}
  46.  
  47. /* hide comment input field */
  48. /*ytd-comment-simplebox-renderer:not(:hover) {opacity:0}*/
  49. ytd-comment-simplebox-renderer:not(:hover) {display:none !important}
  50.  
  51. .yt-spec-button-shape-next--mono.yt-spec-button-shape-next--outline {display:none}
  52. .yt-spec-button-shape-next--mono.yt-spec-button-shape-next--tonal {background: rgba(0,0,0,.05) !important}
  53.  
  54.  
  55.  
  56. .html5-video-player {width:100%}
  57. .ytp-time-separator {opacity: 0 !important}
  58. .ytp-title {display: none !important}
  59. .ytp-gradient-top {display: none !important}
  60. .ytp-chrome-top-buttons {display: none !important}
  61. .ytp-fullerscreen-edu-chevron {display: none !important}
  62.  
  63.  
  64. /* compact feed */
  65. ytd-rich-item-renderer {margin: 0 !important}
  66. #meta.ytd-rich-grid-media {padding:0 !important}
  67. ytd-compact-video-renderer.ytd-item-section-renderer {margin: 0 !important}
  68. ytd-compact-playlist-renderer.ytd-item-section-renderer {margin: 0 !important}
  69. ytd-compact-video-renderer.ytd-watch-next-secondary-results-renderer:not([expansion="collapsed"]) {margin: 0 !important}
  70. .style-scope.ytd-item-section-renderer {margin: 0 !important}
  71. #expandable-metadata {margin: 0 !important}
  72. #badges {margin: 0 !important}
  73.  
  74.  
  75. /* preview player*/
  76. .ytp-inline-preview-ui .ytp-inline-preview-controls {top:0 !important;right:0 !important}
  77. /* includes paid promotion */
  78. .YtmPaidContentOverlayLink {display: none !important}
  79.  
  80. /* live chat */
  81. yt-live-chat-viewer-engagement-message-renderer {display: none !important}
  82. ytd-live-chat-frame {border:none !important}
  83. yt-live-chat-header-renderer {height: fit-content !important; padding: 0 !important}
  84. yt-live-chat-message-input-renderer {display: none !important}
  85. #reaction-control-panel-overlay.yt-live-chat-renderer {display: none !important}
  86.  
  87.  
  88. /* likes seperator */
  89. .yt-spec-button-shape-next--size-m.yt-spec-button-shape-next--segmented-start::after {display:none !important}
  90. /* no button backgrounds until hover */
  91. #top-row.ytd-watch-metadata:not(:hover) .yt-spec-button-shape-next--mono.yt-spec-button-shape-next--tonal {background-color:transparent !important}
  92. #top-row.ytd-watch-metadata:not(:hover) .yt-spec-button-shape-next--mono.yt-spec-button-shape-next--filled {color: black !important; background-color:transparent !important}
  93. /* Info Card */
  94. ytd-info-panel-content-renderer[has-menu] {border: none !important}
  95.  
  96. /* additional info panel */
  97. .content.ytd-info-panel-content-renderer {padding-top: 0 !important; padding-bottom: 0 !important}
  98.  
  99.  
  100. /* survey */
  101. #attached-survey.ytd-rich-grid-media {display: none !important}
  102.  
  103. /* hide left green border on subscription button */
  104. .animated-action__background-container {display: none !important}
  105.  
  106.  
  107. #top-row.ytd-watch-metadata:not(:hover) .yt-spec-button-shape-next--size-m.yt-spec-button-shape-next--icon-leading-trailing .yt-spec-button-shape-next__secondary-icon {opacity:0}
  108.  
  109. /* padding over video player */
  110. ytd-watch-flexy[default-layout]:not([no-top-margin]):not([reduced-top-margin]) #primary.ytd-watch-flexy, ytd-watch-flexy[default-layout]:not([no-top-margin]):not([reduced-top-margin]) #secondary.ytd-watch-flexy {padding-top:0 !important}
  111.  
  112.  
  113. `);
  114.  
  115.  
  116. };
  117.  
  118. //---------------------------------------------------------------------------------------------------------------------------
  119. if (currentURL.startsWith("https://m.youtube.com")) {
  120.  
  121.  
  122. GM_addStyle(`
  123. /* turn off text selection in player (double-tap forwarding video on Firefox Android does select text) */
  124. #player-control-overlay {
  125. -webkit-touch-callout: none;
  126. -webkit-user-select: none;
  127. -khtml-user-select: none;
  128. -moz-user-select: none;
  129. -ms-user-select: none;
  130. user-select: none; }
  131.  
  132.  
  133. /* top bar */
  134. /* Logo */
  135. .mobile-topbar-header[data-mode="watch"] .mobile-topbar-logo:not(:hover) {opacity: 0 !important}
  136.  
  137. /* account avatar, search button, login button */
  138. .mobile-topbar-header[data-mode="watch"] .topbar-menu-button-avatar-button:not(:hover) {opacity: 0.3 !important}
  139. ytm-mobile-topbar-renderer ytm-menu .icon-button:not(:hover) {opacity: 0.3 !important}
  140. .yt-spec-button-shape-next--overlay.yt-spec-button-shape-next--text:not(:hover) {opacity: 0.3 !important}
  141. .mobile-topbar-header-sign-in-button:not(:hover) {opacity: 0.3 !important}
  142.  
  143. /* search bar */
  144. ytm-mobile-topbar-renderer {backdrop-filter: none !important}
  145.  
  146. /* navbar*/
  147. ytm-pivot-bar-renderer {backdrop-filter: none !important; height: fit-content !important}
  148. .pivot-bar-item-title {display:none !important}
  149. ytm-pivot-bar-renderer {border:none !important}
  150. .yt-spec-avatar-shape__button--button-extra-small {filter: grayscale(1)}
  151.  
  152. /* dark mode above/under videoplayer */
  153. .mobile-topbar-header[data-mode="watch"] {background-color: rgba(0,0,0,1) !important}
  154. .engagement-panel-section-list-background.draggable {background: rgba(0,0,0,1) !important}
  155.  
  156.  
  157.  
  158. /* player */
  159. ytm-custom-control .player-controls-top {opacity: .4 !important}
  160. ytm-custom-control .player-controls-bottom .icon-button {opacity: 0.8 !important}
  161. /* player paused overlay */
  162. #player-control-overlay.fadein .player-controls-background {background: rgba(0,0,0,.2) !important}
  163. /* player controls background */
  164. ytm-custom-control .player-controls-middle .modern-tap-target-ui .icon-button {background-color: rgba(0,0,0,0.15) !important}
  165.  
  166. /* player tip scrubber popup */
  167. .tooltip-wrapper {display: none !important}
  168.  
  169. /* make more space for the video content */
  170. .player-controls-pb {left: 15px !important; right: 15px !important}
  171. ytm-custom-control .player-controls-bottom {left: 0 !important; right: 0 !important}
  172. ytm-custom-control .player-controls-top {top: -8px !important}
  173.  
  174.  
  175. /* muted video popup */
  176. .ytp-unmute-animated .ytp-unmute-icon {border-bottom: none !important;border-radius: 50px !important;background-color: rgba(255, 255, 255, 0.59) !important}
  177. .ytp-unmute-shrink .ytp-unmute-text {opacity: 0 !important}
  178. .ytp-unmute-shrink .ytp-unmute-box {width: 0 !important}
  179.  
  180.  
  181. /* comments */
  182. .modern-styling {margin:0 !important}
  183. ytm-comments-simplebox-renderer {display: none !important}
  184. .draggable .engagement-panel-section-list-header {border:none !important}
  185. ytm-comment-renderer {padding:0 !important}
  186. ytm-comment-thread-renderer {padding:0 !important}
  187. .comment-content {padding: 0 4px !important}
  188. ytm-comment-replies-renderer {margin:0 !important}
  189. .comment-simplebox-placeholder {border: none !important}
  190. .comments-simplebox-placeholder {background: none !important}
  191. ytm-comments-simplebox-renderer {padding:0 !important}
  192. .rich-grid-sticky-header { display: none !important}
  193. ytm-comment-renderer .comment-expand {padding: 0 !important}
  194. ytm-comment-renderer .comment-details {margin: 0 !important}
  195.  
  196.  
  197. /* comments menu button */
  198. .comment-menu:not(hover) {opacity: 0 !important}
  199.  
  200. /* landscape comments panel */
  201. @media (min-width: 931px) and (orientation: landscape) {ytm-engagement-panel {width: 40% !important}}
  202. /* landscape sidebar recommendations */
  203. @media (min-width: 931px) and (orientation: landscape) {ytm-single-column-watch-next-results-renderer [section-identifier="related-items"] {padding:0 !important}}
  204. @media (min-width: 931px) and (orientation: landscape) {ytm-single-column-watch-next-results-renderer [section-identifier="related-items"] .item {padding:0 !important}}
  205.  
  206. /* submit comment field */
  207. ytm-comments-header-renderer {display: none !important}
  208.  
  209.  
  210.  
  211. /* search info-panel */
  212. ytm-info-panel-container-renderer {display: none !important}
  213.  
  214.  
  215. /* Shorts */
  216.  
  217. .logo-in-player-endpoint {opacity: 0 !important}
  218. .yt-spec-button-shape-next.yt-spec-button-shape-next--tonal.yt-spec-button-shape-next--overlay-dark.yt-spec-button-shape-next--size-l.yt-spec-button-shape-next--icon-button {background: none !important}
  219. .yt-subscribe-button-view-model-wiz__container {display: none !important}
  220.  
  221.  
  222.  
  223. /* Title under player */
  224. .slim-video-metadata-header .slim-video-information-content.slim-video-information-empty-badge {padding:0 !important}
  225. ytm-slim-video-metadata-section-renderer ytm-slim-owner-renderer {padding-top: 0 !important}
  226.  
  227.  
  228. /* padding uploader avatar and subscribe button */
  229. ytm-slim-video-metadata-section-renderer ytm-slim-owner-renderer {padding: 0 !important}
  230. .slim-owner-profile-icon {margin-right: 2px !important}
  231.  
  232.  
  233. /* action buttons spacing */
  234. .yt-spec-button-shape-next--mono.yt-spec-button-shape-next--tonal {background: rgba(0,0,0,.05) !important}
  235. .yt-spec-button-shape-next--size-m {padding: 0 6px !important; height: 33px !important}
  236. .slim-video-action-bar-actions > .slim_video_action_bar_renderer_button, .slim-video-action-bar-actions > yt-smartimation, .slim-video-action-bar-actions > ytm-account-link-button-renderer {margin-right: 5px !important}
  237. /* downvotes arent shown anyway */
  238. .yt-spec-button-shape-next--size-m.yt-spec-button-shape-next--icon-button.yt-spec-button-shape-next--segmented-end {width: min-content !important}
  239. .slim-video-action-bar-actions {padding: 3px 3px !important}
  240.  
  241.  
  242. /* includes paid promotion */
  243. .YtmPaidContentOverlayLink {display: none !important}
  244. `);
  245. }