aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/google-calendar/webview.js
diff options
context:
space:
mode:
authorLibravatar Vijay Aravamudhan <vraravam@users.noreply.github.com>2023-08-08 07:11:16 +0530
committerLibravatar GitHub <noreply@github.com>2023-08-08 07:11:16 +0530
commit6770f562306ea0e742bf274654fe34b6abaeff92 (patch)
tree92e1780587a2f3d80f5e6ae80ad890a8ca1d828f /recipes/google-calendar/webview.js
parentci: modernize github actions (diff)
downloadferdium-recipes-6770f562306ea0e742bf274654fe34b6abaeff92.tar.gz
ferdium-recipes-6770f562306ea0e742bf274654fe34b6abaeff92.tar.zst
ferdium-recipes-6770f562306ea0e742bf274654fe34b6abaeff92.zip
Update google-calendar recipe to load external scripts to fix CSP error (#402)
* Update google-calendar recipe to load external scripts to fix CSP error https://github.com/ferdium/ferdium-app/issues/1086\#issuecomment-1656926137 * use Ferdium.handleDarkMode() in google-calendar webview to be able to toggle between light and dark mode --------- Co-authored-by: MCMXC <16797721+mcmxcdev@users.noreply.github.com>
Diffstat (limited to 'recipes/google-calendar/webview.js')
-rw-r--r--recipes/google-calendar/webview.js31
1 files changed, 29 insertions, 2 deletions
diff --git a/recipes/google-calendar/webview.js b/recipes/google-calendar/webview.js
index 3921dea..804527d 100644
--- a/recipes/google-calendar/webview.js
+++ b/recipes/google-calendar/webview.js
@@ -13,6 +13,33 @@ module.exports = Ferdium => {
13 location.href = 13 location.href =
14 'https://accounts.google.com/AccountChooser?continue=https://calendar.google.com/u/0/'; 14 'https://accounts.google.com/AccountChooser?continue=https://calendar.google.com/u/0/';
15 } 15 }
16 Ferdium.injectCSS(_path.default.join(__dirname, 'calendar.css')); 16
17 Ferdium.injectJSUnsafe(_path.default.join(__dirname, 'webview-unsafe.js')); 17 Ferdium.injectCSS(_path.default.join(__dirname, 'service.css'));
18 Ferdium.injectCSS(
19 'https://cdn.statically.io/gh/ferdium/ferdium-recipes/main/recipes/google-calendar/calendar.css',
20 );
21 Ferdium.injectJSUnsafe(
22 'https://cdn.statically.io/gh/ferdium/ferdium-recipes/main/recipes/google-calendar/webview-unsave.js',
23 );
24
25 Ferdium.handleDarkMode(isEnabled => {
26 const cssId = 'cssDarkModeWorkaround';
27
28 if (isEnabled) {
29 // Workaround for loading darkmode.css
30 if (!document.querySelector(`#${cssId}`)) {
31 const head = document.querySelectorAll('head')[0];
32 const link = document.createElement('link');
33 link.id = cssId;
34 link.rel = 'stylesheet';
35 link.type = 'text/css';
36 link.href =
37 'https://cdn.statically.io/gh/ferdium/ferdium-recipes/main/recipes/google-calendar/darkmode.css';
38 link.media = 'all';
39 head.append(link);
40 }
41 } else {
42 document.querySelector(`#${cssId}`)?.remove();
43 }
44 });
18}; 45};