diff options
author | Vijay A <avijayr@protonmail.com> | 2021-08-31 16:25:57 +0530 |
---|---|---|
committer | Vijay A <avijayr@protonmail.com> | 2021-08-31 16:25:57 +0530 |
commit | dfae2d231e39c81827d08fd8834d736c5b3005b1 (patch) | |
tree | 5037b401e7de837fdd6046a3c61ac76aed240e6e /recipes/office365-owa/webview.js | |
parent | New recipe: odoo (diff) | |
download | ferdium-recipes-dfae2d231e39c81827d08fd8834d736c5b3005b1.tar.gz ferdium-recipes-dfae2d231e39c81827d08fd8834d736c5b3005b1.tar.zst ferdium-recipes-dfae2d231e39c81827d08fd8834d736c5b3005b1.zip |
refactor: Use Ferdi.safeParseInt to ensure that parsing is done consistently in all recipes.
Diffstat (limited to 'recipes/office365-owa/webview.js')
-rw-r--r-- | recipes/office365-owa/webview.js | 11 |
1 files changed, 3 insertions, 8 deletions
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 => { | |||
5 | 5 | ||
6 | if (location.pathname.match(/\/owa/)) { | 6 | if (location.pathname.match(/\/owa/)) { |
7 | // classic app | 7 | // classic app |
8 | directUnreadCount = parseInt( | 8 | directUnreadCount = Ferdi.safeParseInt(jQuery("span[title*='Inbox'] + div > span").first().text()); |
9 | jQuery("span[title*='Inbox'] + div > span") | ||
10 | .first() | ||
11 | .text(), | ||
12 | 10, | ||
13 | ); | ||
14 | } else { | 9 | } else { |
15 | // new app | 10 | // new app |
16 | const foldersElement = document.querySelector('div[role=tree]:nth-child(3)'); | 11 | const foldersElement = document.querySelector('div[role=tree]:nth-child(3)'); |
@@ -18,7 +13,7 @@ module.exports = Ferdi => { | |||
18 | const allScreenReaders = foldersElement.querySelectorAll('span.screenReaderOnly'); | 13 | const allScreenReaders = foldersElement.querySelectorAll('span.screenReaderOnly'); |
19 | for (const child of allScreenReaders) { | 14 | for (const child of allScreenReaders) { |
20 | if ((child.innerText === 'unread' || child.innerText === 'item') && child.previousSibling) { | 15 | if ((child.innerText === 'unread' || child.innerText === 'item') && child.previousSibling) { |
21 | directUnreadCount += parseInt(child.previousSibling.innerText, 10); | 16 | directUnreadCount += Ferdi.safeParseInt(child.previousSibling.innerText); |
22 | } | 17 | } |
23 | } | 18 | } |
24 | } | 19 | } |
@@ -28,7 +23,7 @@ module.exports = Ferdi => { | |||
28 | const allScreenReaders = groupsElement.querySelectorAll('span.screenReaderOnly'); | 23 | const allScreenReaders = groupsElement.querySelectorAll('span.screenReaderOnly'); |
29 | for (const child of allScreenReaders) { | 24 | for (const child of allScreenReaders) { |
30 | if ((child.innerText === 'unread' || child.innerText === 'item') && child.previousSibling) { | 25 | if ((child.innerText === 'unread' || child.innerText === 'item') && child.previousSibling) { |
31 | indirectUnreadCount += parseInt(child.previousSibling.innerText, 10); | 26 | indirectUnreadCount += Ferdi.safeParseInt(child.previousSibling.innerText); |
32 | } | 27 | } |
33 | } | 28 | } |
34 | } | 29 | } |