PageSourceSearch

https://confinity.com/theme-bootstrap.js

js confinity.com collected 2026-10-02 08:02:55 UTC 1,681 bytes, 54 lines download raw bytes

1(() => {
2  const current = document.currentScript;
3  const def = current?.dataset.defaultTheme === "dark" ? "dark" : "light";
4  const prefKey = current?.dataset.themeKey || "";
5  const mig = current?.dataset.migrateLegacy === "true";
6
7  function systemTheme() {
8    return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
9  }
10
11  try {
12    if (!prefKey) {
13      const stored = window.localStorage.getItem("data-theme");
14      const attr0 = stored === "light" || stored === "dark" ? stored : def;
15      if (!(stored === "light" || stored === "dark")) {
16        window.localStorage.setItem("data-theme", attr0);
17      }
18      document.documentElement.setAttribute("data-theme", attr0);
19      return;
20    }
21
22    const raw = window.localStorage.getItem(prefKey);
23    let attr;
24    let storedPref;
25    if (raw === "light" || raw === "dark") {
26      attr = raw;
27      storedPref = raw;
28    } else if (raw === "system") {
29      attr = systemTheme();
30      storedPref = "system";
31    } else if (mig) {
32      const legacy = window.localStorage.getItem("data-theme");
33      if (legacy === "light" || legacy === "dark") {
34        attr = legacy;
35        storedPref = legacy;
36      } else {
37        attr = def;
38        storedPref = def;
39      }
40      window.localStorage.setItem(prefKey, storedPref);
41    } else {
42      attr = def;
43      storedPref = def;
44      window.localStorage.setItem(prefKey, storedPref);
45    }
46
47    window.localStorage.setItem("data-theme", attr);
48    document.documentElement.setAttribute("data-theme", attr);
49  } catch (_error) {
50    try {
51      document.documentElement.setAttribute("data-theme", def);
52    } catch (_ignored) {}
53  }
54})();

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.