diff options
Diffstat (limited to 'src/webview')
-rw-r--r-- | src/webview/darkmode/ignore.js | 3 | ||||
-rw-r--r-- | src/webview/recipe.js | 30 |
2 files changed, 32 insertions, 1 deletions
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 @@ | |||
1 | export default [ | ||
2 | 'discordapp.com', | ||
3 | ]; | ||
diff --git a/src/webview/recipe.js b/src/webview/recipe.js index fca00fde2..b30199f03 100644 --- a/src/webview/recipe.js +++ b/src/webview/recipe.js | |||
@@ -9,6 +9,8 @@ import { | |||
9 | disable as disableDarkMode, | 9 | disable as disableDarkMode, |
10 | } from 'darkreader'; | 10 | } from 'darkreader'; |
11 | 11 | ||
12 | import ignoreList from './darkmode/ignore'; | ||
13 | |||
12 | import RecipeWebview from './lib/RecipeWebview'; | 14 | import RecipeWebview from './lib/RecipeWebview'; |
13 | 15 | ||
14 | import spellchecker, { switchDict, disable as disableSpellchecker, getSpellcheckerLocaleByFuzzyIdentifier } from './spellchecker'; | 16 | import spellchecker, { switchDict, disable as disableSpellchecker, getSpellcheckerLocaleByFuzzyIdentifier } from './spellchecker'; |
@@ -123,7 +125,7 @@ class RecipeController { | |||
123 | 125 | ||
124 | if (darkModeExists) { | 126 | if (darkModeExists) { |
125 | injectDarkModeStyle(this.settings.service.recipe.path); | 127 | injectDarkModeStyle(this.settings.service.recipe.path); |
126 | } else { | 128 | } else if (!ignoreList.includes(window.location.host)) { |
127 | // Use darkreader instead | 129 | // Use darkreader instead |
128 | enableDarkMode(); | 130 | enableDarkMode(); |
129 | } | 131 | } |
@@ -194,6 +196,32 @@ new RecipeController(); | |||
194 | const originalWindowOpen = window.open; | 196 | const originalWindowOpen = window.open; |
195 | 197 | ||
196 | window.open = (url, frameName, features) => { | 198 | window.open = (url, frameName, features) => { |
199 | if (!url && !frameName && !features) { | ||
200 | // The service hasn't yet supplied a URL (as used in Skype). | ||
201 | // Return a new dummy window object and wait for the service to change the properties | ||
202 | const newWindow = { | ||
203 | location: { | ||
204 | href: '', | ||
205 | }, | ||
206 | }; | ||
207 | |||
208 | const checkInterval = setInterval(() => { | ||
209 | // Has the service changed the URL yet? | ||
210 | if (newWindow.location.href !== '') { | ||
211 | // Open the new URL | ||
212 | window.open(newWindow.location.href); | ||
213 | clearInterval(checkInterval); | ||
214 | } | ||
215 | }, 0); | ||
216 | |||
217 | setTimeout(() => { | ||
218 | // Stop checking for location changes after 1 second | ||
219 | clearInterval(checkInterval); | ||
220 | }, 1000); | ||
221 | |||
222 | return newWindow; | ||
223 | } | ||
224 | |||
197 | // We need to differentiate if the link should be opened in a popup or in the systems default browser | 225 | // We need to differentiate if the link should be opened in a popup or in the systems default browser |
198 | if (!frameName && !features) { | 226 | if (!frameName && !features) { |
199 | return ipcRenderer.sendToHost('new-window', url); | 227 | return ipcRenderer.sendToHost('new-window', url); |