aboutsummaryrefslogtreecommitdiffstats
path: root/src/webview
diff options
context:
space:
mode:
Diffstat (limited to 'src/webview')
-rw-r--r--src/webview/darkmode/custom.js22
-rw-r--r--src/webview/recipe.js19
-rw-r--r--src/webview/spellchecker.js2
3 files changed, 39 insertions, 4 deletions
diff --git a/src/webview/darkmode/custom.js b/src/webview/darkmode/custom.js
new file mode 100644
index 000000000..f767f5755
--- /dev/null
+++ b/src/webview/darkmode/custom.js
@@ -0,0 +1,22 @@
1// CSS for pages that need custom styles to work correctly in darkmode
2export default {
3 'web.whatsapp.com': `
4 div.landing-window > div.landing-main {
5 background-color: #FFFFFF !important;
6 }
7 div.landing-window > div.landing-main * {
8 color: #212121 !important;
9 }
10 `,
11 'web.threema.ch': `
12 .scan {
13 background-color: #FFF;
14 }
15 .scan * {
16 color: #212121;
17 }
18 .scan input.md-input {
19 color: #212121;
20 }
21 `,
22};
diff --git a/src/webview/recipe.js b/src/webview/recipe.js
index 3f2338b68..ddfd0e139 100644
--- a/src/webview/recipe.js
+++ b/src/webview/recipe.js
@@ -10,6 +10,7 @@ import {
10} from 'darkreader'; 10} from 'darkreader';
11 11
12import ignoreList from './darkmode/ignore'; 12import ignoreList from './darkmode/ignore';
13import customDarkModeCss from './darkmode/custom';
13 14
14import RecipeWebview from './lib/RecipeWebview'; 15import RecipeWebview from './lib/RecipeWebview';
15 16
@@ -42,6 +43,8 @@ class RecipeController {
42 'get-service-id': 'serviceIdEcho', 43 'get-service-id': 'serviceIdEcho',
43 }; 44 };
44 45
46 universalDarkModeInjected = false;
47
45 constructor() { 48 constructor() {
46 this.initialize(); 49 this.initialize();
47 } 50 }
@@ -117,7 +120,7 @@ class RecipeController {
117 } 120 }
118 } 121 }
119 122
120 if (this.settings.service.isDarkModeEnabled || this.settings.app.darkMode) { 123 if (this.settings.service.isDarkModeEnabled) {
121 debug('Enable dark mode'); 124 debug('Enable dark mode');
122 125
123 // Check if recipe has a darkmode.css 126 // Check if recipe has a darkmode.css
@@ -126,9 +129,12 @@ class RecipeController {
126 129
127 if (darkModeExists) { 130 if (darkModeExists) {
128 injectDarkModeStyle(this.settings.service.recipe.path); 131 injectDarkModeStyle(this.settings.service.recipe.path);
129 } else if (!ignoreList.includes(window.location.host)) { 132 } else if (this.settings.app.universalDarkMode && !ignoreList.includes(window.location.host)) {
130 // Use darkreader instead 133 // Use darkreader instead
131 enableDarkMode(); 134 enableDarkMode({}, {
135 css: customDarkModeCss[window.location.host] || '',
136 });
137 this.universalDarkModeInjected = true;
132 } 138 }
133 } else { 139 } else {
134 debug('Remove dark mode'); 140 debug('Remove dark mode');
@@ -137,8 +143,15 @@ class RecipeController {
137 removeDarkModeStyle(); 143 removeDarkModeStyle();
138 } else { 144 } else {
139 disableDarkMode(); 145 disableDarkMode();
146 this.universalDarkModeInjected = false;
140 } 147 }
141 } 148 }
149
150 // Remove dark reader if (universal) dark mode was just disabled
151 if (this.universalDarkModeInjected && (!this.settings.service.isDarkModeEnabled || !this.settings.app.universalDarkMode)) {
152 disableDarkMode();
153 this.universalDarkModeInjected = false;
154 }
142 } 155 }
143 156
144 updateAppSettings(event, data) { 157 updateAppSettings(event, data) {
diff --git a/src/webview/spellchecker.js b/src/webview/spellchecker.js
index 27380676d..1cb449110 100644
--- a/src/webview/spellchecker.js
+++ b/src/webview/spellchecker.js
@@ -96,7 +96,7 @@ export function isEnabled() {
96 96
97export function disable() { 97export function disable() {
98 if (isEnabled()) { 98 if (isEnabled()) {
99 webFrame.setSpellCheckProvider(currentDict, true, { spellCheck: () => true }); 99 webFrame.setSpellCheckProvider(currentDict, { spellCheck: () => true });
100 _isEnabled = false; 100 _isEnabled = false;
101 currentDict = null; 101 currentDict = null;
102 } 102 }