aboutsummaryrefslogtreecommitdiffstats
path: root/src/webview/recipe.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/webview/recipe.js')
-rw-r--r--src/webview/recipe.js20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/webview/recipe.js b/src/webview/recipe.js
index 598c3eb9a..a45c34002 100644
--- a/src/webview/recipe.js
+++ b/src/webview/recipe.js
@@ -1,8 +1,8 @@
1/* eslint-disable import/first */ 1/* eslint-disable import/first */
2import { contextBridge, ipcRenderer } from 'electron'; 2import { contextBridge, ipcRenderer } from 'electron';
3import path from 'path'; 3import { join } from 'path';
4import { autorun, computed, observable } from 'mobx'; 4import { autorun, computed, observable } from 'mobx';
5import fs from 'fs-extra'; 5import { pathExistsSync, readFileSync } from 'fs-extra';
6import { debounce } from 'lodash'; 6import { debounce } from 'lodash';
7 7
8// For some services darkreader tries to use the chrome extension message API 8// For some services darkreader tries to use the chrome extension message API
@@ -189,7 +189,7 @@ class RecipeController {
189 189
190 loadRecipeModule(event, config, recipe) { 190 loadRecipeModule(event, config, recipe) {
191 debug('loadRecipeModule'); 191 debug('loadRecipeModule');
192 const modulePath = path.join(recipe.path, 'webview.js'); 192 const modulePath = join(recipe.path, 'webview.js');
193 debug('module path', modulePath); 193 debug('module path', modulePath);
194 // Delete module from cache 194 // Delete module from cache
195 delete require.cache[require.resolve(modulePath)]; 195 delete require.cache[require.resolve(modulePath)];
@@ -214,15 +214,15 @@ class RecipeController {
214 const styles = document.createElement('style'); 214 const styles = document.createElement('style');
215 styles.innerHTML = screenShareCss; 215 styles.innerHTML = screenShareCss;
216 216
217 const userCss = path.join(recipe.path, 'user.css'); 217 const userCss = join(recipe.path, 'user.css');
218 if (fs.existsSync(userCss)) { 218 if (pathExistsSync(userCss)) {
219 const data = await fs.readFile(userCss); 219 const data = readFileSync(userCss);
220 styles.innerHTML += data.toString(); 220 styles.innerHTML += data.toString();
221 } 221 }
222 document.querySelector('head').appendChild(styles); 222 document.querySelector('head').appendChild(styles);
223 223
224 const userJs = path.join(recipe.path, 'user.js'); 224 const userJs = join(recipe.path, 'user.js');
225 if (fs.existsSync(userJs)) { 225 if (pathExistsSync(userJs)) {
226 const loadUserJs = () => { 226 const loadUserJs = () => {
227 // eslint-disable-next-line 227 // eslint-disable-next-line
228 const userJsModule = require(userJs); 228 const userJsModule = require(userJs);
@@ -308,11 +308,11 @@ class RecipeController {
308 debug('Enable dark mode'); 308 debug('Enable dark mode');
309 309
310 // Check if recipe has a darkmode.css 310 // Check if recipe has a darkmode.css
311 const darkModeStyle = path.join( 311 const darkModeStyle = join(
312 this.settings.service.recipe.path, 312 this.settings.service.recipe.path,
313 'darkmode.css', 313 'darkmode.css',
314 ); 314 );
315 const darkModeExists = fs.pathExistsSync(darkModeStyle); 315 const darkModeExists = pathExistsSync(darkModeStyle);
316 316
317 debug('darkmode.css exists? ', darkModeExists ? 'Yes' : 'No'); 317 debug('darkmode.css exists? ', darkModeExists ? 'Yes' : 'No');
318 318