aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/googlecalendar/webview-unsafe.js
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2021-05-27 23:58:09 +0200
committerLibravatar Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com>2021-07-24 00:23:17 +0000
commit26cf70e834030fed95701db9b44efd4af9660c27 (patch)
tree5f498f61a497a24ee0d84e4effea7a18148fff80 /recipes/googlecalendar/webview-unsafe.js
parent[msteams] Context isolation support (diff)
downloadferdium-recipes-26cf70e834030fed95701db9b44efd4af9660c27.tar.gz
ferdium-recipes-26cf70e834030fed95701db9b44efd4af9660c27.tar.zst
ferdium-recipes-26cf70e834030fed95701db9b44efd4af9660c27.zip
[googlecalendar] Context isolation support
Diffstat (limited to 'recipes/googlecalendar/webview-unsafe.js')
-rw-r--r--recipes/googlecalendar/webview-unsafe.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/recipes/googlecalendar/webview-unsafe.js b/recipes/googlecalendar/webview-unsafe.js
new file mode 100644
index 0000000..68145ad
--- /dev/null
+++ b/recipes/googlecalendar/webview-unsafe.js
@@ -0,0 +1,39 @@
1let modal;
2let updates = 0;
3
4const waitFor = (condition, callback) => {
5 if (!condition()) {
6 window.setTimeout(waitFor.bind(null, condition, callback), 100);
7 } else {
8 callback();
9 }
10};
11
12const showModal = text => {
13 modal.querySelector('p').innerHTML = text;
14 updates += 1;
15 window.franz.setBadge(updates);
16 modal.classList.add('open');
17};
18
19const hideModal = () => {
20 modal.querySelector('p').innerHTML = '';
21 updates -= 1;
22 window.franz.setBadge(updates);
23 modal.classList.remove('open');
24};
25
26const createModal = () => {
27 const franzModal = document.createElement('div');
28 franzModal.setAttribute('id', 'franz-modal');
29 franzModal.innerHTML = '<div class="modal-content"><span class="close">&times;</span><p></p></div>';
30 franzModal.querySelector('.close').addEventListener('click', hideModal);
31
32 return franzModal;
33};
34
35window.alert = showModal;
36
37modal = createModal();
38waitFor(() => document.body, () => document.body.appendChild(modal));
39document.addEventListener('keydown', event => event.keyCode === 27 && hideModal());