diff options
author | 2021-12-23 17:00:32 +0100 | |
---|---|---|
committer | 2021-12-23 17:00:32 +0100 | |
commit | 2b0ddd3516b0c329087707bebeaa2bea50f5f724 (patch) | |
tree | 967c747eae4abccf63eef1446f4dbb60a4c78c98 /recipes/zoho/webview.js | |
parent | Remove duplicate reference to node version for ease of maintenance (diff) | |
download | ferdium-recipes-2b0ddd3516b0c329087707bebeaa2bea50f5f724.tar.gz ferdium-recipes-2b0ddd3516b0c329087707bebeaa2bea50f5f724.tar.zst ferdium-recipes-2b0ddd3516b0c329087707bebeaa2bea50f5f724.zip |
Use the Zoho Mail JS API instead of outdated HTML elements (#791)
Diffstat (limited to 'recipes/zoho/webview.js')
-rw-r--r-- | recipes/zoho/webview.js | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/recipes/zoho/webview.js b/recipes/zoho/webview.js index 177ea4c..7c833a3 100644 --- a/recipes/zoho/webview.js +++ b/recipes/zoho/webview.js | |||
@@ -1,10 +1,23 @@ | |||
1 | const _path = _interopRequireDefault(require('path')); | ||
2 | |||
3 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
4 | |||
1 | module.exports = (Ferdi) => { | 5 | module.exports = (Ferdi) => { |
2 | const getMessages = () => { | 6 | const getMessages = () => { |
3 | const unreadMailInCurrentFolder = $('.zmList.zmLUrd').length; | 7 | Ferdi.injectJSUnsafe(_path.default.join(__dirname, 'webview-unsafe.js')); |
4 | const unreadMailAnyware = $('#zmlTree .zmTreeNDWra .zmBold').length; | ||
5 | |||
6 | Ferdi.setBadge(unreadMailInCurrentFolder, unreadMailAnyware); | ||
7 | }; | 8 | }; |
8 | 9 | ||
10 | //Zoho uses different URLs for different regions. Find out which region the account belongs to and redirect to the correct URL. | ||
11 | const redirectRegion = () => { | ||
12 | if (window.location.href === "https://www.zoho.com/mail/login.html") { | ||
13 | const btn = document.querySelectorAll(".access-apps"); | ||
14 | if (btn.length > 0) { | ||
15 | window.location.assign(btn[0].href + "zm/"); | ||
16 | } | ||
17 | } | ||
18 | } | ||
19 | |||
20 | window.addEventListener('load', redirectRegion); | ||
9 | Ferdi.loop(getMessages); | 21 | Ferdi.loop(getMessages); |
22 | |||
10 | }; | 23 | }; |