From d3841b766f9d37d557646003899f67525c5f755f Mon Sep 17 00:00:00 2001 From: Markus Hatvan Date: Tue, 5 Oct 2021 17:04:09 +0200 Subject: chore: add eslint-plugin-unicorn (#733) --- recipes/office365-owa/webview.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'recipes/office365-owa/webview.js') diff --git a/recipes/office365-owa/webview.js b/recipes/office365-owa/webview.js index b897c8d..17649fd 100644 --- a/recipes/office365-owa/webview.js +++ b/recipes/office365-owa/webview.js @@ -1,12 +1,14 @@ module.exports = (Ferdi, settings) => { - const collectCounts = (selector) => { + const collectCounts = selector => { let unreadCount = 0; const foldersElement = document.querySelector(selector); if (foldersElement) { - const allScreenReaders = foldersElement.querySelectorAll('span.screenReaderOnly'); + const allScreenReaders = foldersElement.querySelectorAll( + 'span.screenReaderOnly', + ); for (const child of allScreenReaders) { if (child.previousSibling) { - unreadCount += Ferdi.safeParseInt(child.previousSibling.innerText); + unreadCount += Ferdi.safeParseInt(child.previousSibling.textContent); } } } @@ -17,22 +19,24 @@ module.exports = (Ferdi, settings) => { let directUnreadCount = 0; let indirectUnreadCount = 0; - if (location.pathname.match(/\/owa/)) { + if (/\/owa/.test(location.pathname)) { // classic app - directUnreadCount = Ferdi.safeParseInt(jQuery("span[title*='Inbox'] + div > span").first().text()); + directUnreadCount = Ferdi.safeParseInt( + document.querySelectorAll("span[title*='Inbox'] + div > span")[0] + .textContent, + ); } else { // new app - if (settings.onlyShowFavoritesInUnreadCount === true) { - directUnreadCount = collectCounts('div[role=tree]:nth-child(2)'); // favorites - } else { - directUnreadCount = collectCounts('div[role=tree]:nth-child(3)'); // folders - } + directUnreadCount = + settings.onlyShowFavoritesInUnreadCount === true + ? collectCounts('div[role=tree]:nth-child(2)') + : collectCounts('div[role=tree]:nth-child(3)'); indirectUnreadCount = collectCounts('div[role=tree]:nth-child(4)'); // groups } Ferdi.setBadge(directUnreadCount, indirectUnreadCount); - } + }; Ferdi.loop(getMessages); }; -- cgit v1.2.3-70-g09d2