PageSourceSearch

https://zeyunlu.github.io/assets/js/theme.js

js zeyunlu.github.io collected 2026-10-03 10:14:23 UTC 454 bytes, 17 lines download raw bytes

1// Has to be in the head tag, otherwise a flicker effect will occur.
2let initTheme = (theme) => {
3  if (theme == null) {
4    const userPref = window.matchMedia;
5    if (userPref && userPref('(prefers-color-scheme: dark)').matches) {
6        theme = 'dark';
7    }
8  }
9
10  if (theme)  {
11    document.documentElement.setAttribute('data-theme', theme)
12  }
13
14  localStorage.setItem("theme", theme);
15}
16
17initTheme(localStorage.getItem("theme"));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.