GitHub - single-column repository page with important info on the top

Pulls Readme above files list and reorganizes repository root page moving sidebar content foremost.

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

  1. /* ==UserStyle==
  2. @name GitHub - single-column repository page with important info on the top
  3. @namespace myfonj
  4. @version 1.12.3
  5. @description Pulls Readme above files list and reorganizes repository root page moving sidebar content foremost.
  6. @author myf
  7. @license CC0
  8. ==/UserStyle== */
  9. @-moz-document domain("github.com") {
  10. /*
  11. https://userstyles.world/style/5069/github-repository-page-in-single-column-with-important-info-on-the-top
  12. https://greasyfork.org/en/scripts/406729/versions/new
  13. Changelog
  14. 1.12.3 (2023-12-13) - total commit count and last commit time pulled to the left edge
  15. 1.12.2 (2023-12-12) - also rushed pulling of "last commit" info, for now above readme - license - (...) - edit - menu line
  16. 1.12.0 (2023-12-12) - rushed hotfix for new main content structure, readme is back up. Ton of dead code remains.
  17. 1.11.1 (2023-11-15) - restore compacting stuff under tags (license, CoC, ... icons) after structure change (new wrapper)
  18. 1.11.0 (2023-09-25) - Hide redundant ☆ / 👁 / 🜉 + counts under tags.
  19. 1.10.0 (2023-09-25) - Hide "No releases published" / "No packages published" boxes
  20. 1.9.4 (2023-09-20) - prevent links under tags wrapping between words
  21. 1.9.3 (2023-09-07) - wider "About" box, narrower rest, icons-(+ counts)-only footer
  22. 1.9.2 (2023-08-15) - max-width for header
  23. 1.9.1 (2023-07-13) - fix superfluous line break in resources (`include-fragment`)
  24. 1.9.0 (2023-06-22) - readme pulled to top even on subpages; requires modern Chromium or Firefox with `layout.css.has-selector.enabled` pref
  25. 1.8.4 (2023-03-03) - hopefuly applied even for "turbopages"
  26. 1.8.3 (2022-08-11) - just name and info changes
  27. */
  28. /* just for categorization */
  29. /* … and this little photo zoom */
  30. .Popover .avatar-user {
  31. min-width: 240px;
  32. min-height: 240px;
  33. /* image-rendering: crisp-edges */
  34. }
  35. /* … and pulling the readme at code pages deeper */
  36. main div:has(> #readme) {
  37. /* wohohoo, new era of usestyling just arrived. */
  38. order: -1;
  39. }
  40. }
  41. @-moz-document regexp("^https?://github.com/(?!password_reset|settings)([^#?/]+)/([^#?/]+)/?([#?].*)?$") {
  42. /*
  43. examples
  44. https://github.com/mmulet/code-relay
  45. few contributors, many columns
  46. https://github.com/mozilla/readability
  47. used by ..
  48. https://github.com/GoogleChromeLabs/dark-mode-toggle
  49. many tags, much everything
  50. https://github.com/WebReflection/sqlite-worker
  51. five columns
  52. https://github.com/rilwis/bamboo
  53. fork, just two columns
  54. https://github.com/mozilla/standards-positions
  55. no about, no tags
  56. https://github.com/mcmilk/7-Zip-zstd/
  57. sponsor
  58. https://github.com/mdn/mdn-minimalist
  59. no readme TOC
  60. `.repository-content` class is actually unreliable, since it is not present for ajaxified turbonavigations
  61. using `#repository-container-header + *` instead
  62. that `*` seems like
  63. <turbo-frame id="repo-content-turbo-frame" target="_top" data-turbo-action="advance" class="">
  64. <div id="repo-content-pjax-container" class="repository-content ">
  65. */
  66. /* header block nentred
  67. */
  68. .AppHeader > * {
  69. max-width: 1280px;
  70. margin: auto;
  71. }
  72. /* unify main max width and centering of the main blocks
  73. */
  74. main > div {
  75. max-width: none !important;
  76. max-width: 80rem !important;
  77. max-width: 90rem !important;
  78. margin-left: auto;
  79. margin-right: auto;
  80. }
  81. /* Header row with name, description for mobile, tabs, etc */
  82. main > div:first-child {
  83. display: flex;
  84. flex-direction: column;
  85. background-color: transparent !important;
  86. padding-top: 0 !important;
  87. }
  88. /* "Tabs" (Code , PRs, Actions, ... ) pull above main heading */
  89. main > div:first-child > nav {
  90. order: -1;
  91. margin-bottom: 1rem;
  92. }
  93. /* main "columns" wrapper (files | sidebar) - convert to reversed rows */
  94. #repository-container-header + * .Layout {
  95. display: flex !important;
  96. flex-direction: column-reverse !important;
  97. }
  98. /* Files, Sidebar - now rows*/
  99. #repository-container-header + * .Layout > div {
  100. width: auto;
  101. }
  102. /*
  103. main column - wrapper of:
  104. - file navigation (branches, tags left, goto, file right)
  105. - files (moved to bottom, except for 1. "row" with latest commit positioned to file navigation)
  106. - readme (moved under file navigation)
  107. */
  108. #repository-container-header + * .Layout > .Layout-main {
  109. position: relative;
  110. display: flex;
  111. flex-direction: column;
  112. }
  113. #repository-container-header + * .Layout > .Layout-main > .file-navigation {
  114. order: -2;
  115. }
  116. /*
  117. Readme - move before files files
  118. there are two kinds of readme blocks:
  119. - "fancy" readme-toc component with kebab menu of headings (introduced around 2021-03-26)
  120. - see e.g. https://github.com/SerenityOS/serenity
  121. - "normal" div#readme
  122. - see e.g. https://github.com/mozilla/readability
  123. */
  124. #repository-container-header + * .Layout > .Layout-main > readme-toc,
  125. #repository-container-header + * .Layout > .Layout-main > #readme {
  126. order: -1;
  127. }
  128. /* sticky "README.md" heading / TOC box make simple button */
  129. #repository-container-header + * .Layout > .Layout-main > readme-toc > #readme > :first-child {
  130. display: inline-flex !important;
  131. border: none !important;
  132. background-color: transparent !important
  133. /**/
  134. }
  135. /* "readme.md" label/link heading after TOC button: hide */
  136. #repository-container-header + * .Layout > .Layout-main > readme-toc > #readme > :first-child h2 {
  137. display: none;
  138. }
  139. /* actual readme box: push up into place freed by heading / TOC box */
  140. #repository-container-header + * .Layout > .Layout-main > readme-toc > #readme > :last-child{
  141. margin-top: -3rem
  142. }
  143. /* readme - line length limit (originnaly 1012px through .container-lg) */
  144. #repository-container-header + * .Layout > .Layout-main > readme-toc > #readme article.markdown-body.entry-content {
  145. max-width: 80ch;
  146. }
  147. /*
  148. sidebar - now top content
  149. for god's sake, THIS div should be MAIN and should be near H1 or something
  150. not suffocated at the end of the document in sidebar
  151. */
  152. #repository-container-header + * .Layout > .Layout-sidebar > div {
  153. display: flex;
  154. flex-direction: row;
  155. /* let's try without
  156. flex-wrap: wrap;
  157. now */
  158. padding-bottom: 1rem;
  159. }
  160. /* all main flex items (about .. languages)*/
  161. #repository-container-header + * .Layout > .Layout-sidebar > div > * {
  162. flex-grow: 1;
  163. flex-shrink: 1;
  164. flex-basis: 0;
  165. border-left: 1px solid var(--color-border-secondary);
  166. border-left: none;
  167. padding-left: .5rem;
  168. padding-right: .5rem;
  169. padding-bottom: 1rem;
  170. }
  171. /*
  172. first "about" cell
  173. */
  174. #repository-container-header + * .Layout > .Layout-sidebar > div:first-child > div:first-child {
  175. flex-basis: 50ch;
  176. flex-grow: 2;
  177. max-width: 80ch;
  178. border-left: none;
  179. padding-left: 0;
  180. }
  181. /* 📖 Readme ⚖️ License : condense, icons-(+ counts)-only footer */
  182. /* those h3 are .sr-only, preceding divs and `include-fragment` */
  183. #repository-container-header + * .Layout > .Layout-sidebar > div:first-child > div:first-child > div h3 ~ * {
  184. display: inline;
  185. font-size: 0;
  186. line-height: 1rem;
  187. & strong,
  188. & a[href$="/LICENSE"],
  189. & a:not(:has(svg)){
  190. font-size: 1rem;
  191. white-space: nowrap !important;
  192. }
  193. &:has(svg)::after {
  194. content: '\A0';
  195. font-size: 1rem;
  196. }
  197. /*
  198. Hide redundant ☆ / 👁 / 🜉 + counts under tags.
  199. They are present in the header already, and better.
  200. */
  201. &:has(
  202. a[href$="/stargazers"],
  203. a[href$="/watchers"],
  204. a[href$="/forks"]
  205. ) {
  206. display: none !important
  207. }
  208. }
  209. /* unnecessary 🔗 link icon, may cause wrap, hide */
  210. #repository-container-header + * .Layout > .Layout-sidebar > div:first-child > div:first-child .octicon-link {
  211. display: none;
  212. }
  213. /* last "(programming) languages" cell */
  214. #repository-container-header + * .Layout > .Layout-sidebar > div:first-child > div:last-child {
  215. /*
  216. flex-shrink: 100;
  217. flex-grow: 0;
  218. /* let's try without limiting */
  219. }
  220. /* Contributors "grid" min three in rows (to not get a two or single row skyscraper) */
  221. #repository-container-header + * .Layout > .Layout-sidebar > div:first-child h2 + ul {
  222. min-width: 8rem !important;
  223. }
  224. /* no border nor paddings */
  225. #repository-container-header + * .Layout > .Layout-sidebar > div > div > div {
  226. border: none;
  227. padding: 0;
  228. }
  229. /* headings */
  230. #repository-container-header + * .Layout > .Layout-sidebar > div > div > div > h2 ,
  231. #repository-container-header + * .Layout > .Layout-sidebar > div > div > div > h2 > a {
  232. white-space: nowrap !important;
  233. }
  234. /* tags in about cell - restack and dim */
  235. #repository-container-header + * .Layout > .Layout-sidebar > div:first-child > div .f6:not(:hover) {
  236. opacity: 0.5;
  237. }
  238. #repository-container-header + * .Layout > .Layout-sidebar > div:first-child > div .f6 {
  239. display: flex;
  240. flex-wrap: wrap;
  241. }
  242. #repository-container-header + * .Layout > .Layout-sidebar > div:first-child > div .f6 > * {
  243. flex-grow: 1;
  244. text-align: center;
  245. }
  246. /* "used by 108" - make 8 avatars wrap */
  247. .hx_flex-avatar-stack {
  248. flex-wrap: wrap;
  249. max-width: 10rem;
  250. padding-right: .8rem;
  251. }
  252. /* allowing wrap of counter under "used by" avatars */
  253. #repository-container-header + * .Layout > .Layout-sidebar > div:first-child > div .d-flex.flex-items-center {
  254. flex-wrap: wrap;
  255. }
  256. /*
  257. un-truncating everything to allow wrapping of long (esp. in "releases" cell
  258. affects "releases", but whatever
  259. */
  260. #repository-container-header + * .Layout > .Layout-sidebar > div > * * {
  261. white-space: normal !important;
  262. }
  263. /* un-flexing latest release */
  264. #repository-container-header + * .Layout > .Layout-sidebar > div > * .Link--primary.d-flex * { display: block !important}
  265.  
  266. /* superfluous link icon in "sponsor this project" */
  267. #repository-container-header + * .Layout > .Layout-sidebar > div > * [style="min-width:32px;height:32px;"] {
  268. display: none !important;
  269. }
  270. /* environments "active" tag below text */
  271. #repository-container-header + * .Layout > .Layout-sidebar > div > * h2 + .list-style-none li .Label {
  272. display: block;
  273. }
  274.  
  275. /*
  276. § Hide "No releases published" / "No packages published" boxes.
  277. */
  278. #repository-container-header + * .Layout > .Layout-sidebar > div > div.BorderGrid-row:has(
  279. > .BorderGrid-cell:only-child
  280. > h2:first-child /* :has( a[href$="/releases"]) */
  281. + div.text-small.color-fg-muted:last-child
  282. ) {
  283. display: none;
  284. }
  285.  
  286.  
  287.  
  288. /*
  289. last commit & "commits" link
  290. normally above files table, moving into file navigation
  291. */
  292. #repository-container-header + * .Layout > .Layout-main > *:not([id]) > .Box-header {
  293. position: absolute !important;
  294. padding: 0;
  295. top: .33rem;
  296. border: none;
  297. left: 16rem; /* space for branch selector, branches, tags */
  298. right: 21rem; /* space for Go to file, Add file, Code/clone */
  299. background-color: transparent !important;
  300. z-index: 90; /* for "..." unfolding */
  301. }
  302. /* unnecesary non-TOC "readme.md" heading box */
  303. #repository-container-header + * .Layout > .Layout-main > [id="readme"] > .Box-header:first-child { display: none !important; }
  304. /* hide hash */
  305. #repository-container-header + * .Layout > .Layout-main .Box-header .text-mono {
  306. display: none !important
  307. }
  308. /* reverse order so commit count ends up beside tag count */
  309. #repository-container-header + * .Layout > .Layout-main .Box-header > div > :last-child {
  310. order: -1;
  311. padding-right: 1rem;
  312. }
  313. /* hide "commits" text (lave icon) (more space for last commit msg) */
  314. #repository-container-header + * .Layout > .Layout-main .Box-header > div > :last-child .color-text-secondary {
  315. display: none !important;
  316. }
  317. /* hide "branches" and "tags" text (lave icons) (more space for last commit msg) */
  318. .file-navigation .color-text-tertiary{
  319. display: none;
  320. }
  321. /*
  322. hide word "commits", "tags", "branches" after counts
  323. */
  324. svg[aria-hidden="true"]:first-child + strong:not(:hover) + span:last-child {
  325. font-size: 0;
  326.  
  327. }
  328. svg[aria-hidden="true"]:first-child + span:last-child:not(:hover) > strong:first-child + span:last-child {
  329. font-size: 0;
  330. }
  331.  
  332. /*
  333. (just trying) see wide tables without scrolling them
  334. */
  335. .markdown-body table {
  336. overflow: visible;
  337. }
  338.  
  339.  
  340. /**
  341. 2023-12-11
  342. new structure, totally turdy
  343. rushed hotfix
  344. readme first
  345. **/
  346. [data-selector="repos-split-pane-content"]{
  347. margin: 0;
  348. max-width: none;
  349. & div:has(>div>h2#folders-and-files) {
  350. order: 1;
  351. }
  352. /*
  353. "last commit" info: pull between header and readme
  354. */
  355. table[aria-labelledby="folders-and-files"] > tbody > tr:first-child > td[colspan="3"]:only-child > div {
  356. xoutline: #0FF6 solid;
  357. xoutline-offset: -2px;
  358. position: absolute;
  359. top: -2.6rem;
  360. left: 0rem;
  361. z-index: 1;
  362. padding-inline: 0;
  363. xborder: 1px solid color-mix(in srgb, transparent 70%, currentcolor);
  364. /*
  365. that "~more info" dropdown opened by "…" button
  366. */
  367. & + div {
  368. top: 6.7rem;
  369. }
  370. /*
  371. move total commits count and last commit time to the left
  372. */
  373. & relative-time,
  374. & *:has(>[aria-label="Commit history"]),
  375. & [aria-label="Commit history"] {
  376. order: -1;
  377. }
  378. /*
  379. fix separators and spacing
  380. */
  381. & [aria-label="Commit history"] {
  382. margin-left: -12px
  383. }
  384. & :has(> relative-time) {
  385. /* removing the ' · ' */
  386. font-size: 0;
  387. /* and put it back; */
  388. & > * {
  389. font-size: var(--body-font-size, 0.875rem);
  390. }
  391. & relative-time {
  392. &::before { content: 'Last '; opacity: .7; }
  393. &::after { content: ': '; }
  394. }
  395. }
  396. }
  397. }
  398.  
  399. /* END */
  400. }