1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

User CSS で Dark Mode

Last updated at Posted at 2022-12-25

私には眩しすぎた

日が暮れると、目に突き刺さる白背景のサイトたち。Dark Mode がないと目が潰れてしまう。深刻。
Google Chrome には、強制的にDark Mode にしてしまう実験的オプションがあるが、自分の作っているサイトまでDark Modeにされると困ってしまう。なので、 UserCSS を使って、よくアクセスするサイトを暗くした。

当然、そのサイトを作っている組織には、デザイナーさんがいて、考え抜かれた配色になっているのだろうし、勝手に色を変えるなんて失礼だとは思ったけど、もうとにかく眩しすぎて耐えられないので、CSS の勉強という体で暗くした。ごめんなさい。

Dark Mode にしたサイト

  • Qiita
  • Google Calendar

この2つは、日が暮れてもよくアクセスするため、特に私の目に厳しい。速やかに Dark Mode にする必要がある。

Google Calendar は、Google Search には Dark Mode があるので、そのうち対応するのかな?と思いつつ、ヘッダーで弊社ロゴマークのアスペクト比を勝手に変えるという許せない点があったので、変えた。

Qiita は、やらない方針みたいなので、やった。やりながら、まぁ確かに両方提供するのはしんどいと思った。

便利なセレクター

Google Calendar のサービスには、タグに色々なAttribution がついているので、それを使うと簡単に選べる。

div[role="dialog"],
div[role="listbox"],
div[role="presentation"] {
  background-color: var(--surface);
  color: #fff;
}

Qiita は、ちょっとデザインが変わったら崩れちゃうんだろうな感があるけど、:nth-child(), [id^="xxx"], [id$="yyy"], :not() などが活躍した。

.p-items_main > div:nth-child(2) * {
  border-color: var(--hairline);
}
div[id^="UserMainPage-"] * button[aria-label$="Page"] {
  background-color: var(--cursor);
}
blockquote *:not(code) {
  color: var(--text-white);
}

結果

Screen Shot 2022-12-25 at 19.29.47.png
Screen Shot 2022-12-25 at 19.33.49.png

かなり私の目に優しくなった。ここは改善が必要とか色々あるけど切りがないのでいったん終了。まぁ焼け石に水デスネ。

気が向いたらアップデートしていくかも知れない。

メリー・クリスマス^^

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?