Files
reddit-tweaks-ffe/lib/settings.js
cottongin cca7940dd9 fix: subreddit badge fill, tagline 'to' cleanup, and comments li spacing
- Default subreddit badge background from transparent to opaque fill
  (light: #fde8e0, dark: #3d2518) so page highlights don't bleed through
- Remove lingering "to" text node from tagline when subreddit is hidden
- Hide the <li> wrapping the comments link (not just the <a>) to
  eliminate leftover whitespace in the flat-list
- Simplify popup: subreddit bg fields are now color pickers (no longer
  need transparent text-input workaround)

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-26 15:32:33 -04:00

49 lines
1.4 KiB
JavaScript

(function () {
"use strict";
const DEFAULTS = {
enabled: true,
darkMode: "auto",
"light.subredditBgColor": "#fde8e0",
"light.subredditBorderColor": "#c84a20",
"light.subredditTextColor": "#c84a20",
"light.commentsBgColor": "#e0e0e0",
"light.commentsBorderColor": "#4a4a4a",
"light.commentsTextColor": "#4a4a4a",
"dark.subredditBgColor": "#3d2518",
"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);
const merged = Object.assign({}, DEFAULTS, stored);
merged.subredditColors = Object.assign({}, merged.subredditColors);
return merged;
}
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;
})();