Skip to content

Commit

Permalink
Update google-calendar recipe to load external scripts to fix CSP error
Browse files Browse the repository at this point in the history
  • Loading branch information
vraravam committed Jul 30, 2023
1 parent 7c985ca commit 11f9e88
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion recipes/google-calendar/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "google-calendar",
"name": "Google Calendar",
"version": "2.4.0",
"version": "2.4.1",
"license": "MIT",
"aliases": [
"google-calendar",
Expand Down
25 changes: 22 additions & 3 deletions recipes/google-calendar/webview.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,31 @@ const _path = _interopRequireDefault(require('path'));
module.exports = Ferdium => {
// if the user is on googlecalendar landing page, go to the login page.
if (
location.hostname === 'workspace.google.com' &&
location.hostname == 'workspace.google.com' &&
location.href.includes('products/calendar/')
) {
location.href =
'https://accounts.google.com/AccountChooser?continue=https://calendar.google.com/u/0/';
}
Ferdium.injectCSS(_path.default.join(__dirname, 'calendar.css'));
Ferdium.injectJSUnsafe(_path.default.join(__dirname, 'webview-unsafe.js'));
Ferdium.injectCSS(_path.default.join(__dirname, 'service.css'));
Ferdium.injectCSS(
'https://cdn.statically.io/gh/ferdium/ferdium-recipes/main/recipes/google-calendar/calendar.css',
);
Ferdium.injectJSUnsafe(
'https://cdn.statically.io/gh/ferdium/ferdium-recipes/main/recipes/google-calendar/webview-unsave.js',
);

// Workaround for loading darkmode.css
const cssId = 'cssDarkModeWorkaround';
if (!document.querySelector(cssId)) {
const head = document.querySelectorAll('head')[0];
const link = document.createElement('link');
link.id = cssId;
link.rel = 'stylesheet';
link.type = 'text/css';
link.href =
'https://cdn.statically.io/gh/ferdium/ferdium-recipes/main/recipes/google-calendar/darkmode.css';
link.media = 'all';
head.append(link);
}
};

0 comments on commit 11f9e88

Please sign in to comment.