From dfae2d231e39c81827d08fd8834d736c5b3005b1 Mon Sep 17 00:00:00 2001 From: Vijay A Date: Tue, 31 Aug 2021 16:25:57 +0530 Subject: refactor: Use Ferdi.safeParseInt to ensure that parsing is done consistently in all recipes. --- recipes/office365-owa/webview.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'recipes/office365-owa/webview.js') diff --git a/recipes/office365-owa/webview.js b/recipes/office365-owa/webview.js index 0309488..1a04132 100644 --- a/recipes/office365-owa/webview.js +++ b/recipes/office365-owa/webview.js @@ -5,12 +5,7 @@ module.exports = Ferdi => { if (location.pathname.match(/\/owa/)) { // classic app - directUnreadCount = parseInt( - jQuery("span[title*='Inbox'] + div > span") - .first() - .text(), - 10, - ); + directUnreadCount = Ferdi.safeParseInt(jQuery("span[title*='Inbox'] + div > span").first().text()); } else { // new app const foldersElement = document.querySelector('div[role=tree]:nth-child(3)'); @@ -18,7 +13,7 @@ module.exports = Ferdi => { const allScreenReaders = foldersElement.querySelectorAll('span.screenReaderOnly'); for (const child of allScreenReaders) { if ((child.innerText === 'unread' || child.innerText === 'item') && child.previousSibling) { - directUnreadCount += parseInt(child.previousSibling.innerText, 10); + directUnreadCount += Ferdi.safeParseInt(child.previousSibling.innerText); } } } @@ -28,7 +23,7 @@ module.exports = Ferdi => { const allScreenReaders = groupsElement.querySelectorAll('span.screenReaderOnly'); for (const child of allScreenReaders) { if ((child.innerText === 'unread' || child.innerText === 'item') && child.previousSibling) { - indirectUnreadCount += parseInt(child.previousSibling.innerText, 10); + indirectUnreadCount += Ferdi.safeParseInt(child.previousSibling.innerText); } } } -- cgit v1.2.3-70-g09d2