diff options
author | 2021-05-27 23:58:09 +0200 | |
---|---|---|
committer | 2021-07-24 00:23:17 +0000 | |
commit | 26cf70e834030fed95701db9b44efd4af9660c27 (patch) | |
tree | 5f498f61a497a24ee0d84e4effea7a18148fff80 /recipes/googlecalendar/webview-unsafe.js | |
parent | [msteams] Context isolation support (diff) | |
download | ferdium-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.js | 39 |
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 @@ | |||
1 | let modal; | ||
2 | let updates = 0; | ||
3 | |||
4 | const waitFor = (condition, callback) => { | ||
5 | if (!condition()) { | ||
6 | window.setTimeout(waitFor.bind(null, condition, callback), 100); | ||
7 | } else { | ||
8 | callback(); | ||
9 | } | ||
10 | }; | ||
11 | |||
12 | const showModal = text => { | ||
13 | modal.querySelector('p').innerHTML = text; | ||
14 | updates += 1; | ||
15 | window.franz.setBadge(updates); | ||
16 | modal.classList.add('open'); | ||
17 | }; | ||
18 | |||
19 | const hideModal = () => { | ||
20 | modal.querySelector('p').innerHTML = ''; | ||
21 | updates -= 1; | ||
22 | window.franz.setBadge(updates); | ||
23 | modal.classList.remove('open'); | ||
24 | }; | ||
25 | |||
26 | const createModal = () => { | ||
27 | const franzModal = document.createElement('div'); | ||
28 | franzModal.setAttribute('id', 'franz-modal'); | ||
29 | franzModal.innerHTML = '<div class="modal-content"><span class="close">×</span><p></p></div>'; | ||
30 | franzModal.querySelector('.close').addEventListener('click', hideModal); | ||
31 | |||
32 | return franzModal; | ||
33 | }; | ||
34 | |||
35 | window.alert = showModal; | ||
36 | |||
37 | modal = createModal(); | ||
38 | waitFor(() => document.body, () => document.body.appendChild(modal)); | ||
39 | document.addEventListener('keydown', event => event.keyCode === 27 && hideModal()); | ||