YouTube CSS

Adds compact CSS style for mobile and desktop site YouTube

目前为 2024-11-20 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name YouTube CSS
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.1
  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.  
  162. /* player tip scrubber popup */
  163. .tooltip-wrapper {display: none !important}
  164.  
  165. /* make more space for the video content */
  166. .player-controls-pb {left: 15px !important; right: 15px !important}
  167. ytm-custom-control .player-controls-bottom {left: 0 !important; right: 0 !important}
  168. ytm-custom-control .player-controls-top {top: -8px !important}
  169.  
  170.  
  171. /* muted video popup */
  172. .ytp-unmute-animated .ytp-unmute-icon {border-bottom: none !important;border-radius: 50px !important;background-color: rgba(255, 255, 255, 0.59) !important}
  173. .ytp-unmute-shrink .ytp-unmute-text {opacity: 0 !important}
  174. .ytp-unmute-shrink .ytp-unmute-box {width: 0 !important}
  175.  
  176.  
  177. /* comments */
  178. .modern-styling {margin:0 !important}
  179. ytm-comments-simplebox-renderer {display: none !important}
  180. .draggable .engagement-panel-section-list-header {border:none !important}
  181. ytm-comment-renderer {padding:0 !important}
  182. ytm-comment-thread-renderer {padding:0 !important}
  183. .comment-content {padding: 0 4px !important}
  184. ytm-comment-replies-renderer {margin:0 !important}
  185. .comment-simplebox-placeholder {border: none !important}
  186. .comments-simplebox-placeholder {background: none !important}
  187. ytm-comments-simplebox-renderer {padding:0 !important}
  188. .rich-grid-sticky-header { display: none !important}
  189. ytm-comment-renderer .comment-expand {padding: 0 !important}
  190. ytm-comment-renderer .comment-details {margin: 0 !important}
  191.  
  192.  
  193. /* comments menu button */
  194. .comment-menu:not(hover) {opacity: 0 !important}
  195.  
  196. /* landscape comments panel */
  197. @media (min-width: 931px) and (orientation: landscape) {ytm-engagement-panel {width: 40% !important}}
  198. /* landscape sidebar recommendations */
  199. @media (min-width: 931px) and (orientation: landscape) {ytm-single-column-watch-next-results-renderer [section-identifier="related-items"] {padding:0 !important}}
  200. @media (min-width: 931px) and (orientation: landscape) {ytm-single-column-watch-next-results-renderer [section-identifier="related-items"] .item {padding:0 !important}}
  201.  
  202. /* submit comment field */
  203. ytm-comments-header-renderer {display: none !important}
  204.  
  205.  
  206.  
  207. /* Feed */
  208. .chip-bar {display: none !important}
  209. ytm-media-item[use-vertical-layout] .details {margin-top: 0 !important}
  210. ytm-rich-item-renderer ytm-media-item .details {margin-left: 0 !important}
  211. /* Thumbnail Time */
  212. ytm-thumbnail-overlay-time-status-renderer {margin-right: 0 !important}
  213. /* video recommendations under player */
  214. ytm-single-column-watch-next-results-renderer.full-bleed-wn-thumbs [section-identifier="related-items"] ytm-video-with-context-renderer ytm-media-item .details {margin: 0 !important}
  215. ytm-item-section-renderer {border: none !important}
  216.  
  217. /* search info-panel */
  218. ytm-info-panel-container-renderer {display: none !important}
  219.  
  220. /* Shorts */
  221. ytm-reel-shelf-renderer .reel-shelf-header {margin:0 !important}
  222. ytm-reel-shelf-renderer {border: none !important; margin: 0 !important}
  223. ytm-reel-shelf-renderer .reel-shelf-items > * {margin: 0 !important}
  224. .reel-shelf-menu {display: none !important}
  225.  
  226.  
  227.  
  228. /* Title under player */
  229. .slim-video-metadata-header .slim-video-information-content.slim-video-information-empty-badge {padding:0 !important}
  230. ytm-slim-video-metadata-section-renderer ytm-slim-owner-renderer {padding-top: 0 !important}
  231.  
  232. /* padding uploader avatar and subscribe button */
  233. ytm-slim-video-metadata-section-renderer ytm-slim-owner-renderer {padding: 0 !important}
  234. .slim-owner-profile-icon {margin-right: 2px !important}
  235.  
  236. /* hide left green border on subscription button */
  237. .animated-action__background-container {display: none !important}
  238.  
  239. /* action buttons spacing */
  240. .yt-spec-button-shape-next--mono.yt-spec-button-shape-next--tonal {background: rgba(0,0,0,.05) !important}
  241. .yt-spec-button-shape-next--size-m {padding: 0 6px !important; height: 33px !important}
  242. .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}
  243. /* downvotes arent shown anyway */
  244. .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}
  245. .slim-video-action-bar-actions {padding: 3px 3px !important}
  246.  
  247.  
  248. /* description box */
  249. .draggable ytm-structured-description-content-renderer {padding: 0 !important}
  250. ytm-expandable-video-description-body-renderer.expandable-video-description-modern {margin: 0 !important}
  251. /* description statistics */
  252. ytm-video-description-header-renderer .factoids {padding: 0 !important}
  253.  
  254.  
  255. /* name / views and time / chapter separator */
  256. .ytm-badge-and-byline-separator, .middot {opacity: 0 !important}
  257.  
  258. /* weird empty space after going fullscreen and leaving fullscreen video */
  259. .related-chips-slot-wrapper.slot-open {transform: none !important}
  260.  
  261.  
  262.  
  263.  
  264. ytm-video-with-context-renderer.feed-item, :where(ytm-rich-item-renderer.rich-item-single-standard-column) ytm-media-item .details {margin-bottom: 0 !important}
  265.  
  266. /* includes paid promotion */
  267. .YtmPaidContentOverlayLink {display: none !important}
  268. `);
  269. }