feat: extension skeleton with manifest, settings module, and placeholder icons
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
46
lib/settings.js
Normal file
46
lib/settings.js
Normal file
@@ -0,0 +1,46 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
const DEFAULTS = {
|
||||
enabled: true,
|
||||
darkMode: "auto",
|
||||
"light.subredditBgColor": "transparent",
|
||||
"light.subredditBorderColor": "#c84a20",
|
||||
"light.subredditTextColor": "#c84a20",
|
||||
"light.commentsBgColor": "#e0e0e0",
|
||||
"light.commentsBorderColor": "#4a4a4a",
|
||||
"light.commentsTextColor": "#4a4a4a",
|
||||
"dark.subredditBgColor": "transparent",
|
||||
"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);
|
||||
return Object.assign({}, DEFAULTS, stored);
|
||||
}
|
||||
|
||||
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;
|
||||
})();
|
||||
Reference in New Issue
Block a user