aboutsummaryrefslogtreecommitdiffstats
path: root/src/webview/recipe.js
diff options
context:
space:
mode:
authorLibravatar vantezzen <hello@vantezzen.io>2020-04-17 18:07:20 +0200
committerLibravatar vantezzen <hello@vantezzen.io>2020-04-17 18:07:20 +0200
commitd3bea9800073f864cf407bf0c42ef7c299a91852 (patch)
treec0781876d677f51293333c18cbb637dafab203c2 /src/webview/recipe.js
parentMerge branch 'develop' (diff)
parentPrepare code (diff)
downloadferdium-app-d3bea9800073f864cf407bf0c42ef7c299a91852.tar.gz
ferdium-app-d3bea9800073f864cf407bf0c42ef7c299a91852.tar.zst
ferdium-app-d3bea9800073f864cf407bf0c42ef7c299a91852.zip
Merge branch 'develop'v5.5.0-gm
Diffstat (limited to 'src/webview/recipe.js')
-rw-r--r--src/webview/recipe.js15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/webview/recipe.js b/src/webview/recipe.js
index bad5a93b2..8125ec064 100644
--- a/src/webview/recipe.js
+++ b/src/webview/recipe.js
@@ -21,6 +21,7 @@ import ignoreList from './darkmode/ignore';
21import customDarkModeCss from './darkmode/custom'; 21import customDarkModeCss from './darkmode/custom';
22 22
23import RecipeWebview from './lib/RecipeWebview'; 23import RecipeWebview from './lib/RecipeWebview';
24import Userscript from './lib/Userscript';
24 25
25import spellchecker, { switchDict, disable as disableSpellchecker, getSpellcheckerLocaleByFuzzyIdentifier } from './spellchecker'; 26import spellchecker, { switchDict, disable as disableSpellchecker, getSpellcheckerLocaleByFuzzyIdentifier } from './spellchecker';
26import { injectDarkModeStyle, isDarkModeStyleInjected, removeDarkModeStyle } from './darkmode'; 27import { injectDarkModeStyle, isDarkModeStyleInjected, removeDarkModeStyle } from './darkmode';
@@ -55,6 +56,8 @@ class RecipeController {
55 56
56 recipe = null; 57 recipe = null;
57 58
59 userscript = null;
60
58 hasUpdatedBeforeRecipeLoaded = false; 61 hasUpdatedBeforeRecipeLoaded = false;
59 62
60 constructor() { 63 constructor() {
@@ -130,7 +133,8 @@ class RecipeController {
130 const userJsModule = require(userJs); 133 const userJsModule = require(userJs);
131 134
132 if (typeof userJsModule === 'function') { 135 if (typeof userJsModule === 'function') {
133 userJsModule(config); 136 this.userscript = new Userscript(this.recipe, this, config);
137 userJsModule(config, this.userscript);
134 } 138 }
135 }; 139 };
136 140
@@ -153,6 +157,11 @@ class RecipeController {
153 debug('isDarkModeEnabled', this.settings.service.isDarkModeEnabled); 157 debug('isDarkModeEnabled', this.settings.service.isDarkModeEnabled);
154 debug('System spellcheckerLanguage', this.settings.app.spellcheckerLanguage); 158 debug('System spellcheckerLanguage', this.settings.app.spellcheckerLanguage);
155 debug('Service spellcheckerLanguage', this.settings.service.spellcheckerLanguage); 159 debug('Service spellcheckerLanguage', this.settings.service.spellcheckerLanguage);
160 debug('darkReaderSettigs', this.settings.service.darkReaderSettings);
161
162 if (this.userscript && this.userscript.internal_setSettings) {
163 this.userscript.internal_setSettings(this.settings);
164 }
156 165
157 if (this.settings.app.enableSpellchecking) { 166 if (this.settings.app.enableSpellchecking) {
158 debug('Setting spellchecker language to', this.spellcheckerLanguage); 167 debug('Setting spellchecker language to', this.spellcheckerLanguage);
@@ -225,7 +234,8 @@ class RecipeController {
225 console.log('Injecting DarkReader'); 234 console.log('Injecting DarkReader');
226 235
227 // Use darkreader instead 236 // Use darkreader instead
228 enableDarkMode({}, { 237 const { brightness, contrast, sepia } = this.settings.service.darkReaderSettings;
238 enableDarkMode({ brightness, contrast, sepia }, {
229 css: customDarkModeCss[window.location.host] || '', 239 css: customDarkModeCss[window.location.host] || '',
230 }); 240 });
231 this.universalDarkModeInjected = true; 241 this.universalDarkModeInjected = true;
@@ -322,7 +332,6 @@ new RecipeController();
322// Patching window.open 332// Patching window.open
323const originalWindowOpen = window.open; 333const originalWindowOpen = window.open;
324 334
325
326window.open = (url, frameName, features) => { 335window.open = (url, frameName, features) => {
327 if (!url && !frameName && !features) { 336 if (!url && !frameName && !features) {
328 // The service hasn't yet supplied a URL (as used in Skype). 337 // The service hasn't yet supplied a URL (as used in Skype).