refactor: extract isDarkMode/getColorPrefix to settings.js as shared utilities

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-26 21:09:03 -04:00
parent d659238289
commit 7ac47b5c3c
3 changed files with 22 additions and 16 deletions

View File

@@ -18,6 +18,10 @@
"dark.commentsTextColor": "#cccccc",
subredditColors: {},
colorPresets: [],
badgeLayout: true,
cardLayout: true,
cardBackground: "reddit",
cardGap: 16,
};
function migrateSubredditColors(colors) {
@@ -60,9 +64,21 @@
await browser.storage.local.clear();
}
function isDarkMode(settings) {
if (settings.darkMode === "light") return false;
if (settings.darkMode === "dark") return true;
return document.body.classList.contains("res-nightmode");
}
function getColorPrefix(settings) {
return isDarkMode(settings) ? "dark" : "light";
}
window.RedditTweaks = window.RedditTweaks || {};
window.RedditTweaks.DEFAULTS = DEFAULTS;
window.RedditTweaks.loadSettings = loadSettings;
window.RedditTweaks.saveSettings = saveSettings;
window.RedditTweaks.resetSettings = resetSettings;
window.RedditTweaks.isDarkMode = isDarkMode;
window.RedditTweaks.getColorPrefix = getColorPrefix;
})();