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.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.js')
-rw-r--r-- | recipes/googlecalendar/webview.js | 43 |
1 files changed, 1 insertions, 42 deletions
diff --git a/recipes/googlecalendar/webview.js b/recipes/googlecalendar/webview.js index 469ff0c..729f400 100644 --- a/recipes/googlecalendar/webview.js +++ b/recipes/googlecalendar/webview.js | |||
@@ -3,47 +3,6 @@ | |||
3 | const path = require('path'); | 3 | const path = require('path'); |
4 | 4 | ||
5 | module.exports = Franz => { | 5 | module.exports = Franz => { |
6 | let modal; | ||
7 | let updates = 0; | ||
8 | |||
9 | const waitFor = (condition, callback) => { | ||
10 | if (!condition()) { | ||
11 | window.setTimeout(waitFor.bind(null, condition, callback), 100); | ||
12 | } else { | ||
13 | callback(); | ||
14 | } | ||
15 | }; | ||
16 | |||
17 | const createModal = () => { | ||
18 | const franzModal = document.createElement('div'); | ||
19 | franzModal.setAttribute('id', 'franz-modal'); | ||
20 | franzModal.innerHTML = '<div class="modal-content"><span class="close">×</span><p></p></div>'; | ||
21 | franzModal.querySelector('.close').addEventListener('click', hideModal); | ||
22 | |||
23 | return franzModal; | ||
24 | }; | ||
25 | |||
26 | const showModal = text => { | ||
27 | modal.querySelector('p').innerHTML = text; | ||
28 | updates++; | ||
29 | modal.classList.add('open'); | ||
30 | }; | ||
31 | |||
32 | const hideModal = () => { | ||
33 | modal.querySelector('p').innerHTML = ''; | ||
34 | updates--; | ||
35 | modal.classList.remove('open'); | ||
36 | }; | ||
37 | |||
38 | window.alert = showModal; | ||
39 | |||
40 | const getMessages = () => Franz.setBadge(updates); | ||
41 | |||
42 | modal = createModal(); | ||
43 | waitFor(() => document.body, () => document.body.appendChild(modal)); | ||
44 | document.addEventListener('keydown', event => event.keyCode === 27 && hideModal()); | ||
45 | |||
46 | Franz.injectCSS(path.join(__dirname, 'calendar.css')); | 6 | Franz.injectCSS(path.join(__dirname, 'calendar.css')); |
47 | Franz.loop(getMessages); | 7 | Franz.injectJSUnsafe(path.join(__dirname, 'webview-unsafe.js')); |
48 | }; | 8 | }; |
49 | //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdvb2dsZWNhbGVuZGFyL3dlYnZpZXcuanMiXSwibmFtZXMiOlsicGF0aCIsInJlcXVpcmUiLCJtb2R1bGUiLCJleHBvcnRzIiwiRnJhbnoiLCJtb2RhbCIsInVwZGF0ZXMiLCJjcmVhdGVNb2RhbCIsImZyYW56TW9kYWwiLCJkb2N1bWVudCIsImNyZWF0ZUVsZW1lbnQiLCJzZXRBdHRyaWJ1dGUiLCJpbm5lckhUTUwiLCJxdWVyeVNlbGVjdG9yIiwiYWRkRXZlbnRMaXN0ZW5lciIsImhpZGVNb2RhbCIsInNob3dNb2RhbCIsInRleHQiLCJjbGFzc0xpc3QiLCJhZGQiLCJyZW1vdmUiLCJ3aW5kb3ciLCJhbGVydCIsImdldE1lc3NhZ2VzIiwic2V0QmFkZ2UiLCJib2R5IiwiYXBwZW5kQ2hpbGQiLCJldmVudCIsImtleUNvZGUiLCJpbmplY3RDU1MiLCJqb2luIiwiX19kaXJuYW1lIiwibG9vcCJdLCJtYXBwaW5ncyI6Ijs7QUFBQSxNQUFNQSxPQUFPQyxRQUFRLE1BQVIsQ0FBYjs7QUFFQUMsT0FBT0MsT0FBUCxHQUFpQkMsU0FBUztBQUN4QixNQUFJQyxLQUFKO0FBQ0EsTUFBSUMsVUFBVSx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