refactor: extract isDarkMode/getColorPrefix to settings.js as shared utilities
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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;
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user