diff options
Diffstat (limited to 'src/webview/recipe.js')
-rw-r--r-- | src/webview/recipe.js | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/src/webview/recipe.js b/src/webview/recipe.js index e3e13b726..3f2338b68 100644 --- a/src/webview/recipe.js +++ b/src/webview/recipe.js | |||
@@ -1,8 +1,15 @@ | |||
1 | import { ipcRenderer } from 'electron'; | 1 | import { ipcRenderer } from 'electron'; |
2 | import path from 'path'; | 2 | import path from 'path'; |
3 | import { autorun, computed, observable } from 'mobx'; | 3 | import { autorun, computed, observable } from 'mobx'; |
4 | import fs from 'fs-extra'; | ||
4 | import { loadModule } from 'cld3-asm'; | 5 | import { loadModule } from 'cld3-asm'; |
5 | import { debounce } from 'lodash'; | 6 | import { debounce } from 'lodash'; |
7 | import { | ||
8 | enable as enableDarkMode, | ||
9 | disable as disableDarkMode, | ||
10 | } from 'darkreader'; | ||
11 | |||
12 | import ignoreList from './darkmode/ignore'; | ||
6 | 13 | ||
7 | import RecipeWebview from './lib/RecipeWebview'; | 14 | import RecipeWebview from './lib/RecipeWebview'; |
8 | 15 | ||
@@ -14,7 +21,7 @@ import './notifications'; | |||
14 | import { DEFAULT_APP_SETTINGS } from '../config'; | 21 | import { DEFAULT_APP_SETTINGS } from '../config'; |
15 | import { isDevMode } from '../environment'; | 22 | import { isDevMode } from '../environment'; |
16 | 23 | ||
17 | const debug = require('debug')('Franz:Plugin'); | 24 | const debug = require('debug')('Ferdi:Plugin'); |
18 | 25 | ||
19 | class RecipeController { | 26 | class RecipeController { |
20 | @observable settings = { | 27 | @observable settings = { |
@@ -110,12 +117,27 @@ class RecipeController { | |||
110 | } | 117 | } |
111 | } | 118 | } |
112 | 119 | ||
113 | if (this.settings.service.isDarkModeEnabled) { | 120 | if (this.settings.service.isDarkModeEnabled || this.settings.app.darkMode) { |
114 | debug('Enable dark mode'); | 121 | debug('Enable dark mode'); |
115 | injectDarkModeStyle(this.settings.service.recipe.path); | 122 | |
116 | } else if (isDarkModeStyleInjected()) { | 123 | // Check if recipe has a darkmode.css |
124 | const darkModeStyle = path.join(this.settings.service.recipe.path, 'darkmode.css'); | ||
125 | const darkModeExists = fs.pathExistsSync(darkModeStyle); | ||
126 | |||
127 | if (darkModeExists) { | ||
128 | injectDarkModeStyle(this.settings.service.recipe.path); | ||
129 | } else if (!ignoreList.includes(window.location.host)) { | ||
130 | // Use darkreader instead | ||
131 | enableDarkMode(); | ||
132 | } | ||
133 | } else { | ||
117 | debug('Remove dark mode'); | 134 | debug('Remove dark mode'); |
118 | removeDarkModeStyle(); | 135 | |
136 | if (isDarkModeStyleInjected()) { | ||
137 | removeDarkModeStyle(); | ||
138 | } else { | ||
139 | disableDarkMode(); | ||
140 | } | ||
119 | } | 141 | } |
120 | } | 142 | } |
121 | 143 | ||