2026-08-26 14:57:11 -04:00
|
|
|
(function () {
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
const DEFAULTS = {
|
|
|
|
|
enabled: true,
|
|
|
|
|
darkMode: "auto",
|
2026-08-26 15:32:33 -04:00
|
|
|
"light.subredditBgColor": "#fde8e0",
|
2026-08-26 14:57:11 -04:00
|
|
|
"light.subredditBorderColor": "#c84a20",
|
|
|
|
|
"light.subredditTextColor": "#c84a20",
|
|
|
|
|
"light.commentsBgColor": "#e0e0e0",
|
|
|
|
|
"light.commentsBorderColor": "#4a4a4a",
|
|
|
|
|
"light.commentsTextColor": "#4a4a4a",
|
2026-08-26 15:32:33 -04:00
|
|
|
"dark.subredditBgColor": "#3d2518",
|
2026-08-26 14:57:11 -04:00
|
|
|
"dark.subredditBorderColor": "#ff6b3d",
|
|
|
|
|
"dark.subredditTextColor": "#ff6b3d",
|
|
|
|
|
"dark.commentsBgColor": "#3a3a3a",
|
|
|
|
|
"dark.commentsBorderColor": "#888888",
|
|
|
|
|
"dark.commentsTextColor": "#cccccc",
|
|
|
|
|
subredditColors: {},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
async function loadSettings() {
|
|
|
|
|
const stored = await browser.storage.local.get(null);
|
2026-08-26 15:05:48 -04:00
|
|
|
const merged = Object.assign({}, DEFAULTS, stored);
|
|
|
|
|
merged.subredditColors = Object.assign({}, merged.subredditColors);
|
|
|
|
|
return merged;
|
2026-08-26 14:57:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function saveSettings(settings) {
|
|
|
|
|
const toStore = {};
|
|
|
|
|
for (const key of Object.keys(settings)) {
|
|
|
|
|
if (key in DEFAULTS) {
|
|
|
|
|
toStore[key] = settings[key];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
await browser.storage.local.set(toStore);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function resetSettings() {
|
|
|
|
|
await browser.storage.local.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
window.RedditTweaks = window.RedditTweaks || {};
|
|
|
|
|
window.RedditTweaks.DEFAULTS = DEFAULTS;
|
|
|
|
|
window.RedditTweaks.loadSettings = loadSettings;
|
|
|
|
|
window.RedditTweaks.saveSettings = saveSettings;
|
|
|
|
|
window.RedditTweaks.resetSettings = resetSettings;
|
|
|
|
|
})();
|