feat: settings defaults, storage layer, color scheme attribute
This commit is contained in:
@@ -1,7 +1,45 @@
|
||||
// Outlook Relook — Content Script Entry Point
|
||||
// Loaded by manifest on outlook.office.com/*
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
console.log('[Outlook Relook] Content script loaded');
|
||||
|
||||
const OR = window.OutlookRelook;
|
||||
|
||||
async function init() {
|
||||
const settings = await OR.loadSettings();
|
||||
console.log('[Outlook Relook] Loaded settings:', settings);
|
||||
|
||||
// Apply color scheme attribute
|
||||
applyColorScheme(settings.colorScheme);
|
||||
|
||||
// Listen for setting changes from popup
|
||||
chrome.storage.onChanged.addListener((changes, area) => {
|
||||
if (area !== 'sync') return;
|
||||
console.log('[Outlook Relook] Settings changed:', changes);
|
||||
|
||||
// Re-apply color scheme if it changed
|
||||
if (changes.colorScheme) {
|
||||
applyColorScheme(changes.colorScheme.newValue);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function applyColorScheme(scheme) {
|
||||
let resolved = scheme;
|
||||
if (scheme === 'system') {
|
||||
resolved = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
||||
}
|
||||
document.documentElement.setAttribute('data-outlook-relook-scheme', resolved);
|
||||
console.log('[Outlook Relook] Color scheme:', resolved);
|
||||
}
|
||||
|
||||
// Listen for system theme changes when scheme is 'system'
|
||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', async () => {
|
||||
const settings = await OR.loadSettings();
|
||||
if (settings.colorScheme === 'system') {
|
||||
applyColorScheme('system');
|
||||
}
|
||||
});
|
||||
|
||||
init();
|
||||
})();
|
||||
|
||||
@@ -1 +1,111 @@
|
||||
// Outlook Relook — settings-defaults.js (stub, implemented in later task)
|
||||
// Outlook Relook — Settings Defaults
|
||||
// Loaded first by manifest. Exposes window.OutlookRelook.DEFAULTS and helpers.
|
||||
|
||||
window.OutlookRelook = window.OutlookRelook || {};
|
||||
|
||||
window.OutlookRelook.DEFAULTS = {
|
||||
// Theme & Appearance
|
||||
theme: 'swiss',
|
||||
colorScheme: 'system', // 'light' | 'dark' | 'system'
|
||||
accentColor: '', // empty = theme default
|
||||
|
||||
// Density & Spacing
|
||||
densityPreset: 'compact', // 'comfortable' | 'compact' | 'ultra-compact'
|
||||
compactTopBar: true,
|
||||
compactCommandBar: true,
|
||||
compactMessageList: true,
|
||||
compactReadingPane: true,
|
||||
compactFolderPane: true,
|
||||
narrowDateColumn: true,
|
||||
compressComposeToolbar: true,
|
||||
readingPaneMaxWidth: true,
|
||||
|
||||
// Hide Elements
|
||||
hideCopilot: true,
|
||||
hideSuggestedReplies: true,
|
||||
hidePromoBanners: true,
|
||||
hideFocusedOtherTabs: true,
|
||||
hideSidebarAppIcons: false,
|
||||
hideGroupsSection: false,
|
||||
hideMyDayButtons: true,
|
||||
hideSenderAvatars: false,
|
||||
hideFeatureDiscovery: true,
|
||||
hideVivaInsights: true,
|
||||
hideUnreadOtherBanner: true,
|
||||
hideActivityFeed: true,
|
||||
|
||||
// Readability
|
||||
unreadDistinction: true,
|
||||
previewOwnLine: false,
|
||||
normalizeFontWeight: true,
|
||||
darkModeEmailFix: true,
|
||||
messageListFontSize: 'medium', // 'small' | 'medium' | 'large'
|
||||
|
||||
// Behavior
|
||||
autoCollapseRibbon: true,
|
||||
rememberSidebarState: true,
|
||||
suppressContactHover: true,
|
||||
autoAdvanceAfterDelete: true,
|
||||
autoDismissToasts: '5', // 'off' | '3' | '5' | '10' (seconds)
|
||||
toastPosition: 'top-right', // 'bottom-left' | 'top-right'
|
||||
stickyReplyBar: true,
|
||||
autoResizeCompose: true,
|
||||
throttleNotifications: false,
|
||||
|
||||
// Keyboard Navigation
|
||||
keyboardMultiSelect: true,
|
||||
|
||||
// Quick Actions
|
||||
markAllReadButton: true,
|
||||
quickFolderJump: true,
|
||||
};
|
||||
|
||||
// Density presets define which individual toggles each preset sets
|
||||
window.OutlookRelook.DENSITY_PRESETS = {
|
||||
comfortable: {
|
||||
compactTopBar: false,
|
||||
compactCommandBar: false,
|
||||
compactMessageList: false,
|
||||
compactReadingPane: false,
|
||||
compactFolderPane: false,
|
||||
narrowDateColumn: false,
|
||||
compressComposeToolbar: false,
|
||||
readingPaneMaxWidth: true,
|
||||
},
|
||||
compact: {
|
||||
compactTopBar: true,
|
||||
compactCommandBar: true,
|
||||
compactMessageList: true,
|
||||
compactReadingPane: true,
|
||||
compactFolderPane: true,
|
||||
narrowDateColumn: true,
|
||||
compressComposeToolbar: true,
|
||||
readingPaneMaxWidth: true,
|
||||
},
|
||||
'ultra-compact': {
|
||||
compactTopBar: true,
|
||||
compactCommandBar: true,
|
||||
compactMessageList: true,
|
||||
compactReadingPane: true,
|
||||
compactFolderPane: true,
|
||||
narrowDateColumn: true,
|
||||
compressComposeToolbar: true,
|
||||
readingPaneMaxWidth: true,
|
||||
},
|
||||
};
|
||||
|
||||
// Load settings from chrome.storage.sync, filling in defaults for missing keys
|
||||
window.OutlookRelook.loadSettings = function () {
|
||||
return new Promise((resolve) => {
|
||||
chrome.storage.sync.get(window.OutlookRelook.DEFAULTS, (settings) => {
|
||||
resolve(settings);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// Save a partial settings object to chrome.storage.sync
|
||||
window.OutlookRelook.saveSettings = function (partial) {
|
||||
return new Promise((resolve) => {
|
||||
chrome.storage.sync.set(partial, resolve);
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user