pixiv Comments Section Space Saving

Reduces margins and adds horizontal lines to reflect previous layout.

  1. /* ==UserStyle==
  2. @name pixiv Comments Section Space Saving
  3. @name:ja pixiv コメント欄を省スペース化
  4. @description Reduces margins and adds horizontal lines to reflect previous layout.
  5. @description:ja 余白を修正し、以前のような水平線区切りのデザインにします。
  6. @namespace https://greasyfork.org/users/137
  7. @version 5.4.0
  8. @license MPL-2.0
  9. @contributionURL https://www.amazon.co.jp/registry/wishlist/E7PJ5C3K7AM2
  10. @compatible Edge
  11. @compatible Firefoxを推奨 / Firefox is recommended
  12. @compatible Opera
  13. @compatible Chrome
  14. @author 100の人
  15. @homepageURL https://greasyfork.org/scripts/412706
  16. ==/UserStyle== */
  17.  
  18. @namespace url(http://www.w3.org/1999/xhtml);
  19.  
  20. @-moz-document regexp("https://www\\.pixiv\\.net/(?:artworks/[0-9]+(?:[?#].*)?|novel/show\\.php\\?(?:[^#]*&)?id=[0-9]+(?:[&#].*)?)") {
  21. /*====================================
  22. コメント欄
  23. */
  24. main h2 ~ div:nth-of-type(2) > ul {
  25. --pixiv-border-width: 1px;
  26. --pixiv-border-style: solid;
  27. --pixiv-border-color: #D6DEE5;
  28. --comment-padding: 0.2em;
  29. --meta-line-height: 16px;
  30. --pixiv-color: #333;
  31. --author-comment-background: lavenderblush;
  32. }
  33.  
  34. .fKkgNY ~ * main h2 ~ div:nth-of-type(2) > ul {
  35. /* ダークテーマ */
  36. --pixiv-color: white;
  37. --author-comment-background: #666065;
  38. }
  39. /*------------------------------------
  40. 余白を修正
  41. */
  42. #root main h2 ~ div:nth-of-type(2) li {
  43. margin-top: unset;
  44. margin-bottom: unset;
  45. }
  46. main h2 ~ div:nth-of-type(2) > ul > li > div > div > div:nth-of-type(1),
  47. main h2 ~ div:nth-of-type(2) li li > div /* 返信コメント */ {
  48. position: relative;
  49. padding: var(--comment-padding);
  50. padding-bottom: calc(var(--comment-padding) + var(--pixiv-border-width));
  51. border: var(--pixiv-border-width) var(--pixiv-border-color);
  52. border-top-style: var(--pixiv-border-style);
  53. margin-top: calc(var(--pixiv-border-width) * -1);
  54. }
  55. main h2 ~ div:nth-of-type(2) > ul > li:last-of-type {
  56. border-bottom: var(--pixiv-border-width) var(--pixiv-border-style) var(--pixiv-border-color);
  57. }
  58. main h2 ~ div:nth-of-type(2) :is(li > div > div, li li) > div:nth-of-type(1) > div:nth-of-type(2) {
  59. display: grid;
  60. grid-template:
  61. "name date"
  62. "body body"
  63. / max-content 1fr;
  64. grid-column-gap: 0.5em;
  65. }
  66. main h2 ~ div:nth-of-type(2) :is(li > div > div, li li) > div:nth-of-type(1) > div:nth-of-type(2) > div:nth-of-type(1) {
  67. grid-area: name;
  68. }
  69. main h2 ~ div:nth-of-type(2) :is(li > div > div, li li) > div:nth-of-type(1) > div:nth-of-type(2) > div:nth-of-type(2) {
  70. grid-area: body;
  71. margin-top: unset;
  72. width: 100%; /* 長い単語等が含まれていると親からはみ出る問題に対処 */
  73. }
  74. main h2 ~ div:nth-of-type(2) :is(li > div > div, li li) > div:nth-of-type(1) > div:nth-of-type(2) > div:nth-of-type(3) {
  75. grid-area: date;
  76. line-height: var(--meta-line-height);
  77. }
  78. main h2 ~ div:nth-of-type(2) :is(li > div > div, li li) > div:nth-of-type(1) > div:nth-of-type(2) > div:nth-of-type(3) > span:nth-of-type(2) {
  79. display: none;
  80. }
  81. main h2 ~ div:nth-of-type(2) :is(li > div > div, li li) > div:nth-of-type(1) > div:nth-of-type(2) > div:nth-of-type(3) > span:nth-of-type(3) {
  82. /* 返信ボタン */
  83. position: absolute;
  84. top: var(--comment-padding);
  85. right: var(--comment-padding);
  86. display: none;
  87. }
  88. main h2 ~ div:nth-of-type(2) > ul > li > div > div > div:nth-of-type(1):hover > .ui-profile-popup + div > div:nth-of-type(3) > span:nth-of-type(3),
  89. main h2 ~ div:nth-of-type(2) li li:hover .ui-profile-popup + div > div:nth-of-type(3) > span:nth-of-type(3) /* 返信コメント */ {
  90. display: inline;
  91. }
  92. /*------------------------------------
  93. ユーザー名にユーザーページへのリンク
  94. */
  95. main h2 ~ div:nth-of-type(2) .ui-profile-popup {
  96. --user-icon-width: 40px;
  97. --user-icon-right-margin: 8px;
  98. color: var(--pixiv-color);
  99. }
  100. main h2 ~ div:nth-of-type(2) .ui-profile-popup::after {
  101. content: attr(data-user_name);
  102. position: absolute;
  103. top: var(--comment-padding);
  104. left: calc(var(--comment-padding) + var(--user-icon-width) + var(--user-icon-right-margin));
  105. font-weight: bold;
  106. display: block;
  107. line-height: var(--meta-line-height);
  108. }
  109. main h2 ~ div:nth-of-type(2) li li .ui-profile-popup {
  110. /* 返信コメント */
  111. --user-icon-width: 32px;
  112. }
  113. main h2 ~ div:nth-of-type(2) :is(li > div > div, li li) > div:nth-of-type(1) > div:nth-of-type(2) > div:nth-of-type(1) {
  114. color: transparent;
  115. }
  116. /*------------------------------------
  117. 削除されたユーザーのアイコン
  118. */
  119. main h2 ~ div:nth-of-type(2) .ui-profile-popup[data-user_name=""] {
  120. opacity: 0.4;
  121. }
  122. /*------------------------------------
  123. 作者コメント強調方法の修正
  124. */
  125. main h2 ~ div:nth-of-type(2) > ul > li > div > div > div:nth-of-type(1),
  126. main h2 ~ div:nth-of-type(2) li li > div /* 返信コメント */ {
  127. z-index: 0;
  128. }
  129. main h2 ~ div:nth-of-type(2) li .l6DTSU_ {
  130. background: var(--author-comment-background);
  131. color: transparent;
  132. z-index: -1;
  133. border-radius: unset;
  134. margin: unset;
  135. position: absolute;
  136. top: 0;
  137. right: 0;
  138. bottom: 0;
  139. left: 0;
  140. }
  141. main h2 ~ div:nth-of-type(2) > ul > li > div > div > div:nth-of-type(1) .l6DTSU_ {
  142. /* 作者コメントが返信元であった場合用 */
  143. border-bottom: var(--pixiv-border-width) var(--pixiv-border-style) var(--pixiv-border-color);
  144. }
  145. main h2 ~ div:nth-of-type(2) > ul > li:last-of-type > div > div > div:nth-of-type(2) > div:empty {
  146. /* 作者コメント、一番下のコメント、かつ返信がなければ */
  147. margin-bottom: calc(var(--pixiv-border-width) * -1);
  148. }
  149. }