--- /dev/null
+:root {
+ /* NB: No space after colon. */
+ --theme:dark;
+ --body-color: black;
+ --body-filter: invert(1);
+ --img-filter: invert(1);
+}
--- /dev/null
+:root {
+ /* NB: No space after colon. */
+ --theme:light;
+ --body-color: white;
+ --body-filter:;
+ --img-filter:;
+}
{
"name": "vapier tabs backup",
- "version": "0.2.1.3",
+ "version": "0.2.1.4",
"manifest_version": 2,
"description": "With 'Tabs Backup & Restore' you will never lose your work again! Backup an entire Chrome session (windows and tabs).",
"icons": { "16": "icon_16.png",
<head>
<meta charset='utf-8'/>
<title>Tabs Backup & Restore - Options</title>
+
+ <link rel='stylesheet' href='dark.css' media='(prefers-color-scheme: dark)'/>
+ <link rel='stylesheet' href='light.css' media='(prefers-color-scheme: light), (prefers-color-scheme: no-preference)'/>
+ <!-- Load theme override asap to help with initial loading/flashing. -->
+ <link rel='stylesheet' href='' id='theme-override'/>
+ <script src="theme-init.js"></script>
+
<style>
body {
font-family: Arial;
-
+ background-color: var(--body-color);
+ filter: var(--body-filter);
overflow-x:hidden;
}
vertical-align:middle;
width:75px;
height:75px;
+ filter: var(--img-filter);
}
.menuItem {
select {
padding: 5px;
}
+
+ button.selected {
+ filter: invert(1);
+ }
</style>
<!-- <script src="jquery-1.8.2.min.js"></script> -->
The maximum number of backups to keep. Old backups will be deleted when this number is reached.
</td>
</tr>
+
+ <tr class="prefsRow">
+ <td width="200">Theme</td>
+ <td>
+ <input type="text" id="prefsTheme" hidden>
+ <button id="theme-light">Light</button>
+ <button id="theme-system">System</button>
+ <button id="theme-dark">Dark</button>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2" class="prefsDescription">
+ The color scheme to use in this extension.
+ </td>
+ </tr>
+
</table>
</div>
document.querySelector('#saveBtn').addEventListener('click', saveOptions);
document.querySelector('#restoreDefaultBtn').addEventListener('click', restoreToDefault);
+ ['light', 'system', 'dark'].forEach((theme) => {
+ document.getElementById(`theme-${theme}`).addEventListener('click', setThemeClick);
+ });
+
//document.querySelector('body').addEventListener('click', restoreOptions);
});
}
}
+function setThemeClick() {
+ const theme = this.textContent.toLowerCase();
+ setThemeValue(theme);
+ switchTheme(theme);
+}
+
+function setThemeValue(value) {
+ const element = document.getElementById('prefsTheme');
+ switch (value) {
+ case 'light':
+ case 'dark':
+ break;
+ default:
+ value = 'system';
+ break;
+ }
+ element.value = value;
+
+ ['light', 'system', 'dark'].forEach((theme) => {
+ document.getElementById(`theme-${theme}`).className =
+ value == theme ? 'selected' : '';
+ });
+}
+
function saveOptions () {
var backupPeriodMinutes = getSelectValue("prefsSelectBackupPeriod");
localStorage.prefsBackupTimer = backupPeriodMinutes;
var backupMaxItems = getSelectValue("prefsSelectMaxBackups");
localStorage.prefsMaxBackupItems = backupMaxItems;
+ var theme = document.getElementById('prefsTheme').value;
+ localStorage.prefsTheme = theme;
+
// Re-initialize the backup alarm
chrome.runtime.getBackgroundPage((bg) => bg.initAlarm());
// those values are also set in background.js..
setSelectValue ("prefsSelectBackupPeriod", "5");
setSelectValue ("prefsSelectMaxBackups", "30");
+ setThemeValue("system");
saveOptions();
}
function restoreOptions() {
var backupPeriodMinutes = localStorage.prefsBackupTimer;
var backupMaxItems = localStorage.prefsMaxBackupItems;
+ var theme = localStorage.prefsTheme;
setSelectValue ("prefsSelectBackupPeriod", backupPeriodMinutes);
setSelectValue ("prefsSelectMaxBackups", backupMaxItems);
+ setThemeValue(theme);
}
<head>
<meta charset='utf-8'/>
<title>Tabs Backup & Restore</title>
+
+ <link rel='stylesheet' href='dark.css' media='(prefers-color-scheme: dark)'/>
+ <link rel='stylesheet' href='light.css' media='(prefers-color-scheme: light), (prefers-color-scheme: no-preference)'/>
+ <!-- Load theme override asap to help with initial loading/flashing. -->
+ <link rel='stylesheet' href='' id='theme-override'/>
+ <script src="theme-init.js"></script>
+
<style>
::-webkit-scrollbar {
}
+ html {
+ background-color: var(--body-color);
+ filter: var(--body-filter);
+ }
+
body {
font-family: Arial;
min-width:357px;
vertical-align:middle;
width:75px;
height:75px;
+ filter: var(--img-filter);
}
.menuItem {
--- /dev/null
+// Load the theme override asap to help with initial loading/flashing.
+function switchTheme(theme) {
+ const css = document.querySelector('link#theme-override');
+ if (theme == 'light' || theme == 'dark') {
+ css.href = `${theme}.css`;
+ } else {
+ css.href = '';
+ }
+}
+
+switchTheme(localStorage.prefsTheme);