YouTube CSS

Adds compact CSS style for mobile and desktop site YouTube

当前为 2024-11-08 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name YouTube CSS
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.0
  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, #avatar, #author-thumbnail.ytd-comment-view-model yt-img-shadow.ytd-comment-view-model, #author-photo.yt-live-chat-text-message-renderer, #ytd-player, yt-img-shadow.ytd-video-renderer {border-radius:0px !important}
  23.  
  24. .downloadbutton:before {content: "Download 🡇" !important}
  25. .downloadbutton {background-color: black !important; border-radius: 6px !important}
  26.  
  27.  
  28. /* transparent searchbar */
  29. #masthead-container {z-index:0 !important}
  30. /* placeholder text in searchbar */
  31. ::-moz-placeholder {color:transparent !important}
  32. ::-webkit-input-placeholder {color:transparent !important}
  33.  
  34. #logo.ytd-masthead:not(:hover) {opacity:0}
  35. #buttons.ytd-masthead:not(:hover) {opacity:0}
  36.  
  37. #chips-wrapper.ytd-feed-filter-chip-bar-renderer:not(:hover) {opacity:0}
  38. yt-chip-cloud-chip-renderer.yt-chip-cloud-renderer {margin-top: 0 !important; margin-bottom: 0 !important}
  39. #contents.ytd-rich-grid-renderer {padding-top:0 !important}
  40.  
  41.  
  42. ytd-comments-header-renderer {margin: 0 !important}
  43. ytd-mini-guide-entry-renderer[system-icons]:not(:hover) .title.ytd-mini-guide-entry-renderer {opacity:0}
  44.  
  45. /* hide comment input field */
  46. ytd-comment-simplebox-renderer:not(:hover) {opacity:0}
  47.  
  48. .yt-spec-button-shape-next--mono.yt-spec-button-shape-next--outline {display:none}
  49. .yt-spec-button-shape-next--mono.yt-spec-button-shape-next--tonal {background: rgba(0,0,0,.05) !important}
  50.  
  51. /* Channel page transparent upper bar */
  52. #contentContainer.tp-yt-app-header:not(:hover) {opacity:0.9}
  53.  
  54.  
  55. .html5-video-player {width:100%}
  56. .ytp-time-separator {opacity: 0 !important}
  57. .ytp-title {display: none !important}
  58. .ytp-gradient-top {display: none !important}
  59. .ytp-chrome-top-buttons {display: none !important}
  60. .ytp-fullerscreen-edu-chevron {display: none !important}
  61.  
  62.  
  63. /* compact feed */
  64. ytd-rich-item-renderer {margin: 0 !important}
  65. #meta.ytd-rich-grid-media {padding:0 !important}
  66. ytd-compact-video-renderer.ytd-item-section-renderer {margin: 0 !important}
  67. ytd-compact-playlist-renderer.ytd-item-section-renderer {margin: 0 !important}
  68. ytd-compact-video-renderer.ytd-watch-next-secondary-results-renderer:not([expansion="collapsed"]) {margin: 0 !important}
  69. .style-scope.ytd-item-section-renderer {margin: 0 !important}
  70. #expandable-metadata {margin: 0 !important}
  71. #badges {margin: 0 !important}
  72.  
  73. /* shorts */
  74. #items.yt-horizontal-list-renderer > .yt-horizontal-list-renderer {padding: 0px !important}
  75. #rich-shelf-header.ytd-rich-shelf-renderer {margin: 0px !important}
  76. #dismissible.ytd-rich-shelf-renderer {margin: 0px !important;border: 0px !important}
  77.  
  78. /* preview */
  79. .ytp-inline-preview-ui .ytp-inline-preview-controls {top:0 !important;right:0 !important}
  80.  
  81. /* live chat */
  82. yt-live-chat-viewer-engagement-message-renderer {display: none !important}
  83. ytd-live-chat-frame {border:none !important}
  84. yt-live-chat-header-renderer {height: fit-content !important; padding: 0 !important}
  85. ytd-watch-flexy[fixed-panels] #chat.ytd-watch-flexy {border-radius: 0 !important}
  86. yt-live-chat-message-input-renderer {display: none !important}
  87. #reaction-control-panel-overlay.yt-live-chat-renderer {display: none !important}
  88.  
  89.  
  90. /* likes seperator */
  91. .yt-spec-button-shape-next--size-m.yt-spec-button-shape-next--segmented-start::after {display:none !important}
  92. /* no button backgrounds until hover */
  93. #top-row.ytd-watch-metadata:not(:hover) .yt-spec-button-shape-next--mono.yt-spec-button-shape-next--tonal {background-color:transparent !important}
  94. #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}
  95. /* Info Card */
  96. ytd-info-panel-content-renderer[has-menu] {border: none !important}
  97.  
  98.  
  99. /* survey */
  100. #attached-survey.ytd-rich-grid-media {display: none !important}
  101.  
  102. /* hide left green border on subscription button */
  103. .animated-action__background-container {display: none !important}
  104.  
  105.  
  106. #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}
  107.  
  108. /* padding over video player */
  109. 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}
  110.  
  111. /* includes paid promotion */
  112. .YtmPaidContentOverlayLink {display: none !important}
  113. `);
  114.  
  115.  
  116. };
  117.  
  118. //---------------------------------------------------------------------------------------------------------------------------
  119. if (currentURL.startsWith("https://m.youtube.com")) {
  120.  
  121.  
  122. GM_addStyle(`
  123. .downloadbutton:before {content: "Download ⤓" !important}
  124. .downloadbutton {color: gray !important; margin: 5px !important}
  125.  
  126. /* turn off text selection in player (double-tap forwarding video on Firefox Android does select text) */
  127. #player-control-overlay {
  128. -webkit-touch-callout: none;
  129. -webkit-user-select: none;
  130. -khtml-user-select: none;
  131. -moz-user-select: none;
  132. -ms-user-select: none;
  133. user-select: none; }
  134.  
  135.  
  136. /* Logo */
  137. .mobile-topbar-header[data-mode="watch"] .mobile-topbar-logo:not(:hover) {opacity: 0 !important}
  138.  
  139. /* account avatar, search button, login button */
  140. .mobile-topbar-header[data-mode="watch"] .topbar-menu-button-avatar-button:not(:hover) {opacity: 0.3 !important}
  141. ytm-mobile-topbar-renderer ytm-menu .icon-button:not(:hover) {opacity: 0.3 !important}
  142. .yt-spec-button-shape-next--overlay.yt-spec-button-shape-next--text:not(:hover) {opacity: 0.3 !important}
  143. .mobile-topbar-header-sign-in-button:not(:hover) {opacity: 0.3 !important}
  144.  
  145. ytm-comment-thread-renderer .comment-icon,
  146. .slim-owner-profile-icon,
  147. .channel-thumbnail-icon,
  148. ytm-profile-icon,
  149. .ytm-comments-entry-point-teaser-avatar,
  150. .video-thumbnail-container-compact-rounded,
  151. .collections-stack-wiz__collection-stack1--medium,
  152. .collections-stack-wiz__collection-stack1,
  153. .collections-stack-wiz__collection-stack2,
  154. ytm-reel-item-renderer.rounded-reel-item .video-thumbnail-container-vertical,
  155. ytm-reel-item-renderer.rounded-reel-item .reel-item-metadata,
  156. .video-thumbnail-container-large.rounded-thumbnail
  157. {border-radius: 0 !important}
  158.  
  159. /* keep rounded avatar on homepage */
  160. .mobile-topbar-header[data-mode="browse"] ytm-profile-icon {border-radius: 50px !important}
  161.  
  162. /* dark mode navbar*/
  163. ytm-pivot-bar-renderer {background-color: transparent !important; background: linear-gradient(180deg, rgba(0,0,0,0) 10%, rgba(0,0,0,0.5032212714187237) 56%, rgba(0,0,0,1) 100%) !important}
  164. ytm-pivot-bar-renderer c3-icon {color: white !important}
  165. .pivot-bar-item-title {display:none !important}
  166. ytm-pivot-bar-renderer {border:none !important}
  167.  
  168. /* dark mode above/under videoplayer */
  169. .mobile-topbar-header[data-mode="watch"] {background-color: rgba(0,0,0,1) !important}
  170. .draggable .engagement-panel-section-list-header-wrapper {background-color: black !important;color: gray !important}
  171. .draggable .engagement-panel-section-list-header {border: none !important}
  172. /* number of comments */
  173. .engagement-panel-section-list-header-context > span:nth-child(1) {color: gray !important}
  174. .engagement-panel-drag-line {opacity:0 !important}
  175. .draggable .engagement-panel-container {border-radius: 0 !important}
  176. ytm-single-column-watch-next-results-renderer .single-column-watch-next-modern-panels ytm-comments-entry-point-header-renderer.modern-styling {border-radius: 0 !important}
  177.  
  178.  
  179.  
  180. /* player */
  181. #player-control-overlay.fadein .player-controls-background {background: rgba(0,0,0,.3) !important}
  182. ytm-custom-control .player-controls-top {opacity: .4 !important}
  183. .time-delimiter {opacity: 0 !important}
  184. ytm-custom-control .player-controls-bottom .icon-button {opacity: 0.8 !important}
  185. #player-control-overlay .player-controls-background-container {visibility: hidden !important}
  186.  
  187. /* player tip scrubber popup */
  188. .tooltip-wrapper {display: none !important}
  189.  
  190. /* make more space for the video content */
  191. .player-controls-pb {left: 15px !important; right: 15px !important}
  192. ytm-custom-control .player-controls-bottom {left: 0 !important; right: 0 !important}
  193. ytm-custom-control .player-controls-top {top: -8px !important}
  194.  
  195.  
  196. /* muted video popup */
  197. .ytp-unmute-animated .ytp-unmute-icon {border-bottom: none !important;border-radius: 50px !important;background-color: rgba(255, 255, 255, 0.59) !important}
  198. .ytp-unmute-shrink .ytp-unmute-text {opacity: 0 !important}
  199. .ytp-unmute-shrink .ytp-unmute-box {width: 0 !important}
  200.  
  201.  
  202. /* comments */
  203. .modern-styling {margin:0 !important}
  204. ytm-comments-header-renderer {border:none !important}
  205. ytm-comment-renderer {padding:0 !important}
  206. ytm-comment-thread-renderer {padding:0 !important}
  207. .comment-content {padding: 0 4px !important}
  208. ytm-comment-replies-renderer {margin:0 !important}
  209. .comment-simplebox-placeholder {border: none !important}
  210. .comments-simplebox-placeholder {background: none !important}
  211. ytm-comments-simplebox-renderer {padding:0 !important}
  212. ytm-single-column-watch-next-results-renderer .single-column-watch-next-modern-panels ytm-comments-entry-point-header-renderer.modern-styling {padding: 0 !important}
  213. .rich-grid-sticky-header { display: none !important}
  214. ytm-comment-renderer .comment-expand {padding: 0 !important}
  215. ytm-comment-renderer .comment-details {margin: 0 !important}
  216.  
  217. /* "comments" text */
  218. .comments-entry-point-header-text {display: none !important}
  219.  
  220. /* comments panel close button */
  221. .yt-spec-button-shape-next--mono.yt-spec-button-shape-next--text {color: gray !important}
  222.  
  223. /* landscape comments panel */
  224. @media (min-width: 931px) and (orientation: landscape) {ytm-engagement-panel {width: 40% !important}}
  225. /* landscape sidebar recommendations */
  226. @media (min-width: 931px) and (orientation: landscape) {ytm-single-column-watch-next-results-renderer [section-identifier="related-items"] {padding:0 !important}}
  227. @media (min-width: 931px) and (orientation: landscape) {ytm-single-column-watch-next-results-renderer [section-identifier="related-items"] .item {padding:0 !important}}
  228.  
  229. /* submit comment field */
  230. ytm-comments-header-renderer {display: none !important}
  231.  
  232.  
  233.  
  234. /* Feed */
  235. .chip-bar {display: none !important}
  236. ytm-media-item[use-vertical-layout] .details {margin-top: 0 !important}
  237. ytm-rich-item-renderer ytm-media-item .details {margin-left: 0 !important}
  238. /* Thumbnail Time */
  239. ytm-thumbnail-overlay-time-status-renderer {margin-right: 0 !important}
  240. /* video recommendations under player */
  241. 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}
  242. ytm-item-section-renderer {border: none !important}
  243.  
  244. /* search info-panel */
  245. ytm-info-panel-container-renderer {display: none !important}
  246.  
  247. /* Shorts */
  248. ytm-reel-shelf-renderer .reel-shelf-header {margin:0 !important}
  249. ytm-reel-shelf-renderer {border: none !important; margin: 0 !important}
  250. ytm-reel-shelf-renderer .reel-shelf-items > * {margin: 0 !important}
  251. .reel-shelf-menu {display: none !important}
  252.  
  253.  
  254.  
  255. /* Title under player */
  256. .slim-video-metadata-header .slim-video-information-content.slim-video-information-empty-badge {padding:0 !important}
  257. ytm-slim-video-metadata-section-renderer ytm-slim-owner-renderer {padding-top: 0 !important}
  258.  
  259. /* padding uploader avatar and subscribe button */
  260. ytm-slim-video-metadata-section-renderer ytm-slim-owner-renderer {padding: 0 !important}
  261. .slim-owner-profile-icon {margin-right: 2px !important}
  262.  
  263. /* hide left green border on subscription button */
  264. .animated-action__background-container {display: none !important}
  265.  
  266. /* action buttons spacing */
  267. .yt-spec-button-shape-next--mono.yt-spec-button-shape-next--tonal {background: rgba(0,0,0,.05) !important}
  268. .yt-spec-button-shape-next--size-m {padding: 0 6px !important; height: 33px !important}
  269. .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}
  270. /* downvotes arent shown anyway */
  271. .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}
  272. .slim-video-action-bar-actions {padding: 3px 3px !important}
  273.  
  274.  
  275. /* description box */
  276. .draggable ytm-structured-description-content-renderer {padding: 0 !important}
  277. ytm-expandable-video-description-body-renderer.expandable-video-description-modern {margin: 0 !important}
  278. /* description statistics */
  279. ytm-video-description-header-renderer .factoids {padding: 0 !important}
  280.  
  281.  
  282. /* name / views and time / chapter separator */
  283. .ytm-badge-and-byline-separator, .middot {opacity: 0 !important}
  284.  
  285. /* weird empty space after going fullscreen and leaving fullscreen video */
  286. .related-chips-slot-wrapper.slot-open {transform: none !important}
  287.  
  288.  
  289.  
  290.  
  291. 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}
  292.  
  293. /* includes paid promotion */
  294. .YtmPaidContentOverlayLink {display: none !important}
  295. `);
  296. }