Twitter.com: un-trim images on hover

Reveal cropped portions of content while post is under mouse pointer.

当前为 2021-12-13 提交的版本,查看 最新版本

  1. /* ==UserStyle==
  2. @name Twitter.com: un-trim images on hover
  3. @description Reveal cropped portions of content while post is under mouse pointer.
  4. @namespace myfonj
  5. @version 1.0.14
  6. @license CC0 - Public Domain
  7. ==/UserStyle== */
  8.  
  9. @-moz-document domain("twitter.com") {
  10. /*
  11. Twitter.com: un-trim images on hover
  12.  
  13. https://greasyfork.org/en/scripts/402913/versions/new
  14. https://userstyles.org/styles/175427/edit
  15. div[aria-label^="Timeline: "] > div > div
  16. = "post item"
  17. */
  18. /*
  19. let the spice flow. over.
  20. */
  21. div[aria-label^="Timeline: "] > div > div:hover {
  22. overflow: visible !important;
  23. z-index: 10;
  24. }
  25. div[aria-label^="Timeline: "] > div > div:hover * {
  26. overflow: visible !important;
  27. }
  28. /*
  29. directly hovered position something always above its unhovered siblings
  30. */
  31. div[aria-label^="Timeline: "] > div > div:hover *:hover {
  32. z-index: 20;
  33. }
  34. /*
  35. counters covered by box would be inaccessible, move them above and make 'em transparent ...
  36. */
  37. div[aria-label^="Timeline: "] > div > div:hover [role="group"],
  38. div[aria-label^="Timeline: "] > div > div:hover [role="link"][data-focusable="true"][href$="/media_tags"] {
  39. z-index: 30;
  40. opacity: 0;
  41. }
  42.  
  43. /* tweet actions */
  44. div[aria-label^="Timeline: "] > div > div:hover [role="group"] {
  45. outline: 20px solid rgba(0, 0, 0, 0.5);
  46. background-color: rgba(0, 0, 0, 0.5);
  47. }
  48. /*
  49. ... until hovered
  50. */
  51. div[aria-label^="Timeline: "] > div > div:hover [role="group"]:hover,
  52. div[aria-label^="Timeline: "] > div > div:hover [role="link"][data-focusable="true"][href$="/media_tags"]:hover {
  53. opacity: 1 !important;
  54. }
  55.  
  56. /*
  57. fix for external link badge text underlayed by illustration producing non-contrasting text
  58. */
  59. div[aria-label^="Timeline: "] > div > div:hover a[href^="https://t.co/"][href$="?amp=1"][target="_blank"][role="link"][data-focusable="true"][rel=" noopener noreferrer"]:hover {
  60. background-color: rgba(0, 0, 0, 0.5);
  61. }
  62. /* tweet text */
  63. div[aria-label^="Timeline: "] > div > div [style^="flex-basis"] + div [dir][lang]:hover,
  64. div[aria-label^="Timeline: "] > div > div [style^="flex-basis"]:hover + div [dir][lang] {
  65. z-index: 30;
  66. background-color: rgba(0, 0, 0, 0.5);
  67. border-left: 10px solid transparent;
  68. margin-left: -10px;
  69. }
  70. /*
  71. this is it - this *invisible* image just sits there covering div with very same image as background,
  72. "squeezed" into wrapper. so let's unleash it while invisible to gain some performace
  73. */
  74. div[aria-label^="Timeline: "] > div > div [aria-label] > img {
  75. width: auto !important;
  76. height: auto !important;
  77. max-width: calc(100vw - 20em) !important;
  78. /* too lazy to measure sidebar for now */
  79. min-width: calc(100%) !important;
  80. /* sometimes there is small pic that would otherwise downscale */
  81. outline: 3px solid black;
  82. z-index: 100 !important;
  83. }
  84. /*
  85. tadaa, real pic an all its glory. most probably bigger
  86. */
  87. div[aria-label^="Timeline: "] > div > div:hover [aria-label] > img {
  88. opacity: 1 !important;
  89. }
  90. div[aria-label^="Timeline: "] > div > div:hover [aria-label] > img:hover {
  91. box-shadow: rgba(217, 217, 217, 0.2) 0px 0px 10px, rgba(217, 217, 217, 0.25) 0px 3px 6px 3px;
  92. }
  93.  
  94. /* 2020-06 - avatars in timeline started to follow same principle, so became hover "jumpy"
  95. since we are zooming them in detail popups anyway, just be dirty and brutal for now
  96. 2021-03-11 switched to super general SRC URL matching logic
  97. */
  98. div[aria-label^="Timeline: "]:not(#\0) [style*="pbs.twimg.com/profile_images"] + img[src*="pbs.twimg.com/profile_images"],
  99. div[aria-label^="Timeline: "]:not(#\0) [style*="/default_profile_images/"] + img[src*="/default_profile_images/"] {
  100. display: none !important;
  101. outline: 1px solid red !important;
  102. }
  103.  
  104. /*
  105. Increase size of avatar pictures in hover popup
  106. this is hell to debug, so please dont't judge
  107. the popup has bottom/top according relative placement in viewport
  108. 2021-04-06 they removed [tabindex="-1"]
  109. * OFF 2021-12-13 - they switched to [style*='clip-path: url("#circle-hw-shapeclip-clipconfig")'] mangledness
  110. /
  111. [style*="left: "] a[role="link"][aria-hidden="true"],
  112. [style*="left: "] a[role="link"][aria-hidden="true"] * {
  113. min-height: 12em !important;
  114. min-width: 12em !important;
  115. margin: 0 !important;
  116. padding: 0 !important;
  117. background-size: contain;
  118. }
  119. /* */
  120.  
  121. /*
  122. fix video player controls
  123. since it is serious mess, lets adore the emphemeral structure I had to sieve trough:
  124. */
  125. /*
  126. // for ilustration, where it begins. from here it is just classes copied from devtools
  127. (unreliable I assume) and some hand copied attributes
  128. html
  129. > body>
  130. > div#react-root
  131. > div.css-1dbjc4n.r-13awgt0.r-12vffkv
  132. > div.css-1dbjc4n.r-13awgt0.r-12vffkv
  133. > div.css-1dbjc4n.r-18u37iz.r-13qz1uu.r-417010
  134. > main.css-1dbjc4n.r-1habvwh.r-16xksha.r-1wbh5a2
  135. > div.css-1dbjc4n.r-150rngu.r-16y2uox.r-1wbh5a2.r-33ulu8
  136. > div.css-1dbjc4n.r-aqfbo4.r-16y2uox
  137. > div.css-1dbjc4n.r-1oszu61.r-1niwhzg.r-18u37iz.r-16y2uox.r-1wtj0ep.r-2llsf.r-13qz1uu
  138. > div.css-1dbjc4n.r-yfoy6g.r-18bvks7.r-1ljd8xs.r-13l2t4g.r-1phboty.r-1jgb5lz.r-11wrixw.r-61z16t.r-1ye8kvj.r-13qz1uu.r-184en5c
  139. > div.css-1dbjc4n
  140. > div.css-1dbjc4n
  141. > div.css-1dbjc4n.r-16y2uox
  142. > div.css-1dbjc4n.r-1jgb5lz.r-1ye8kvj.r-13qz1uu
  143. > div.css-1dbjc4n
  144. > section.css-1dbjc4n
  145. > div.css-1dbjc4n[aria-label^="Timeline: "]:not([REM="yup, this is the timeline"])
  146. > div[style^="position: relative; min-height: "][style$="px;"]
  147. > div[style^="position: absolute; width: 100%; transform: translateY("][style$="px); transition: opacity 0.3s ease-out 0s;"]:not([REM="THIS IS ACTUAL POST WRAPPER"])
  148. > div.css-1dbjc4n.r-1ila09b.r-qklmqi.r-1adg3ll.r-1ny4l3l
  149. > div.css-1dbjc4n
  150. > article.css-1dbjc4n.r-1loqt21.r-18u37iz.r-1ny4l3l.r-o7ynqc.r-6416eg
  151. > div.css-1dbjc4n.r-eqz5dr.r-16y2uox.r-1wbh5a2
  152. > div.css-1dbjc4n.r-16y2uox.r-1wbh5a2.r-1ny4l3l.r-1udh08x.r-1yt7n81.r-ry3cjt
  153. > div.css-1dbjc4n
  154. > div.css-1dbjc4n.r-18u37iz
  155. > div.css-1dbjc4n.r-1iusvr4.r-16y2uox.r-1777fci.r-1mi0q7o
  156. > div.css-1dbjc4n
  157. > div.css-1dbjc4n
  158. > div[class]:only-child
  159. > div[class]:only-child
  160. > div[class]:only-child
  161. > div[class]:only-child
  162. |
  163. _______________________________________________________________/
  164. / from here on just "reliable" attributes and pseudo-structure
  165. |
  166. > div[style="padding-bottom: 56.25%;"]:first-child
  167. + div:last-child
  168. > div[data-testid="placementTracking"]
  169. > div[data-testid="videoPlayer"]
  170. > div
  171. > div[style="padding-bottom: 56.25%;"]:first-child
  172. + div:last-child
  173. > div[style="height: 100%; position: relative; transform: translateZ(0px); width: 100%;"]
  174. > div[style="height: 100%; position: absolute; width: 100%;"]:not([class]):first-child
  175. > div[style="position: relative; width: 100%; height: 100%; background-color: transparent; overflow: hidden;"]
  176. > video:not([REM="OMG, here is the video"])
  177. + div:not([style]):last-child
  178. > div:not([class]):only-child
  179. > div:first-child:not([REM="this is the bugger I couldn't push under the video controls"])
  180. + div:not([class])
  181. + div:not([class])
  182. + div:not([class])
  183. > div[style="transition-duration: 250ms; transition-property: opacity, height; transition-timing-function: ease; will-change: opacity; opacity: 1;"]
  184. > div[class]
  185. > div[style="background-image: linear-gradient(transparent, rgba(0, 0, 0, 0.77));"]
  186. > div:first-child:not([REM="this is progress / seeker wrapper"])
  187. + div:last-child:not([REM="this is video controls wrapper"])
  188. */
  189.  
  190. div[style^="padding-bottom: "][style$="%;"]:first-child
  191. + div:last-child
  192. > div[data-testid="placementTracking"]
  193. > div[data-testid="videoPlayer"]
  194. > div
  195. > div[style^="padding-bottom: "][style$="%;"]:first-child
  196. + div:last-child
  197. > div[style="height: 100%; position: relative; transform: translateZ(0px); width: 100%;"]
  198. > div[style="height: 100%; position: absolute; width: 100%;"]:not([class]):first-child
  199. + div:not([style]):last-child
  200. > div:not([class]):only-child
  201. > div:first-child:not([REM="this is the bugger I couldn't push under the video controls"])
  202. {
  203. z-index: 0;
  204. }
  205. /*
  206. [:shivers:]
  207. */
  208.  
  209. /*
  210. § dim sidebar until hovered
  211. */
  212. [data-testid="sidebarColumn"]:not(:hover) {
  213. opacity: .7
  214. }
  215.  
  216. /*
  217. § old school "inacessible" follow buttons - use primary "white on blue" instead of black on white
  218. */
  219. div[role="button"][tabindex="0"][aria-label^="Follow @"] {
  220. background-color: rgb(29, 161, 242) !important;
  221. }
  222. div[role="button"][tabindex="0"][aria-label^="Follow @"]:focus,
  223. div[role="button"][tabindex="0"][aria-label^="Follow @"]:hover {
  224. background-color: rgb(19, 141, 212) !important;
  225. }
  226. div[role="button"][tabindex="0"][aria-label^="Follow @"] * {
  227. color: #fff !important;
  228. }
  229.  
  230. div[role="button"][tabindex="0"][aria-label^="Following @"] {
  231. background-color: darkgreen !important;
  232. }
  233. div[role="button"][tabindex="0"][aria-label^="Following @"]:hover ,
  234. div[role="button"][tabindex="0"][aria-label^="Following @"]:focus {
  235. background-color: darkred !important;
  236. }
  237. div[role="button"][tabindex="0"][aria-label^="Following @"] * {
  238. color: #fff !important;
  239. }
  240.  
  241.  
  242. }