YouTube CSS

Adds compact CSS style for mobile and desktop site YouTube

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

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