aboutsummaryrefslogtreecommitdiffstats
path: root/recipes
diff options
context:
space:
mode:
authorLibravatar Jonathan Weber <bejonwe@gmail.com>2021-12-23 17:00:32 +0100
committerLibravatar GitHub <noreply@github.com>2021-12-23 17:00:32 +0100
commit2b0ddd3516b0c329087707bebeaa2bea50f5f724 (patch)
tree967c747eae4abccf63eef1446f4dbb60a4c78c98 /recipes
parentRemove duplicate reference to node version for ease of maintenance (diff)
downloadferdium-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')
-rw-r--r--recipes/zoho/package.json2
-rw-r--r--recipes/zoho/webview-unsafe.js12
-rw-r--r--recipes/zoho/webview.js21
3 files changed, 30 insertions, 5 deletions
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
2if (
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 @@
1const _path = _interopRequireDefault(require('path'));
2
3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4
1module.exports = (Ferdi) => { 5module.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};