Skip to content

Commit 8ab5787

Browse files
committed
fix: remove inline script
1 parent ae49bf0 commit 8ab5787

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

src/js/theme-init.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
(function () {
2+
const localStorageTheme = localStorage.getItem("theme");
3+
const systemSettingDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
4+
5+
let theme = "light";
6+
if (localStorageTheme) {
7+
theme = localStorageTheme;
8+
} else if (systemSettingDark) {
9+
theme = "dark";
10+
}
11+
12+
document.documentElement.setAttribute("data-theme", theme);
13+
})();

src/newtab.html

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,7 @@
99
content="NoteKeeper is a Firefox extension that transforms the New Tab into a minimalist, auto-saving text editor.">
1010
<link rel="icon" type="image/png" sizes="48x48" href="icons/icon48.png" />
1111
<!-- Prevent flash of incorrect theme -->
12-
<script>
13-
(function () {
14-
const localStorageTheme = localStorage.getItem("theme");
15-
const systemSettingDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
16-
17-
let theme = "light";
18-
if (localStorageTheme) {
19-
theme = localStorageTheme;
20-
} else if (systemSettingDark) {
21-
theme = "dark";
22-
}
23-
24-
document.documentElement.setAttribute("data-theme", theme);
25-
})();
26-
</script>
12+
<script type="text/javascript" src="js/theme-init.js"></script>
2713
<link rel="stylesheet" href="styles.css" />
2814
</head>
2915

0 commit comments

Comments
 (0)