47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
(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;
|
|
})();
|