From 822c5680c0461c90468cd8a69a37e3354376c73c Mon Sep 17 00:00:00 2001 From: Cromefire_ Date: Tue, 5 Jan 2021 22:59:23 +0100 Subject: Synchronize Outlook services and correct message count (#398) --- recipes/office365-owa/README.md | 8 ++++---- recipes/office365-owa/index.js | 4 ++-- recipes/office365-owa/package.json | 2 +- recipes/office365-owa/webview.js | 15 ++++++++------- recipes/outlook/README.md | 8 ++++---- recipes/outlook/index.js | 4 ++-- recipes/outlook/package.json | 23 ++++++++++++----------- recipes/outlook/webview.js | 38 +++++++++++++++++++++++++++++++------- 8 files changed, 64 insertions(+), 38 deletions(-) (limited to 'recipes') diff --git a/recipes/office365-owa/README.md b/recipes/office365-owa/README.md index a35ef46..0aca27b 100644 --- a/recipes/office365-owa/README.md +++ b/recipes/office365-owa/README.md @@ -1,5 +1,5 @@ -# Office 365 Outlook Web App for Franz -This is the Franz 5 Recipe for Office 365 Outlook Web App +# Office 365 Outlook Web App for Ferdi +This is the Ferdi 5 Recipe for Office 365 Outlook Web App -### How to create your own Franz recipes: -* [Read the documentation](https://github.com/meetfranz/plugins) +### How to create your own Ferdi recipes: +* [Read the documentation](https://github.com/getferdi/recipes/blob/master/docs/integration.md.) diff --git a/recipes/office365-owa/index.js b/recipes/office365-owa/index.js index ce5229a..12994ff 100644 --- a/recipes/office365-owa/index.js +++ b/recipes/office365-owa/index.js @@ -1,7 +1,7 @@ var os = require('os') -module.exports = Franz => - class Owa extends Franz { +module.exports = Ferdi => + class Outlook extends Ferdi { overrideUserAgent() { return window.navigator.userAgent.replace(/(Ferdi|Electron)\/\S+ \([^)]+\)/g,"").trim(); } diff --git a/recipes/office365-owa/package.json b/recipes/office365-owa/package.json index 1ffb2ee..35c4647 100644 --- a/recipes/office365-owa/package.json +++ b/recipes/office365-owa/package.json @@ -10,7 +10,7 @@ ], "license": "MIT", "config": { - "serviceURL": "https://outlook.office365.com/owa", + "serviceURL": "https://outlook.office365.com/mail/", "hasNotificationSound": true, "hasTeamId": false } diff --git a/recipes/office365-owa/webview.js b/recipes/office365-owa/webview.js index ae21e19..6d4edf2 100644 --- a/recipes/office365-owa/webview.js +++ b/recipes/office365-owa/webview.js @@ -1,7 +1,7 @@ 'use strict'; -module.exports = Franz => { - const getMessages = function getMessages() { +module.exports = Ferdi => { + function getMessages() { let unreadMail = 0; if (location.pathname.match(/\/owa/)) { @@ -14,12 +14,13 @@ module.exports = Franz => { ); } else { // new app - const folders = document.querySelector('div[title="Folders"]'); - if (!folders) { + const favorites = document.querySelector('div[title="Favorites"]'); + if (!favorites) { return; } + const folders = Array.from(favorites.nextSibling.childNodes); - unreadMail = [...folders.parentNode.parentNode.children].reduce((count, child) => { + unreadMail = folders.reduce((count, child) => { const unread = child.querySelector('.screenReaderOnly'); return unread && unread.textContent === 'unread' ? count + parseInt(unread.previousSibling.textContent, 10) @@ -27,7 +28,7 @@ module.exports = Franz => { }, 0); } - Franz.setBadge(unreadMail); + Ferdi.setBadge(unreadMail); }; - Franz.loop(getMessages); + Ferdi.loop(getMessages); }; diff --git a/recipes/outlook/README.md b/recipes/outlook/README.md index 8d68fd4..47dbb00 100644 --- a/recipes/outlook/README.md +++ b/recipes/outlook/README.md @@ -1,5 +1,5 @@ -# Outlook Web App for Franz -This is the Franz 5 Recipe for Outlook Web App +# Outlook Web App for Ferdi +This is the Ferdi 5 Recipe for Outlook Web App -### How to create your own Franz recipes: -* [Read the documentation](https://github.com/meetfranz/plugins) +### How to create your own Ferdi recipes: +* [Read the documentation](https://github.com/getferdi/recipes/blob/master/docs/integration.md.) diff --git a/recipes/outlook/index.js b/recipes/outlook/index.js index 5d96b3e..12994ff 100644 --- a/recipes/outlook/index.js +++ b/recipes/outlook/index.js @@ -1,7 +1,7 @@ var os = require('os') -module.exports = Franz => - class Outlook extends Franz { +module.exports = Ferdi => + class Outlook extends Ferdi { overrideUserAgent() { return window.navigator.userAgent.replace(/(Ferdi|Electron)\/\S+ \([^)]+\)/g,"").trim(); } diff --git a/recipes/outlook/package.json b/recipes/outlook/package.json index 79f3b4b..7594b71 100644 --- a/recipes/outlook/package.json +++ b/recipes/outlook/package.json @@ -1,13 +1,14 @@ { - "id": "outlook", - "name": "Outlook", - "version": "1.0.1", - "description": "Outlook Web App", - "main": "index.js", - "author": "Wouter Van Speybroeck ", - "repository": "", - "license": "MIT", - "config": { - "serviceURL": "https://outlook.live.com/owa/" - } + "id": "outlook", + "name": "Outlook Web App", + "version": "1.1.0", + "description": "Outlook Web App", + "main": "index.js", + "author": "Wouter Van Speybroeck ", + "license": "MIT", + "config": { + "serviceURL": "https://outlook.live.com/mail/", + "hasNotificationSound": true, + "hasTeamId": false + } } diff --git a/recipes/outlook/webview.js b/recipes/outlook/webview.js index 7e30fe4..6d4edf2 100644 --- a/recipes/outlook/webview.js +++ b/recipes/outlook/webview.js @@ -1,10 +1,34 @@ -"use strict"; +'use strict'; -module.exports = Franz => { - const getMessages = function getMessages() { - const unreadMail = parseInt(jQuery("i[data-icon-name='Inbox'] + span + span > span").first().text(), 10); - Franz.setBadge(unreadMail); +module.exports = Ferdi => { + function getMessages() { + let unreadMail = 0; + + if (location.pathname.match(/\/owa/)) { + // classic app + unreadMail = parseInt( + jQuery("span[title*='Inbox'] + div > span") + .first() + .text(), + 10 + ); + } else { + // new app + const favorites = document.querySelector('div[title="Favorites"]'); + if (!favorites) { + return; + } + const folders = Array.from(favorites.nextSibling.childNodes); + + unreadMail = folders.reduce((count, child) => { + const unread = child.querySelector('.screenReaderOnly'); + return unread && unread.textContent === 'unread' + ? count + parseInt(unread.previousSibling.textContent, 10) + : count; + }, 0); + } + + Ferdi.setBadge(unreadMail); }; - Franz.loop(getMessages); + Ferdi.loop(getMessages); }; -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm9mZmljZTM2NS1vd2Evd2Vidmlldy5qcyJdLCJuYW1lcyI6WyJtb2R1bGUiLCJleHBvcnRzIiwiRnJhbnoiLCJnZXRNZXNzYWdlcyIsInVucmVhZE1haWwiLCJwYXJzZUludCIsImpRdWVyeSIsImZpcnN0IiwidGV4dCIsInNldEJhZGdlIiwibG9vcCJdLCJtYXBwaW5ncyI6Ijs7QUFBQSxPQUFPLEFBQVAsVUFBa0IsQUFBRCxTQUFXLEFBQzFCO1FBQU0sY0FBYyxTQUFTLEFBQVQsY0FBdUIsQUFDekM7VUFBTSxhQUFhLFNBQVMsT0FBTyxBQUFQLEFBQTRDLEFBQTVDLEFBQW9ELEFBQXBELGtEQUFULEFBQXFFLEFBQXJFLEFBQW5CLGdCQUNBO1VBQU0sQUFBTixTQUFlLEFBQWYsQUFDRDtBQUhELEFBSUE7UUFBTSxBQUFOLEtBQVcsQUFBWCxBQUNEO0FBTkQiLCJmaWxlIjoib2ZmaWNlMzY1LW93YS93ZWJ2aWV3LmpzIiwic291cmNlc0NvbnRlbnQiOlsibW9kdWxlLmV4cG9ydHMgPSAoRnJhbnopID0+IHtcbiAgY29uc3QgZ2V0TWVzc2FnZXMgPSBmdW5jdGlvbiBnZXRNZXNzYWdlcygpIHtcbiAgICBjb25zdCB1bnJlYWRNYWlsID0gcGFyc2VJbnQoalF1ZXJ5KFwic3Bhblt0aXRsZSo9J0luYm94J10gKyBkaXYgPiBzcGFuXCIpLmZpcnN0KCkudGV4dCgpLCAxMCk7XG4gICAgRnJhbnouc2V0QmFkZ2UodW5yZWFkTWFpbCk7XG4gIH07XG4gIEZyYW56Lmxvb3AoZ2V0TWVzc2FnZXMpO1xufTtcbiJdfQ== \ No newline at end of file -- cgit v1.2.3-54-g00ecf