diff options
author | 2021-12-23 17:00:32 +0100 | |
---|---|---|
committer | 2021-12-23 17:00:32 +0100 | |
commit | 2b0ddd3516b0c329087707bebeaa2bea50f5f724 (patch) | |
tree | 967c747eae4abccf63eef1446f4dbb60a4c78c98 | |
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)
-rw-r--r-- | all.json | 2 | ||||
-rw-r--r-- | recipes/zoho/package.json | 2 | ||||
-rw-r--r-- | recipes/zoho/webview-unsafe.js | 12 | ||||
-rw-r--r-- | recipes/zoho/webview.js | 21 |
4 files changed, 31 insertions, 6 deletions
@@ -2028,7 +2028,7 @@ | |||
2028 | "featured": false, | 2028 | "featured": false, |
2029 | "id": "zoho", | 2029 | "id": "zoho", |
2030 | "name": "Zoho Mail", | 2030 | "name": "Zoho Mail", |
2031 | "version": "1.1.0", | 2031 | "version": "1.2.0", |
2032 | "icons": { | 2032 | "icons": { |
2033 | "svg": "https://cdn.jsdelivr.net/gh/getferdi/recipes/recipes/zoho/icon.svg" | 2033 | "svg": "https://cdn.jsdelivr.net/gh/getferdi/recipes/recipes/zoho/icon.svg" |
2034 | } | 2034 | } |
diff --git a/recipes/zoho/package.json b/recipes/zoho/package.json index 0ad72c0..e6e8823 100644 --- a/recipes/zoho/package.json +++ b/recipes/zoho/package.json | |||
@@ -1,7 +1,7 @@ | |||
1 | { | 1 | { |
2 | "id": "zoho", | 2 | "id": "zoho", |
3 | "name": "Zoho Mail", | 3 | "name": "Zoho Mail", |
4 | "version": "1.1.0", | 4 | "version": "1.2.0", |
5 | "license": "MIT", | 5 | "license": "MIT", |
6 | "config": { | 6 | "config": { |
7 | "serviceURL": "https://www.zoho.com/mail/login.html", | 7 | "serviceURL": "https://www.zoho.com/mail/login.html", |
diff --git a/recipes/zoho/webview-unsafe.js b/recipes/zoho/webview-unsafe.js new file mode 100644 index 0000000..e4026c5 --- /dev/null +++ b/recipes/zoho/webview-unsafe.js | |||
@@ -0,0 +1,12 @@ | |||
1 | //wait for Ferdi and Zoho Mail to initialize | ||
2 | if ( | ||
3 | Object.prototype.hasOwnProperty.call(window, "ferdi") && | ||
4 | Object.prototype.hasOwnProperty.call(window.ferdi, "setBadge") && | ||
5 | Object.prototype.hasOwnProperty.call(window, "zmNCenter") && | ||
6 | Object.prototype.hasOwnProperty.call(window, "zmfolAction") | ||
7 | ) { | ||
8 | var unreadNotifications = window.zmNCenter.counter.count(); //General Notifications by Zoho (Bell Icon) | ||
9 | var unreadMail = window.zmfolAction.getUnreadViewCount(); //Unread messages count | ||
10 | |||
11 | window.ferdi.setBadge(unreadMail, unreadNotifications); | ||
12 | } \ No newline at end of file | ||
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 | }; |