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. /* additional description info panels */
  65. #clarify-box {display: none !important}
  66. #middle-row.ytd-watch-metadata {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.  
  77.  
  78.  
  79. /* preview player*/
  80. .ytp-inline-preview-ui .ytp-inline-preview-controls {top:0 !important;right:0 !important}
  81. /* includes paid promotion */
  82. .YtmPaidContentOverlayLink {display: none !important}
  83.  
  84.  
  85.  
  86.  
  87. /* likes seperator */
  88. .yt-spec-button-shape-next--size-m.yt-spec-button-shape-next--segmented-start::after {display:none !important}
  89. /* no button backgrounds until hover */
  90. #top-row.ytd-watch-metadata:not(:hover) .yt-spec-button-shape-next--mono.yt-spec-button-shape-next--tonal {background-color:transparent !important}
  91. #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}
  92. /* Info Card */
  93. ytd-info-panel-content-renderer[has-menu] {border: none !important}
  94.  
  95.  
  96. /* survey */
  97. #attached-survey.ytd-rich-grid-media {display: none !important}
  98.  
  99.  
  100.  
  101. /* padding over video player */
  102. 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}
  103.  
  104.  
  105. `);
  106.  
  107.  
  108. };
  109.  
  110. //---------------------------------------------------------------------------------------------------------------------------
  111. if (currentURL.startsWith("https://m.youtube.com")) {
  112.  
  113.  
  114. GM_addStyle(`
  115. /* turn off text selection in player (double-tap forwarding video on Firefox Android does select text) */
  116. #player-control-overlay {
  117. -webkit-touch-callout: none;
  118. -webkit-user-select: none;
  119. -khtml-user-select: none;
  120. -moz-user-select: none;
  121. -ms-user-select: none;
  122. user-select: none; }
  123.  
  124.  
  125. /* top bar */
  126. /* Logo */
  127. .mobile-topbar-header[data-mode="watch"] .mobile-topbar-logo:not(:hover) {opacity: 0 !important}
  128.  
  129. /* account avatar, search button, login button */
  130. .mobile-topbar-header[data-mode="watch"] .topbar-menu-button-avatar-button:not(:hover) {opacity: 0.3 !important}
  131. ytm-mobile-topbar-renderer ytm-menu .icon-button:not(:hover) {opacity: 0.3 !important}
  132. .yt-spec-button-shape-next--overlay.yt-spec-button-shape-next--text:not(:hover) {opacity: 0.3 !important}
  133. .mobile-topbar-header-sign-in-button:not(:hover) {opacity: 0.3 !important}
  134.  
  135. /* search bar */
  136. ytm-mobile-topbar-renderer {backdrop-filter: none !important}
  137.  
  138. /* navbar*/
  139. ytm-pivot-bar-renderer {backdrop-filter: none !important; height: fit-content !important}
  140. .pivot-bar-item-title {display:none !important}
  141. ytm-pivot-bar-renderer {border:none !important}
  142. .yt-spec-avatar-shape__button--button-extra-small {filter: grayscale(1)}
  143.  
  144. /* dark mode above/under videoplayer */
  145. .mobile-topbar-header[data-mode="watch"] {background-color: rgba(0,0,0,1) !important}
  146. .engagement-panel-section-list-background.draggable {background: rgba(0,0,0,1) !important}
  147.  
  148.  
  149.  
  150. /* player */
  151. ytm-custom-control .player-controls-top {opacity: .4 !important}
  152. ytm-custom-control .player-controls-bottom .icon-button {opacity: 0.8 !important}
  153. /* player paused overlay */
  154. #player-control-overlay.fadein .player-controls-background {background: rgba(0,0,0,.2) !important}
  155. /* player controls background */
  156. ytm-custom-control .player-controls-middle .modern-tap-target-ui .icon-button {background-color: rgba(0,0,0,0.15) !important}
  157.  
  158. /* player tip scrubber popup */
  159. .tooltip-wrapper {display: none !important}
  160.  
  161. /* make more space for the video content */
  162. .player-controls-pb {left: 15px !important; right: 15px !important}
  163. ytm-custom-control .player-controls-bottom {left: 0 !important; right: 0 !important}
  164. ytm-custom-control .player-controls-top {top: -8px !important}
  165.  
  166.  
  167. /* muted video popup */
  168. .ytp-unmute-animated .ytp-unmute-icon {border-bottom: none !important;border-radius: 50px !important;background-color: rgba(255, 255, 255, 0.4) !important}
  169. .ytp-unmute-shrink .ytp-unmute-text {opacity: 0 !important}
  170. .ytp-unmute-shrink .ytp-unmute-box {width: 0 !important}
  171.  
  172.  
  173. /* comments */
  174. .modern-styling {margin:0 !important}
  175. ytm-comments-simplebox-renderer {display: none !important}
  176. .draggable .engagement-panel-section-list-header {border:none !important}
  177. ytm-comment-renderer {padding:0 !important}
  178. ytm-comment-thread-renderer {padding:0 !important}
  179. .comment-content {padding: 0 4px !important}
  180. ytm-comment-replies-renderer {margin:0 !important}
  181. .comment-simplebox-placeholder {border: none !important}
  182. .comments-simplebox-placeholder {background: none !important}
  183. ytm-comments-simplebox-renderer {padding:0 !important}
  184. .rich-grid-sticky-header { display: none !important}
  185. ytm-comment-renderer .comment-expand {padding: 0 !important}
  186. ytm-comment-renderer .comment-details {margin: 0 !important}
  187.  
  188.  
  189. /* comments menu button */
  190. .comment-menu:not(hover) {opacity: 0 !important}
  191.  
  192. /* landscape comments panel */
  193. @media (min-width: 931px) and (orientation: landscape) {ytm-engagement-panel {width: 40% !important}}
  194. /* landscape sidebar recommendations */
  195. @media (min-width: 931px) and (orientation: landscape) {ytm-single-column-watch-next-results-renderer [section-identifier="related-items"] {padding:0 !important}}
  196. @media (min-width: 931px) and (orientation: landscape) {ytm-single-column-watch-next-results-renderer [section-identifier="related-items"] .item {padding:0 !important}}
  197.  
  198. /* submit comment field */
  199. ytm-comments-header-renderer {display: none !important}
  200.  
  201.  
  202.  
  203. /* search info-panel */
  204. ytm-info-panel-container-renderer {display: none !important}
  205.  
  206.  
  207. /* chips bar under player */
  208. ytm-chip-cloud-renderer.chip-bar {background-color: transparent !important; border: none !important}
  209.  
  210.  
  211. /* Shorts */
  212.  
  213. .logo-in-player-endpoint {opacity: 0 !important}
  214. .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}
  215. .yt-subscribe-button-view-model-wiz__container {display: none !important}
  216.  
  217.  
  218.  
  219. /* Title under player */
  220. .slim-video-metadata-header .slim-video-information-content.slim-video-information-empty-badge {padding:0 !important}
  221. ytm-slim-video-metadata-section-renderer ytm-slim-owner-renderer {padding-top: 0 !important}
  222.  
  223. /* additional info panel under player */
  224. ytm-clarification-renderer.item {display: none !important}
  225.  
  226.  
  227. /* padding uploader avatar and subscribe button */
  228. ytm-slim-video-metadata-section-renderer ytm-slim-owner-renderer {padding: 0 !important}
  229. .slim-owner-profile-icon {margin-right: 2px !important}
  230.  
  231.  
  232. /* action buttons spacing */
  233. .yt-spec-button-shape-next--mono.yt-spec-button-shape-next--tonal {background: rgba(0,0,0,.05) !important}
  234. .yt-spec-button-shape-next--size-m {padding: 0 6px !important; height: 33px !important}
  235. .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}
  236. /* downvotes arent shown anyway */
  237. .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}
  238. .slim-video-action-bar-actions {padding: 3px 3px !important}
  239.  
  240.  
  241. /* includes paid promotion */
  242. .YtmPaidContentOverlayLink {display: none !important}
  243. `);
  244. }