| 156 | } |
| 157 | |
| 158 | function getColorModePreference() { |
| 159 | // color mode is set as attributes on <body>, we'll use that information |
| 160 | // along with media query checking rather than parsing the cookie value |
| 161 | // set by github.com |
| 162 | let color_mode_preference = document.querySelector('body')?.dataset.colorMode |
| 163 | |
| 164 | if (color_mode_preference === 'auto') { |
| 165 | if (window.matchMedia('(prefers-color-scheme: light)').matches) { |
| 166 | color_mode_preference += ':light' |
| 167 | } else if (window.matchMedia('(prefers-color-scheme: dark)').matches) { |
| 168 | color_mode_preference += ':dark' |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | return color_mode_preference |
| 173 | } |
| 174 | |
| 175 | function getPerformance() { |
| 176 | const paint = performance |