aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--all.json2
-rw-r--r--recipes/zoho/package.json2
-rw-r--r--recipes/zoho/webview-unsafe.js12
-rw-r--r--recipes/zoho/webview.js21
4 files changed, 31 insertions, 6 deletions
diff --git a/all.json b/all.json
index e1ec541..3eb3a53 100644
--- a/all.json
+++ b/all.json
@@ -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
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};