aboutsummaryrefslogtreecommitdiffstats
path: root/src/webview
diff options
context:
space:
mode:
Diffstat (limited to 'src/webview')
-rw-r--r--src/webview/contextMenu.js2
-rw-r--r--src/webview/darkmode.js2
-rw-r--r--src/webview/darkmode/ignore.js3
-rw-r--r--src/webview/lib/RecipeWebview.js10
-rw-r--r--src/webview/notifications.js2
-rw-r--r--src/webview/recipe.js32
-rw-r--r--src/webview/spellchecker.js2
7 files changed, 42 insertions, 11 deletions
diff --git a/src/webview/contextMenu.js b/src/webview/contextMenu.js
index d3b976554..acd62d675 100644
--- a/src/webview/contextMenu.js
+++ b/src/webview/contextMenu.js
@@ -8,7 +8,7 @@ import {
8import { isDevMode, isMac } from '../environment'; 8import { isDevMode, isMac } from '../environment';
9import { SPELLCHECKER_LOCALES } from '../i18n/languages'; 9import { SPELLCHECKER_LOCALES } from '../i18n/languages';
10 10
11const debug = require('debug')('Franz:contextMenu'); 11const debug = require('debug')('Ferdi:contextMenu');
12 12
13const { Menu } = remote; 13const { Menu } = remote;
14 14
diff --git a/src/webview/darkmode.js b/src/webview/darkmode.js
index 73c7007c6..ab629435c 100644
--- a/src/webview/darkmode.js
+++ b/src/webview/darkmode.js
@@ -3,7 +3,7 @@
3import path from 'path'; 3import path from 'path';
4import fs from 'fs-extra'; 4import fs from 'fs-extra';
5 5
6const debug = require('debug')('Franz:DarkMode'); 6const debug = require('debug')('Ferdi:DarkMode');
7 7
8const chars = [...'abcdefghijklmnopqrstuvwxyz']; 8const chars = [...'abcdefghijklmnopqrstuvwxyz'];
9 9
diff --git a/src/webview/darkmode/ignore.js b/src/webview/darkmode/ignore.js
new file mode 100644
index 000000000..110df364f
--- /dev/null
+++ b/src/webview/darkmode/ignore.js
@@ -0,0 +1,3 @@
1export default [
2 'discordapp.com',
3];
diff --git a/src/webview/lib/RecipeWebview.js b/src/webview/lib/RecipeWebview.js
index be29142af..877e45e35 100644
--- a/src/webview/lib/RecipeWebview.js
+++ b/src/webview/lib/RecipeWebview.js
@@ -39,9 +39,15 @@ class RecipeWebview {
39 if (this.countCache.direct === direct 39 if (this.countCache.direct === direct
40 && this.countCache.indirect === indirect) return; 40 && this.countCache.indirect === indirect) return;
41 41
42 // Parse number to integer
43 // This will correct errors that recipes may introduce, e.g.
44 // by sending a String instead of an integer
45 const directInt = parseInt(direct, 10);
46 const indirectInt = parseInt(indirect, 10);
47
42 const count = { 48 const count = {
43 direct: direct > 0 ? direct : 0, 49 direct: directInt > 0 ? directInt : 0,
44 indirect: indirect > 0 ? indirect : 0, 50 indirect: indirectInt > 0 ? indirectInt : 0,
45 }; 51 };
46 52
47 ipcRenderer.sendToHost('messages', count); 53 ipcRenderer.sendToHost('messages', count);
diff --git a/src/webview/notifications.js b/src/webview/notifications.js
index f8fe53e1b..021f05cc3 100644
--- a/src/webview/notifications.js
+++ b/src/webview/notifications.js
@@ -1,7 +1,7 @@
1import { ipcRenderer } from 'electron'; 1import { ipcRenderer } from 'electron';
2import uuidV1 from 'uuid/v1'; 2import uuidV1 from 'uuid/v1';
3 3
4const debug = require('debug')('Franz:Notifications'); 4const debug = require('debug')('Ferdi:Notifications');
5 5
6class Notification { 6class Notification {
7 static permission = 'granted'; 7 static permission = 'granted';
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 @@
1import { ipcRenderer } from 'electron'; 1import { ipcRenderer } from 'electron';
2import path from 'path'; 2import path from 'path';
3import { autorun, computed, observable } from 'mobx'; 3import { autorun, computed, observable } from 'mobx';
4import fs from 'fs-extra';
4import { loadModule } from 'cld3-asm'; 5import { loadModule } from 'cld3-asm';
5import { debounce } from 'lodash'; 6import { debounce } from 'lodash';
7import {
8 enable as enableDarkMode,
9 disable as disableDarkMode,
10} from 'darkreader';
11
12import ignoreList from './darkmode/ignore';
6 13
7import RecipeWebview from './lib/RecipeWebview'; 14import RecipeWebview from './lib/RecipeWebview';
8 15
@@ -14,7 +21,7 @@ import './notifications';
14import { DEFAULT_APP_SETTINGS } from '../config'; 21import { DEFAULT_APP_SETTINGS } from '../config';
15import { isDevMode } from '../environment'; 22import { isDevMode } from '../environment';
16 23
17const debug = require('debug')('Franz:Plugin'); 24const debug = require('debug')('Ferdi:Plugin');
18 25
19class RecipeController { 26class 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
diff --git a/src/webview/spellchecker.js b/src/webview/spellchecker.js
index 06cbd283a..27380676d 100644
--- a/src/webview/spellchecker.js
+++ b/src/webview/spellchecker.js
@@ -6,7 +6,7 @@ import { readFileSync } from 'fs';
6import { DICTIONARY_PATH } from '../config'; 6import { DICTIONARY_PATH } from '../config';
7import { SPELLCHECKER_LOCALES } from '../i18n/languages'; 7import { SPELLCHECKER_LOCALES } from '../i18n/languages';
8 8
9const debug = require('debug')('Franz:spellchecker'); 9const debug = require('debug')('Ferdi:spellchecker');
10 10
11let provider; 11let provider;
12let currentDict; 12let currentDict;