aboutsummaryrefslogtreecommitdiffstats
path: root/recipes
diff options
context:
space:
mode:
authorLibravatar Vijay A <avijayr@protonmail.com>2021-08-31 16:25:57 +0530
committerLibravatar Vijay A <avijayr@protonmail.com>2021-08-31 16:25:57 +0530
commitdfae2d231e39c81827d08fd8834d736c5b3005b1 (patch)
tree5037b401e7de837fdd6046a3c61ac76aed240e6e /recipes
parentNew recipe: odoo (diff)
downloadferdium-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')
-rw-r--r--recipes/anydo/package.json2
-rw-r--r--recipes/anydo/webview.js2
-rw-r--r--recipes/aws-workmail/package.json2
-rw-r--r--recipes/aws-workmail/webview.js3
-rw-r--r--recipes/bip/package.json2
-rw-r--r--recipes/bip/webview.js3
-rw-r--r--recipes/campuswire/package.json2
-rw-r--r--recipes/campuswire/webview.js2
-rw-r--r--recipes/chatwork/package.json2
-rw-r--r--recipes/chatwork/webview.js7
-rw-r--r--recipes/ciscospark/package.json2
-rw-r--r--recipes/ciscospark/webview.js6
-rw-r--r--recipes/discord/package.json2
-rw-r--r--recipes/discord/webview.js4
-rw-r--r--recipes/disqus/package.json2
-rw-r--r--recipes/disqus/webview.js2
-rw-r--r--recipes/element/package.json2
-rw-r--r--recipes/element/webview.js14
-rw-r--r--recipes/erepublik/package.json2
-rw-r--r--recipes/erepublik/webview.js11
-rwxr-xr-xrecipes/facebook/package.json2
-rwxr-xr-xrecipes/facebook/webview.js4
-rw-r--r--recipes/facebookpages/package.json2
-rw-r--r--recipes/facebookpages/webview.js2
-rw-r--r--recipes/feedly/package.json2
-rw-r--r--recipes/feedly/webview.js2
-rw-r--r--recipes/gadugadu/package.json2
-rw-r--r--recipes/gadugadu/webview.js13
-rw-r--r--recipes/github/package.json2
-rw-r--r--recipes/github/webview.js13
-rw-r--r--recipes/glowing-bear/package.json2
-rw-r--r--recipes/glowing-bear/webview.js6
-rw-r--r--recipes/gmail/package.json2
-rw-r--r--recipes/gmail/webview.js5
-rw-r--r--recipes/google-voice/package.json2
-rw-r--r--recipes/google-voice/webview.js4
-rw-r--r--recipes/googleclassroom/package.json2
-rw-r--r--recipes/googleclassroom/webview.js2
-rw-r--r--recipes/guilded/package.json2
-rw-r--r--recipes/guilded/webview.js2
-rw-r--r--recipes/icq/package.json2
-rw-r--r--recipes/icq/webview.js13
-rw-r--r--recipes/instagram/package.json2
-rw-r--r--recipes/instagram/webview.js2
-rw-r--r--recipes/intercom/package.json2
-rw-r--r--recipes/intercom/webview.js4
-rw-r--r--recipes/jira/package.json2
-rw-r--r--recipes/jira/webview.js5
-rw-r--r--recipes/lark/package.json2
-rw-r--r--recipes/lark/webview.js3
-rw-r--r--recipes/linkedin/package.json2
-rw-r--r--recipes/linkedin/webview.js3
-rw-r--r--recipes/messenger/package.json2
-rw-r--r--recipes/messenger/webview.js4
-rw-r--r--recipes/monday/package.json2
-rwxr-xr-xrecipes/monday/webview.js2
-rw-r--r--recipes/msteams/package.json2
-rw-r--r--recipes/msteams/webview.js5
-rw-r--r--recipes/mysms/package.json2
-rw-r--r--recipes/mysms/webview.js3
-rw-r--r--recipes/nextdoor/package.json2
-rw-r--r--recipes/nextdoor/webview.js2
-rw-r--r--recipes/notion/package.json2
-rw-r--r--recipes/notion/webview.js5
-rw-r--r--recipes/office365-owa/package.json2
-rw-r--r--recipes/office365-owa/webview.js11
-rw-r--r--recipes/pivotal-tracker/package.json2
-rw-r--r--recipes/pivotal-tracker/webview.js5
-rw-r--r--recipes/pleroma/package.json2
-rw-r--r--recipes/pleroma/webview.js4
-rw-r--r--recipes/plurk/package.json2
-rw-r--r--recipes/plurk/webview.js7
-rwxr-xr-xrecipes/protonet/package.json2
-rwxr-xr-xrecipes/protonet/webview.js4
-rw-r--r--recipes/rainloop/package.json2
-rw-r--r--recipes/rainloop/webview.js4
-rw-r--r--recipes/reddit/package.json2
-rw-r--r--recipes/reddit/webview.js3
-rw-r--r--recipes/riseup/package.json2
-rw-r--r--recipes/riseup/webview.js2
-rw-r--r--recipes/rocketchat/package.json2
-rw-r--r--recipes/rocketchat/webview.js2
-rw-r--r--recipes/roundcube/package.json2
-rw-r--r--recipes/roundcube/webview.js3
-rw-r--r--recipes/simplenote/package.json2
-rw-r--r--recipes/simplenote/webview.js3
-rw-r--r--recipes/skype/package.json2
-rw-r--r--recipes/skype/webview.js4
-rw-r--r--recipes/slite/package.json2
-rw-r--r--recipes/slite/webview.js12
-rw-r--r--recipes/steamchat/package.json2
-rw-r--r--recipes/steamchat/webview.js2
-rw-r--r--recipes/teamleader/package.json2
-rw-r--r--recipes/teamleader/webview.js3
-rw-r--r--recipes/teamwork-projects/package.json2
-rw-r--r--recipes/teamwork-projects/webview.js2
-rw-r--r--recipes/telegram-react/package.json2
-rw-r--r--recipes/telegram-react/webview.js2
-rw-r--r--recipes/telegram/package.json2
-rw-r--r--recipes/telegram/webview.js12
-rw-r--r--recipes/thelounge/package.json2
-rw-r--r--recipes/thelounge/webview.js5
-rw-r--r--recipes/threema/package.json2
-rw-r--r--recipes/threema/webview.js2
-rw-r--r--recipes/todoist/package.json2
-rw-r--r--recipes/todoist/webview.js4
-rw-r--r--recipes/tweetdeck/package.json2
-rw-r--r--recipes/tweetdeck/webview.js2
-rw-r--r--recipes/twitter-dm/package.json2
-rw-r--r--recipes/twitter-dm/webview.js3
-rw-r--r--recipes/vk/package.json2
-rw-r--r--recipes/vk/webview.js5
-rw-r--r--recipes/webex-teams/package.json2
-rw-r--r--recipes/webex-teams/webview.js6
-rw-r--r--recipes/wechat/package.json2
-rw-r--r--recipes/wechat/webview.js4
-rw-r--r--recipes/whatsapp/package.json2
-rw-r--r--recipes/whatsapp/webview.js2
-rw-r--r--recipes/wire/package.json2
-rw-r--r--recipes/wire/webview.js9
-rw-r--r--recipes/workplace/package.json2
-rw-r--r--recipes/workplace/webview.js4
-rw-r--r--recipes/wrike/package.json2
-rw-r--r--recipes/wrike/webview.js5
-rw-r--r--recipes/xing/package.json2
-rw-r--r--recipes/xing/webview.js5
-rw-r--r--recipes/yammer/package.json2
-rw-r--r--recipes/yammer/webview.js8
-rw-r--r--recipes/zendesk/package.json2
-rw-r--r--recipes/zendesk/webview.js7
130 files changed, 196 insertions, 248 deletions
diff --git a/recipes/anydo/package.json b/recipes/anydo/package.json
index e015aee..eb6d8d4 100644
--- a/recipes/anydo/package.json
+++ b/recipes/anydo/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "anydo", 2 "id": "anydo",
3 "name": "Any.do", 3 "name": "Any.do",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "repository": "https://github.com/chappy84/recipe-anydo", 6 "repository": "https://github.com/chappy84/recipe-anydo",
7 "config": { 7 "config": {
diff --git a/recipes/anydo/webview.js b/recipes/anydo/webview.js
index cdb7e4f..4f4749b 100644
--- a/recipes/anydo/webview.js
+++ b/recipes/anydo/webview.js
@@ -6,7 +6,7 @@ module.exports = (Ferdi) => {
6 6
7 if (countEls.length) { 7 if (countEls.length) {
8 Array.from(countEls).forEach((el) => { 8 Array.from(countEls).forEach((el) => {
9 incompleteCount += parseInt(el.innerHTML, 10); 9 incompleteCount += Ferdi.safeParseInt(el.innerHTML);
10 }); 10 });
11 } 11 }
12 12
diff --git a/recipes/aws-workmail/package.json b/recipes/aws-workmail/package.json
index 5641f43..e407dd2 100644
--- a/recipes/aws-workmail/package.json
+++ b/recipes/aws-workmail/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "amazon-work-mail", 2 "id": "amazon-work-mail",
3 "name": "Amazon WorkMail", 3 "name": "Amazon WorkMail",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://{teamID}.awsapps.com/mail", 7 "serviceURL": "https://{teamID}.awsapps.com/mail",
diff --git a/recipes/aws-workmail/webview.js b/recipes/aws-workmail/webview.js
index 5c77d79..944a15c 100644
--- a/recipes/aws-workmail/webview.js
+++ b/recipes/aws-workmail/webview.js
@@ -16,8 +16,7 @@ module.exports = (Ferdi) => {
16 let counter = 0; 16 let counter = 0;
17 17
18 for (let i = 0; i < nodes.length; i++) { 18 for (let i = 0; i < nodes.length; i++) {
19 const node = parseInt(nodes[i].innerText); 19 counter += Ferdi.safeParseInt(nodes[i].innerText);
20 counter += (node > 0) ? node : 0;
21 } 20 }
22 21
23 Ferdi.setBadge(counter); 22 Ferdi.setBadge(counter);
diff --git a/recipes/bip/package.json b/recipes/bip/package.json
index 8898d1d..3bc6898 100644
--- a/recipes/bip/package.json
+++ b/recipes/bip/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "bip", 2 "id": "bip",
3 "name": "BiP", 3 "name": "BiP",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://web.bip.com/", 7 "serviceURL": "https://web.bip.com/",
diff --git a/recipes/bip/webview.js b/recipes/bip/webview.js
index 87a7c0a..89668d7 100644
--- a/recipes/bip/webview.js
+++ b/recipes/bip/webview.js
@@ -7,8 +7,7 @@ module.exports = Ferdi => {
7 const elements = document.querySelectorAll('.contact-list__message__unread-badge-counter'); 7 const elements = document.querySelectorAll('.contact-list__message__unread-badge-counter');
8 let count = 0; 8 let count = 0;
9 for (let i = 0; i < elements.length; i++) { 9 for (let i = 0; i < elements.length; i++) {
10 const countValue = parseInt(elements[i].textContent || '0', 10); 10 count += Ferdi.safeParseInt(elements[i].textContent);
11 count += countValue;
12 } 11 }
13 Ferdi.setBadge(count, 0); 12 Ferdi.setBadge(count, 0);
14 }; 13 };
diff --git a/recipes/campuswire/package.json b/recipes/campuswire/package.json
index e305ef1..334061f 100644
--- a/recipes/campuswire/package.json
+++ b/recipes/campuswire/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "campuswire", 2 "id": "campuswire",
3 "name": "Campuswire", 3 "name": "Campuswire",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://campuswire.com/c", 7 "serviceURL": "https://campuswire.com/c",
diff --git a/recipes/campuswire/webview.js b/recipes/campuswire/webview.js
index 5f43cbb..34878f3 100644
--- a/recipes/campuswire/webview.js
+++ b/recipes/campuswire/webview.js
@@ -4,7 +4,7 @@ module.exports = Ferdi => {
4 const messageRequestsElement = document.querySelector('._5nxf'); 4 const messageRequestsElement = document.querySelector('._5nxf');
5 5
6 if (messageRequestsElement) { 6 if (messageRequestsElement) {
7 count += parseInt(messageRequestsElement.innerHTML, 10); 7 count += Ferdi.safeParseInt(messageRequestsElement.innerHTML);
8 } 8 }
9 9
10 Ferdi.setBadge(count); 10 Ferdi.setBadge(count);
diff --git a/recipes/chatwork/package.json b/recipes/chatwork/package.json
index eb6eaf8..52cbf02 100644
--- a/recipes/chatwork/package.json
+++ b/recipes/chatwork/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "chatwork", 2 "id": "chatwork",
3 "name": "ChatWork", 3 "name": "ChatWork",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "repository": "https://github.com/hideosasaki/recipe-chatwork", 6 "repository": "https://github.com/hideosasaki/recipe-chatwork",
7 "config": { 7 "config": {
diff --git a/recipes/chatwork/webview.js b/recipes/chatwork/webview.js
index e131093..cc40834 100644
--- a/recipes/chatwork/webview.js
+++ b/recipes/chatwork/webview.js
@@ -1,7 +1,5 @@
1module.exports = (Ferdi) => { 1module.exports = (Ferdi) => {
2 function getMessages() { 2 function getMessages() {
3 let groupCount = 0;
4 let individualCount = 0;
5 let directCount = 0; 3 let directCount = 0;
6 let indirectCount = 0; 4 let indirectCount = 0;
7 const roomInfoContainer = document.querySelectorAll('li.sc-dnqmqq'); 5 const roomInfoContainer = document.querySelectorAll('li.sc-dnqmqq');
@@ -11,20 +9,17 @@ module.exports = (Ferdi) => {
11 const unreadBadgeHasMention = room.querySelector('li._unreadBadge.sc-cSHVUG'); 9 const unreadBadgeHasMention = room.querySelector('li._unreadBadge.sc-cSHVUG');
12 10
13 if (unreadBadge && unreadBadge.innerText) { 11 if (unreadBadge && unreadBadge.innerText) {
14 count = parseInt(unreadBadge.innerText); 12 count = Ferdi.safeParseInt(unreadBadge.innerText);
15 } 13 }
16 14
17 if (count > 0) { 15 if (count > 0) {
18 if (room.querySelector('img.sc-gqjmRU').getAttribute('src').indexOf('avatar') < 0) { 16 if (room.querySelector('img.sc-gqjmRU').getAttribute('src').indexOf('avatar') < 0) {
19 groupCount += count;
20
21 if (unreadBadgeHasMention) { 17 if (unreadBadgeHasMention) {
22 directCount++; 18 directCount++;
23 } else { 19 } else {
24 indirectCount++; 20 indirectCount++;
25 } 21 }
26 } else { 22 } else {
27 individualCount += count;
28 directCount++; 23 directCount++;
29 } 24 }
30 } 25 }
diff --git a/recipes/ciscospark/package.json b/recipes/ciscospark/package.json
index ec9f3c8..dbf031e 100644
--- a/recipes/ciscospark/package.json
+++ b/recipes/ciscospark/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "ciscospark", 2 "id": "ciscospark",
3 "name": "Cisco Spark", 3 "name": "Cisco Spark",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://web.ciscospark.com", 7 "serviceURL": "https://web.ciscospark.com",
diff --git a/recipes/ciscospark/webview.js b/recipes/ciscospark/webview.js
index 4de3fb1..8de5b8d 100644
--- a/recipes/ciscospark/webview.js
+++ b/recipes/ciscospark/webview.js
@@ -11,10 +11,10 @@ module.exports = Ferdi => {
11 11
12 const elements = document.querySelectorAll('.navigation-bar-list .listItemWrapper'); 12 const elements = document.querySelectorAll('.navigation-bar-list .listItemWrapper');
13 if (elements.length > 0 && elements[1].querySelector(UNREAD_BADGE_SELECTOR)) { 13 if (elements.length > 0 && elements[1].querySelector(UNREAD_BADGE_SELECTOR)) {
14 directCount = parseInt(elements[1].querySelector(UNREAD_BADGE_SELECTOR).textContent, 10); 14 directCount = Ferdi.safeParseInt(elements[1].querySelector(UNREAD_BADGE_SELECTOR).textContent);
15 } 15 }
16 if (elements.length > 0 && elements[2].querySelector(UNREAD_BADGE_SELECTOR)) { 16 if (elements.length > 1 && elements[2].querySelector(UNREAD_BADGE_SELECTOR)) {
17 indirectCount = parseInt(elements[2].querySelector(UNREAD_BADGE_SELECTOR).textContent, 10); 17 indirectCount = Ferdi.safeParseInt(elements[2].querySelector(UNREAD_BADGE_SELECTOR).textContent);
18 } 18 }
19 19
20 Ferdi.setBadge(directCount, indirectCount); 20 Ferdi.setBadge(directCount, indirectCount);
diff --git a/recipes/discord/package.json b/recipes/discord/package.json
index 85069d9..7a2ec50 100644
--- a/recipes/discord/package.json
+++ b/recipes/discord/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "discord", 2 "id": "discord",
3 "name": "Discord", 3 "name": "Discord",
4 "version": "1.3.0", 4 "version": "1.3.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://discordapp.com/login", 7 "serviceURL": "https://discordapp.com/login",
diff --git a/recipes/discord/webview.js b/recipes/discord/webview.js
index 88a5c50..0559612 100644
--- a/recipes/discord/webview.js
+++ b/recipes/discord/webview.js
@@ -75,7 +75,9 @@ module.exports = (Ferdi, settings) => {
75 75
76 if (elementContainer) { 76 if (elementContainer) {
77 const element = elementContainer.querySelector('[data-text-as-pseudo-element]'); 77 const element = elementContainer.querySelector('[data-text-as-pseudo-element]');
78 count = parseInt(element.dataset.textAsPseudoElement, 10); 78 if (element && element.dataset) {
79 count = Ferdi.safeParseInt(element.dataset.textAsPseudoElement);
80 }
79 } 81 }
80 } 82 }
81 } 83 }
diff --git a/recipes/disqus/package.json b/recipes/disqus/package.json
index f9a48df..73f9a24 100644
--- a/recipes/disqus/package.json
+++ b/recipes/disqus/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "disqus", 2 "id": "disqus",
3 "name": "Disqus", 3 "name": "Disqus",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://disqus.com/home/" 7 "serviceURL": "https://disqus.com/home/"
diff --git a/recipes/disqus/webview.js b/recipes/disqus/webview.js
index c1e315c..b5c1902 100644
--- a/recipes/disqus/webview.js
+++ b/recipes/disqus/webview.js
@@ -1,6 +1,6 @@
1const getInnerInt = selector => { 1const getInnerInt = selector => {
2 const element = document.querySelector(selector); 2 const element = document.querySelector(selector);
3 return element && parseInt(element.innerText); 3 return element && Ferdi.safeParseInt(element.innerText);
4}; 4};
5 5
6module.exports = Ferdi => { 6module.exports = Ferdi => {
diff --git a/recipes/element/package.json b/recipes/element/package.json
index 528e167..d4cf96d 100644
--- a/recipes/element/package.json
+++ b/recipes/element/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "element", 2 "id": "element",
3 "name": "Element", 3 "name": "Element",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "aliases": [ 6 "aliases": [
7 "Riot.im", 7 "Riot.im",
diff --git a/recipes/element/webview.js b/recipes/element/webview.js
index 18bb7ad..c1fdea3 100644
--- a/recipes/element/webview.js
+++ b/recipes/element/webview.js
@@ -3,19 +3,19 @@ module.exports = Ferdi => {
3 const badges = document.querySelectorAll('.mx_RoomSublist:not(.mx_RoomSublist_hidden) .mx_RoomSublist_badgeContainer'); 3 const badges = document.querySelectorAll('.mx_RoomSublist:not(.mx_RoomSublist_hidden) .mx_RoomSublist_badgeContainer');
4 4
5 // Number of messages from People 5 // Number of messages from People
6 let direct_count = 0; 6 let directCount = 0;
7 if (badges.length > 0 && badges[0].children.length > 0) { 7 if (badges.length > 0) {
8 direct_count = parseInt(badges[0].textContent); 8 directCount = Ferdi.safeParseInt(badges[0].textContent);
9 } 9 }
10 10
11 // Number of messages from Rooms 11 // Number of messages from Rooms
12 let indirect_count = 0; 12 let indirectCount = 0;
13 if (badges.length > 1 && badges[1].children.length > 0) { 13 if (badges.length > 1) {
14 indirect_count = parseInt(badges[1].textContent); 14 indirectCount = Ferdi.safeParseInt(badges[1].textContent);
15 } 15 }
16 16
17 // set Ferdi badge 17 // set Ferdi badge
18 Ferdi.setBadge(direct_count, indirect_count); 18 Ferdi.setBadge(directCount, indirectCount);
19 } 19 }
20 20
21 Ferdi.loop(getMessages); 21 Ferdi.loop(getMessages);
diff --git a/recipes/erepublik/package.json b/recipes/erepublik/package.json
index 77781ee..c8efaab 100644
--- a/recipes/erepublik/package.json
+++ b/recipes/erepublik/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "erepublik", 2 "id": "erepublik",
3 "name": "eRepublik", 3 "name": "eRepublik",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://erepublik.com" 7 "serviceURL": "https://erepublik.com"
diff --git a/recipes/erepublik/webview.js b/recipes/erepublik/webview.js
index 3056d1b..7c24532 100644
--- a/recipes/erepublik/webview.js
+++ b/recipes/erepublik/webview.js
@@ -12,20 +12,13 @@ module.exports = Ferdi => {
12 12
13 for (let i = 0; i < elementNotify.length; i++) { 13 for (let i = 0; i < elementNotify.length; i++) {
14 const splitText = elementNotify[i].title.split(':'); 14 const splitText = elementNotify[i].title.split(':');
15 const badgeNumber = parseInt(splitText[1], 10); 15 countNotify += Ferdi.safeParseInt(splitText[1]);
16 if (badgeNumber) {
17 countNotify += badgeNumber;
18 }
19 } 16 }
20 17
21 for (let i = 0; i < elementFeed.length; i++) { 18 for (let i = 0; i < elementFeed.length; i++) {
22 const feedNumber = parseInt(elementFeed[i].textContent, 10); 19 countFeed += Ferdi.safeParseInt(elementFeed[i].textContent);
23 if (feedNumber) {
24 countFeed += feedNumber;
25 }
26 } 20 }
27 21
28 console.log(countNotify, countFeed);
29 Ferdi.setBadge(countNotify, countFeed); 22 Ferdi.setBadge(countNotify, countFeed);
30 }; 23 };
31 24
diff --git a/recipes/facebook/package.json b/recipes/facebook/package.json
index 3bd9eb2..2f5a54a 100755
--- a/recipes/facebook/package.json
+++ b/recipes/facebook/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "facebook", 2 "id": "facebook",
3 "name": "Facebook", 3 "name": "Facebook",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://www.facebook.com/login" 7 "serviceURL": "https://www.facebook.com/login"
diff --git a/recipes/facebook/webview.js b/recipes/facebook/webview.js
index f1e24f9..43de149 100755
--- a/recipes/facebook/webview.js
+++ b/recipes/facebook/webview.js
@@ -10,8 +10,8 @@ module.exports = (Ferdi) => {
10 ]; 10 ];
11 11
12 elements.forEach((element) => { 12 elements.forEach((element) => {
13 if (element !== null && parseInt(element.innerHTML, 10)) { 13 if (element !== null) {
14 count += parseInt(element.innerHTML, 10); 14 count += Ferdi.safeParseInt(element.innerHTML);
15 } 15 }
16 }); 16 });
17 17
diff --git a/recipes/facebookpages/package.json b/recipes/facebookpages/package.json
index 717876f..28f06ec 100644
--- a/recipes/facebookpages/package.json
+++ b/recipes/facebookpages/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "facebookpages", 2 "id": "facebookpages",
3 "name": "Facebook Pages", 3 "name": "Facebook Pages",
4 "version": "1.2.1", 4 "version": "1.2.2",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://facebook.com/{teamId}/", 7 "serviceURL": "https://facebook.com/{teamId}/",
diff --git a/recipes/facebookpages/webview.js b/recipes/facebookpages/webview.js
index 539b227..1cc75c6 100644
--- a/recipes/facebookpages/webview.js
+++ b/recipes/facebookpages/webview.js
@@ -4,7 +4,7 @@ module.exports = (Ferdi, options) => {
4 const element = document.querySelector('[data-testid="message_count"] span'); 4 const element = document.querySelector('[data-testid="message_count"] span');
5 5
6 if (element) { 6 if (element) {
7 messages = parseInt(element.textContent, 10); 7 messages = Ferdi.safeParseInt(element.textContent);
8 } 8 }
9 9
10 Ferdi.setBadge(messages); 10 Ferdi.setBadge(messages);
diff --git a/recipes/feedly/package.json b/recipes/feedly/package.json
index 4bb6d10..0ff3f70 100644
--- a/recipes/feedly/package.json
+++ b/recipes/feedly/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "feedly", 2 "id": "feedly",
3 "name": "Feedly", 3 "name": "Feedly",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://feedly.com" 7 "serviceURL": "https://feedly.com"
diff --git a/recipes/feedly/webview.js b/recipes/feedly/webview.js
index 4e5a5c8..09f4209 100644
--- a/recipes/feedly/webview.js
+++ b/recipes/feedly/webview.js
@@ -1,7 +1,7 @@
1module.exports = Ferdi => { 1module.exports = Ferdi => {
2 getMessages = () => { 2 getMessages = () => {
3 const newsDOM = document.querySelectorAll("div[title='All'] > .LeftnavListRow__count")[0].innerHTML; 3 const newsDOM = document.querySelectorAll("div[title='All'] > .LeftnavListRow__count")[0].innerHTML;
4 let counter = parseInt(newsDOM); 4 let counter = Ferdi.safeParseInt(newsDOM);
5 5
6 if (newsDOM.indexOf('K') !== -1 || newsDOM.indexOf('+') !== -1) { 6 if (newsDOM.indexOf('K') !== -1 || newsDOM.indexOf('+') !== -1) {
7 counter = `${newsDOM.substring(0, newsDOM.indexOf('K'))}000`; 7 counter = `${newsDOM.substring(0, newsDOM.indexOf('K'))}000`;
diff --git a/recipes/gadugadu/package.json b/recipes/gadugadu/package.json
index 5579a41..42600d7 100644
--- a/recipes/gadugadu/package.json
+++ b/recipes/gadugadu/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "gadugadu", 2 "id": "gadugadu",
3 "name": "Gadu-Gadu", 3 "name": "Gadu-Gadu",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://www.gg.pl", 7 "serviceURL": "https://www.gg.pl",
diff --git a/recipes/gadugadu/webview.js b/recipes/gadugadu/webview.js
index e1c7a2a..a3c1ee2 100644
--- a/recipes/gadugadu/webview.js
+++ b/recipes/gadugadu/webview.js
@@ -4,16 +4,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
4 4
5module.exports = Ferdi => { 5module.exports = Ferdi => {
6 const getMessages = () => { 6 const getMessages = () => {
7 const updates = parseInt(document.querySelector('i#sr-last-counter').textContent, 10); 7 const updates = Ferdi.safeParseInt(document.querySelector('i#sr-last-counter').textContent);
8 let messages = 0; 8 let messages = 0;
9 9 const elements = document.querySelectorAll('.chat-counter:not(.d-none)');
10 const conversations = document.querySelectorAll('.chat-counter:not(.d-none)').length; 10 for (let i = 0; i < elements.length; i++) {
11 if (conversations === 0) { 11 messages += Ferdi.safeParseInt(elements[i].textContent);
12 messages = 0;
13 } else {
14 for (let i = 0; i < conversations; i + 1) {
15 messages += parseInt(document.querySelectorAll('.chat-counter:not(.d-none)')[i].textContent, 10);
16 }
17 } 12 }
18 13
19 Ferdi.setBadge(messages, updates); 14 Ferdi.setBadge(messages, updates);
diff --git a/recipes/github/package.json b/recipes/github/package.json
index 4454c97..2ed611e 100644
--- a/recipes/github/package.json
+++ b/recipes/github/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "github", 2 "id": "github",
3 "name": "GitHub", 3 "name": "GitHub",
4 "version": "2.1.0", 4 "version": "2.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://github.com/notifications", 7 "serviceURL": "https://github.com/notifications",
diff --git a/recipes/github/webview.js b/recipes/github/webview.js
index 9f35b5e..fdc65a8 100644
--- a/recipes/github/webview.js
+++ b/recipes/github/webview.js
@@ -1,14 +1,17 @@
1module.exports = Ferdi => { 1module.exports = Ferdi => {
2 const getMessages = function getMessages() { 2 const getMessages = function getMessages() {
3 const directCountElement = document.querySelector('.filter-list .count'); 3 const directCountElement = document.querySelector('.filter-list .count');
4 const indirectCountElement = document.querySelector('[class*="mail-status unread"]'); 4 let directCount = 0;
5 let directCount;
6 let indirectCount;
7 if (directCountElement) { 5 if (directCountElement) {
8 directCount = parseInt(directCountElement.innerHTML, 10); 6 directCount = Ferdi.safeParseInt(directCountElement.innerHTML);
9 } else if (indirectCountElement) { 7 }
8
9 const indirectCountElement = document.querySelector('[class*="mail-status unread"]');
10 let indirectCount = 0;
11 if (indirectCountElement) {
10 indirectCount = 1; 12 indirectCount = 1;
11 } 13 }
14
12 Ferdi.setBadge(directCount, indirectCount); 15 Ferdi.setBadge(directCount, indirectCount);
13 }; 16 };
14 17
diff --git a/recipes/glowing-bear/package.json b/recipes/glowing-bear/package.json
index 250cb57..b586117 100644
--- a/recipes/glowing-bear/package.json
+++ b/recipes/glowing-bear/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "glowing-bear", 2 "id": "glowing-bear",
3 "name": "glowing-bear", 3 "name": "glowing-bear",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://www.glowing-bear.org", 7 "serviceURL": "https://www.glowing-bear.org",
diff --git a/recipes/glowing-bear/webview.js b/recipes/glowing-bear/webview.js
index d974836..0780357 100644
--- a/recipes/glowing-bear/webview.js
+++ b/recipes/glowing-bear/webview.js
@@ -4,9 +4,11 @@ module.exports = Ferdi => {
4 const direct = document.querySelectorAll('.badge.danger').length - 1; 4 const direct = document.querySelectorAll('.badge.danger').length - 1;
5 let indirect = -1; 5 let indirect = -1;
6 for (let i = 0; i < indirectElements.length; i += 1) { 6 for (let i = 0; i < indirectElements.length; i += 1) {
7 if (indirectElements[i].innerHTML.length > 0) indirect++; 7 if (indirectElements[i].innerHTML.length > 0) {
8 indirect++;
9 }
8 } 10 }
9 Ferdi.setBadge(Math.max(direct, 0), Math.max(indirect, 0)); 11 Ferdi.setBadge(direct, indirect);
10 }; 12 };
11 13
12 Ferdi.loop(getMessages); 14 Ferdi.loop(getMessages);
diff --git a/recipes/gmail/package.json b/recipes/gmail/package.json
index 49fc89f..97029b4 100644
--- a/recipes/gmail/package.json
+++ b/recipes/gmail/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "gmail", 2 "id": "gmail",
3 "name": "Gmail", 3 "name": "Gmail",
4 "version": "1.4.0", 4 "version": "1.4.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://mail.google.com" 7 "serviceURL": "https://mail.google.com"
diff --git a/recipes/gmail/webview.js b/recipes/gmail/webview.js
index 9a09c87..8c78bb6 100644
--- a/recipes/gmail/webview.js
+++ b/recipes/gmail/webview.js
@@ -13,10 +13,9 @@ module.exports = (Ferdi) => {
13 13
14 const inboxLinks = document.getElementsByClassName('J-Ke n0'); 14 const inboxLinks = document.getElementsByClassName('J-Ke n0');
15 if (inboxLinks.length > 0) { 15 if (inboxLinks.length > 0) {
16 const inboxLink = inboxLinks[0]; 16 const unreadCounts = inboxLinks[0].parentNode.parentNode.getElementsByClassName('bsU');
17 const unreadCounts = inboxLink.parentNode.parentNode.getElementsByClassName('bsU');
18 if (unreadCounts.length > 0) { 17 if (unreadCounts.length > 0) {
19 count = parseInt(unreadCounts[0].innerHTML.trim(), 10); 18 count = Ferdi.safeParseInt(unreadCounts[0].innerHTML);
20 } 19 }
21 } 20 }
22 21
diff --git a/recipes/google-voice/package.json b/recipes/google-voice/package.json
index 84eac14..20661e3 100644
--- a/recipes/google-voice/package.json
+++ b/recipes/google-voice/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "google-voice", 2 "id": "google-voice",
3 "name": "google-voice", 3 "name": "google-voice",
4 "version": "0.4.0", 4 "version": "0.4.1",
5 "license": "MIT", 5 "license": "MIT",
6 "repository": "https://github.com/BehindTheMath/franz-recipe-google-voice", 6 "repository": "https://github.com/BehindTheMath/franz-recipe-google-voice",
7 "config": { 7 "config": {
diff --git a/recipes/google-voice/webview.js b/recipes/google-voice/webview.js
index 7d9602c..53d34a1 100644
--- a/recipes/google-voice/webview.js
+++ b/recipes/google-voice/webview.js
@@ -1,7 +1,7 @@
1module.exports = Ferdi => { 1module.exports = Ferdi => {
2 function parseQuery(query) { 2 function parseQuery(query) {
3 const el = document.querySelector(query); 3 const el = document.querySelector(query);
4 return el && parseInt(el.innerHTML) || 0; 4 return el && Ferdi.safeParseInt(el.innerHTML);
5 } 5 }
6 6
7 function getMessages() { 7 function getMessages() {
@@ -9,7 +9,7 @@ module.exports = Ferdi => {
9 let count; 9 let count;
10 10
11 if (el) { 11 if (el) {
12 count = parseInt(el.innerHTML.replace(/[\(\) ]/gi, '')) || 0; 12 count = Ferdi.safeParseInt(el.innerHTML.replace(/[\(\) ]/gi, ''));
13 } else { 13 } else {
14 const count_messages = parseQuery('gv-nav-tab[tooltip="Messages"] div[aria-label="Unread count"]'); 14 const count_messages = parseQuery('gv-nav-tab[tooltip="Messages"] div[aria-label="Unread count"]');
15 const count_calls = parseQuery('gv-nav-tab[tooltip="Calls"] div[aria-label="Unread count"]'); 15 const count_calls = parseQuery('gv-nav-tab[tooltip="Calls"] div[aria-label="Unread count"]');
diff --git a/recipes/googleclassroom/package.json b/recipes/googleclassroom/package.json
index de9c318..84c7e24 100644
--- a/recipes/googleclassroom/package.json
+++ b/recipes/googleclassroom/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "googleclassroom", 2 "id": "googleclassroom",
3 "name": "Google Classroom", 3 "name": "Google Classroom",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "repository": "https://github.com/TanZng/ferdi-googleclassroom", 6 "repository": "https://github.com/TanZng/ferdi-googleclassroom",
7 "config": { 7 "config": {
diff --git a/recipes/googleclassroom/webview.js b/recipes/googleclassroom/webview.js
index 6431df8..c634b35 100644
--- a/recipes/googleclassroom/webview.js
+++ b/recipes/googleclassroom/webview.js
@@ -8,7 +8,7 @@ module.exports = Ferdi => {
8 homework += upcomingAssignment[i].childElementCount; 8 homework += upcomingAssignment[i].childElementCount;
9 } 9 }
10 } 10 }
11 Ferdi.setBadge(parseInt(homework, 10)); 11 Ferdi.setBadge(homework);
12 }; 12 };
13 13
14 Ferdi.loop(getMessages); 14 Ferdi.loop(getMessages);
diff --git a/recipes/guilded/package.json b/recipes/guilded/package.json
index 7366a6e..7cef02e 100644
--- a/recipes/guilded/package.json
+++ b/recipes/guilded/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "guilded", 2 "id": "guilded",
3 "name": "Guilded", 3 "name": "Guilded",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://www.guilded.gg/", 7 "serviceURL": "https://www.guilded.gg/",
diff --git a/recipes/guilded/webview.js b/recipes/guilded/webview.js
index ccace71..5d56d39 100644
--- a/recipes/guilded/webview.js
+++ b/recipes/guilded/webview.js
@@ -6,7 +6,7 @@ module.exports = Ferdi => {
6 const innerBadge = notificationBadge.getElementsByClassName('BadgeV2-count')[0]; 6 const innerBadge = notificationBadge.getElementsByClassName('BadgeV2-count')[0];
7 unread = innerBadge.innerText; 7 unread = innerBadge.innerText;
8 } 8 }
9 Ferdi.setBadge(parseInt(unread, 10)); 9 Ferdi.setBadge(unread);
10 }; 10 };
11 11
12 Ferdi.loop(getMessages); 12 Ferdi.loop(getMessages);
diff --git a/recipes/icq/package.json b/recipes/icq/package.json
index 1ce61eb..35de4bb 100644
--- a/recipes/icq/package.json
+++ b/recipes/icq/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "icq", 2 "id": "icq",
3 "name": "ICQ", 3 "name": "ICQ",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "repository": "https://github.com/meetfranz/recipe-icq", 6 "repository": "https://github.com/meetfranz/recipe-icq",
7 "config": { 7 "config": {
diff --git a/recipes/icq/webview.js b/recipes/icq/webview.js
index 24271d8..653dc69 100644
--- a/recipes/icq/webview.js
+++ b/recipes/icq/webview.js
@@ -1,15 +1,10 @@
1module.exports = Ferdi => { 1module.exports = Ferdi => {
2 const getMessages = function getMessages() { 2 const getMessages = function getMessages() {
3 let directs = 0; 3 let directs = 0;
4 4 const elements = document.getElementsByClassName('nwa-msg-counter icq-recent_state-read');
5 if (document.getElementsByClassName('nwa-msg-counter icq-recent_state-read').length > 0) { 5 for (let i = 0; i < elements.length; i++) {
6 const elements = document.getElementsByClassName('nwa-msg-counter icq-recent_state-read'); 6 if (Ferdi.safeParseInt(elements[i].innerText.replace(/[^0-9.]/g, '')) > 0) {
7 for (let i = 0; i < elements.length; i++) { 7 directs += 1; // count 1 per channel with messages
8 const countLine = parseInt(elements[i].innerText.replace(/[^0-9.]/g, ''), 10);
9 if (!isNaN(directs) && countLine > 0) {
10 // directs += count_line; // count every message
11 directs += 1; // count 1 per channel with messages
12 }
13 } 8 }
14 } 9 }
15 10
diff --git a/recipes/instagram/package.json b/recipes/instagram/package.json
index 80391bc..8396da4 100644
--- a/recipes/instagram/package.json
+++ b/recipes/instagram/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "instagram", 2 "id": "instagram",
3 "name": "Instagram", 3 "name": "Instagram",
4 "version": "2.2.0", 4 "version": "2.2.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://instagram.com/direct/inbox", 7 "serviceURL": "https://instagram.com/direct/inbox",
diff --git a/recipes/instagram/webview.js b/recipes/instagram/webview.js
index b6d9aa3..8db5852 100644
--- a/recipes/instagram/webview.js
+++ b/recipes/instagram/webview.js
@@ -5,7 +5,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
5module.exports = (Ferdi) => { 5module.exports = (Ferdi) => {
6 const getMessages = function getMessages() { 6 const getMessages = function getMessages() {
7 const element = document.querySelector('a[href^="/direct/inbox"]'); 7 const element = document.querySelector('a[href^="/direct/inbox"]');
8 Ferdi.setBadge(element ? parseInt(element.innerText, 10) : 0); 8 Ferdi.setBadge(element ? Ferdi.safeParseInt(element.innerText) : 0);
9 }; 9 };
10 10
11 Ferdi.loop(getMessages); 11 Ferdi.loop(getMessages);
diff --git a/recipes/intercom/package.json b/recipes/intercom/package.json
index fbe3871..e599308 100644
--- a/recipes/intercom/package.json
+++ b/recipes/intercom/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "intercom", 2 "id": "intercom",
3 "name": "Intercom", 3 "name": "Intercom",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://app.intercom.io/", 7 "serviceURL": "https://app.intercom.io/",
diff --git a/recipes/intercom/webview.js b/recipes/intercom/webview.js
index 18445d8..a29db21 100644
--- a/recipes/intercom/webview.js
+++ b/recipes/intercom/webview.js
@@ -1,7 +1,7 @@
1module.exports = (Ferdi) => { 1module.exports = (Ferdi) => {
2 function getMessages() { 2 function getMessages() {
3 const numMessages = parseInt(document.querySelector('.left-nav [data-content="Inbox"] .unread__container .unread').innerHTML.trim()); 3 const numMessages = Ferdi.safeParseInt(document.querySelector('.left-nav [data-content="Inbox"] .unread__container .unread').innerHTML);
4 Ferdi.setBadge(numMessages >= 0 ? numMessages : 0, 0); 4 Ferdi.setBadge(numMessages);
5 } 5 }
6 6
7 Ferdi.loop(getMessages); 7 Ferdi.loop(getMessages);
diff --git a/recipes/jira/package.json b/recipes/jira/package.json
index 09ace99..23d77a1 100644
--- a/recipes/jira/package.json
+++ b/recipes/jira/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "jira", 2 "id": "jira",
3 "name": "Jira", 3 "name": "Jira",
4 "version": "1.3.0", 4 "version": "1.3.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://{teamId}.atlassian.net", 7 "serviceURL": "https://{teamId}.atlassian.net",
diff --git a/recipes/jira/webview.js b/recipes/jira/webview.js
index f52235d..d39f91e 100644
--- a/recipes/jira/webview.js
+++ b/recipes/jira/webview.js
@@ -2,10 +2,7 @@ module.exports = (Ferdi) => {
2 const getMessages = function getMessages() { 2 const getMessages = function getMessages() {
3 // get unread messages 3 // get unread messages
4 const element = document.querySelector('#atlassian-navigation-notification-count span'); 4 const element = document.querySelector('#atlassian-navigation-notification-count span');
5 let count = element ? element.innerText : 0; 5 Ferdi.setBadge(element ? element.innerText : 0);
6 count = parseInt(count, 10);
7
8 Ferdi.setBadge(count);
9 }; 6 };
10 7
11 Ferdi.loop(getMessages); 8 Ferdi.loop(getMessages);
diff --git a/recipes/lark/package.json b/recipes/lark/package.json
index 81c2a37..a1144e3 100644
--- a/recipes/lark/package.json
+++ b/recipes/lark/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "lark", 2 "id": "lark",
3 "name": "Lark", 3 "name": "Lark",
4 "version": "0.1.0", 4 "version": "0.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://{teamId}.larksuite.com/messenger/", 7 "serviceURL": "https://{teamId}.larksuite.com/messenger/",
diff --git a/recipes/lark/webview.js b/recipes/lark/webview.js
index 5e32219..33d0fc9 100644
--- a/recipes/lark/webview.js
+++ b/recipes/lark/webview.js
@@ -9,8 +9,7 @@ module.exports = (Ferdi) => {
9 Ferdi.setBadge(0); 9 Ferdi.setBadge(0);
10 return; 10 return;
11 } 11 }
12 const messages = parseInt(ele[0].innerHTML, 10); 12 Ferdi.setBadge(ele[0].innerHTML);
13 Ferdi.setBadge(messages);
14 }; 13 };
15 14
16 Ferdi.loop(getMessages); 15 Ferdi.loop(getMessages);
diff --git a/recipes/linkedin/package.json b/recipes/linkedin/package.json
index e595182..2c9bdd2 100644
--- a/recipes/linkedin/package.json
+++ b/recipes/linkedin/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "linkedin", 2 "id": "linkedin",
3 "name": "LinkedIn", 3 "name": "LinkedIn",
4 "version": "1.2.0", 4 "version": "1.2.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://www.linkedin.com/messaging" 7 "serviceURL": "https://www.linkedin.com/messaging"
diff --git a/recipes/linkedin/webview.js b/recipes/linkedin/webview.js
index f109b0d..1017d26 100644
--- a/recipes/linkedin/webview.js
+++ b/recipes/linkedin/webview.js
@@ -6,9 +6,8 @@ module.exports = Ferdi => {
6 count = document.querySelectorAll('.msg-conversation-card__unread-count').length; 6 count = document.querySelectorAll('.msg-conversation-card__unread-count').length;
7 } else { 7 } else {
8 const element = document.querySelector('.nav-item--messaging .nav-item__badge-count'); 8 const element = document.querySelector('.nav-item--messaging .nav-item__badge-count');
9
10 if (element) { 9 if (element) {
11 count = parseInt(element.innerHTML, 10); 10 count = Ferdi.safeParseInt(element.innerHTML);
12 } 11 }
13 } 12 }
14 13
diff --git a/recipes/messenger/package.json b/recipes/messenger/package.json
index ba84ed5..6165ed1 100644
--- a/recipes/messenger/package.json
+++ b/recipes/messenger/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "messenger", 2 "id": "messenger",
3 "name": "Messenger", 3 "name": "Messenger",
4 "version": "1.3.0", 4 "version": "1.3.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://messenger.com", 7 "serviceURL": "https://messenger.com",
diff --git a/recipes/messenger/webview.js b/recipes/messenger/webview.js
index 098c6f5..c147df8 100644
--- a/recipes/messenger/webview.js
+++ b/recipes/messenger/webview.js
@@ -9,7 +9,7 @@ module.exports = Ferdi => {
9 * see https://github.com/getferdi/ferdi/issues/1113#issuecomment-783409154 9 * see https://github.com/getferdi/ferdi/issues/1113#issuecomment-783409154
10 */ 10 */
11 if (isNotification) { 11 if (isNotification) {
12 count = parseInt(/^\((\d+)\)/.exec(document.title)[1]); 12 count = Ferdi.safeParseInt(/^\((\d+)\)/.exec(document.title)[1]);
13 } else { 13 } else {
14 /* 14 /*
15 * Notification case for direct messages, workaround by manavortex 15 * Notification case for direct messages, workaround by manavortex
@@ -28,7 +28,7 @@ module.exports = Ferdi => {
28 */ 28 */
29 const messageRequestsElement = document.querySelector('._5nxf'); 29 const messageRequestsElement = document.querySelector('._5nxf');
30 if (messageRequestsElement) { 30 if (messageRequestsElement) {
31 count += parseInt(messageRequestsElement.innerHTML, 10); 31 count += Ferdi.safeParseInt(messageRequestsElement.innerHTML);
32 } 32 }
33 33
34 Ferdi.setBadge(count); 34 Ferdi.setBadge(count);
diff --git a/recipes/monday/package.json b/recipes/monday/package.json
index 35556a8..5b6af2f 100644
--- a/recipes/monday/package.json
+++ b/recipes/monday/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "monday", 2 "id": "monday",
3 "name": "Monday", 3 "name": "Monday",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://{teamId}.monday.com", 7 "serviceURL": "https://{teamId}.monday.com",
diff --git a/recipes/monday/webview.js b/recipes/monday/webview.js
index bdd73ca..924c071 100755
--- a/recipes/monday/webview.js
+++ b/recipes/monday/webview.js
@@ -9,7 +9,7 @@ module.exports = Ferdi => {
9 const counters = document.querySelectorAll('.surface-control-component .item-counter, .surface-control-component .view-item-counter'); 9 const counters = document.querySelectorAll('.surface-control-component .item-counter, .surface-control-component .view-item-counter');
10 10
11 for (let i = 0; i < counters.length; i++) { 11 for (let i = 0; i < counters.length; i++) {
12 count += parseInt(counters[i].textContent); 12 count += Ferdi.safeParseInt(counters[i].textContent);
13 } 13 }
14 14
15 Ferdi.setBadge(count); 15 Ferdi.setBadge(count);
diff --git a/recipes/msteams/package.json b/recipes/msteams/package.json
index 9ccc53a..c79276f 100644
--- a/recipes/msteams/package.json
+++ b/recipes/msteams/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "msteams", 2 "id": "msteams",
3 "name": "Microsoft Teams", 3 "name": "Microsoft Teams",
4 "version": "3.1.0", 4 "version": "3.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "aliases": [ 6 "aliases": [
7 "teamsChat" 7 "teamsChat"
diff --git a/recipes/msteams/webview.js b/recipes/msteams/webview.js
index 8e971ec..bf25562 100644
--- a/recipes/msteams/webview.js
+++ b/recipes/msteams/webview.js
@@ -7,10 +7,7 @@ module.exports = Ferdi => {
7 let messages = 0; 7 let messages = 0;
8 const badge = document.querySelector('.activity-badge.dot-activity-badge .activity-badge'); 8 const badge = document.querySelector('.activity-badge.dot-activity-badge .activity-badge');
9 if (badge) { 9 if (badge) {
10 const value = parseInt(badge.innerHTML, 10); 10 messages = Ferdi.safeParseInt(badge.innerHTML);
11 if (!isNaN(value)) {
12 messages = value;
13 }
14 } 11 }
15 12
16 const indirectMessages = document.querySelectorAll('[class*=channel-anchor][class*=ts-unread-channel]').length; 13 const indirectMessages = document.querySelectorAll('[class*=channel-anchor][class*=ts-unread-channel]').length;
diff --git a/recipes/mysms/package.json b/recipes/mysms/package.json
index 29cff0b..9030285 100644
--- a/recipes/mysms/package.json
+++ b/recipes/mysms/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "mysms", 2 "id": "mysms",
3 "name": "MySMS", 3 "name": "MySMS",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://app.mysms.com" 7 "serviceURL": "https://app.mysms.com"
diff --git a/recipes/mysms/webview.js b/recipes/mysms/webview.js
index f8660ee..a0b4ea6 100644
--- a/recipes/mysms/webview.js
+++ b/recipes/mysms/webview.js
@@ -4,8 +4,7 @@ module.exports = Ferdi => {
4 4
5 let count = 0; 5 let count = 0;
6 for (let i = 0; i < elements.length; i++) { 6 for (let i = 0; i < elements.length; i++) {
7 const count_line = parseInt(elements[i].innerText.replace(/[^0-9.]/g, '')); 7 if (Ferdi.safeParseInt(elements[i].innerText.replace(/[^0-9.]/g, '')) > 0) {
8 if (count_line > 0) {
9 count++; // count 1 per channel with messages 8 count++; // count 1 per channel with messages
10 } 9 }
11 } 10 }
diff --git a/recipes/nextdoor/package.json b/recipes/nextdoor/package.json
index 1e5c75a..2b40f9d 100644
--- a/recipes/nextdoor/package.json
+++ b/recipes/nextdoor/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "nextdoor", 2 "id": "nextdoor",
3 "name": "Nextdoor", 3 "name": "Nextdoor",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://nextdoor.co.uk/inbox/" 7 "serviceURL": "https://nextdoor.co.uk/inbox/"
diff --git a/recipes/nextdoor/webview.js b/recipes/nextdoor/webview.js
index 0ea8f57..fbac111 100644
--- a/recipes/nextdoor/webview.js
+++ b/recipes/nextdoor/webview.js
@@ -5,7 +5,7 @@ module.exports = Ferdi => {
5 if (notificationBadge != undefined) { 5 if (notificationBadge != undefined) {
6 unread = notificationBadge.innerText; 6 unread = notificationBadge.innerText;
7 } 7 }
8 Ferdi.setBadge(parseInt(unread, 10)); 8 Ferdi.setBadge(unread);
9 }; 9 };
10 10
11 Ferdi.loop(getMessages); 11 Ferdi.loop(getMessages);
diff --git a/recipes/notion/package.json b/recipes/notion/package.json
index d5d504c..1cefed4 100644
--- a/recipes/notion/package.json
+++ b/recipes/notion/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "notion", 2 "id": "notion",
3 "name": "Notion", 3 "name": "Notion",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "repository": "https://github.com/TanZng/ferdi-notion", 6 "repository": "https://github.com/TanZng/ferdi-notion",
7 "config": { 7 "config": {
diff --git a/recipes/notion/webview.js b/recipes/notion/webview.js
index 8ef9ff2..aa8eaec 100644
--- a/recipes/notion/webview.js
+++ b/recipes/notion/webview.js
@@ -1,13 +1,12 @@
1module.exports = (Ferdi) => { 1module.exports = (Ferdi) => {
2 function getMessages() { 2 function getMessages() {
3 let direct = 0; 3 let direct = 0;
4 const indirect = 0;
5 const badgeDiv = document.querySelector('.notion-sidebar-container > div > div > div > :nth-child(4) > :nth-child(2) > div > :nth-child(3) > div > div'); 4 const badgeDiv = document.querySelector('.notion-sidebar-container > div > div > div > :nth-child(4) > :nth-child(2) > div > :nth-child(3) > div > div');
6 if (badgeDiv) { 5 if (badgeDiv) {
7 direct = parseInt(badgeDiv.innerText); 6 direct = Ferdi.safeParseInt(badgeDiv.innerText);
8 } 7 }
9 8
10 Ferdi.setBadge(direct, indirect); 9 Ferdi.setBadge(direct);
11 } 10 }
12 11
13 Ferdi.loop(getMessages); 12 Ferdi.loop(getMessages);
diff --git a/recipes/office365-owa/package.json b/recipes/office365-owa/package.json
index e4dce4c..0bd1afd 100644
--- a/recipes/office365-owa/package.json
+++ b/recipes/office365-owa/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "office365-owa", 2 "id": "office365-owa",
3 "name": "Office 365 Outlook", 3 "name": "Office 365 Outlook",
4 "version": "1.4.1", 4 "version": "1.4.2",
5 "license": "MIT", 5 "license": "MIT",
6 "aliases": [ 6 "aliases": [
7 "live.com" 7 "live.com"
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 }
diff --git a/recipes/pivotal-tracker/package.json b/recipes/pivotal-tracker/package.json
index 0cc6134..b9164e1 100644
--- a/recipes/pivotal-tracker/package.json
+++ b/recipes/pivotal-tracker/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "pivotal-tracker", 2 "id": "pivotal-tracker",
3 "name": "pivotal-tracker", 3 "name": "pivotal-tracker",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://www.pivotaltracker.com/signin", 7 "serviceURL": "https://www.pivotaltracker.com/signin",
diff --git a/recipes/pivotal-tracker/webview.js b/recipes/pivotal-tracker/webview.js
index ef1c8f1..cfc2ae4 100644
--- a/recipes/pivotal-tracker/webview.js
+++ b/recipes/pivotal-tracker/webview.js
@@ -1,8 +1,9 @@
1module.exports = (Ferdi) => { 1module.exports = (Ferdi) => {
2 function getMessages() { 2 function getMessages() {
3 const bell = document.querySelectorAll('#view65 > span')[0]; 3 const bell = document.querySelectorAll('#view65 > span')[0];
4 counter = parseInt(bell.innerText); 4 if (bell) {
5 Ferdi.setBadge(counter); 5 Ferdi.setBadge(bell.innerText);
6 }
6 } 7 }
7 8
8 Ferdi.loop(getMessages); 9 Ferdi.loop(getMessages);
diff --git a/recipes/pleroma/package.json b/recipes/pleroma/package.json
index 3993249..5a4fdf9 100644
--- a/recipes/pleroma/package.json
+++ b/recipes/pleroma/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "pleroma", 2 "id": "pleroma",
3 "name": "Pleroma", 3 "name": "Pleroma",
4 "version": "1.1.1", 4 "version": "1.1.2",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "hasCustomUrl": true 7 "hasCustomUrl": true
diff --git a/recipes/pleroma/webview.js b/recipes/pleroma/webview.js
index 07f2dc0..2c97ab3 100644
--- a/recipes/pleroma/webview.js
+++ b/recipes/pleroma/webview.js
@@ -143,9 +143,9 @@ module.exports = Ferdi => {
143 let directCount = 0; 143 let directCount = 0;
144 const matchArr = document.title.match(titleRegex); 144 const matchArr = document.title.match(titleRegex);
145 if (matchArr) { 145 if (matchArr) {
146 directCount = parseInt(matchArr[1], 10); 146 directCount = Ferdi.safeParseInt(matchArr[1]);
147 } 147 }
148 Ferdi.setBadge(directCount, 0); 148 Ferdi.setBadge(directCount);
149 }; 149 };
150 150
151 getInstanceLogo().then(({ logo, logoMask }) => { 151 getInstanceLogo().then(({ logo, logoMask }) => {
diff --git a/recipes/plurk/package.json b/recipes/plurk/package.json
index 717c64e..6167c53 100644
--- a/recipes/plurk/package.json
+++ b/recipes/plurk/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "plurk", 2 "id": "plurk",
3 "name": "Plurk", 3 "name": "Plurk",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://www.plurk.com" 7 "serviceURL": "https://www.plurk.com"
diff --git a/recipes/plurk/webview.js b/recipes/plurk/webview.js
index 6f20458..0136c24 100644
--- a/recipes/plurk/webview.js
+++ b/recipes/plurk/webview.js
@@ -5,8 +5,11 @@ module.exports = Ferdi => {
5 const np = document.querySelector('#noti_np_count'); 5 const np = document.querySelector('#noti_np_count');
6 const re = document.querySelector('#noti_re_count'); 6 const re = document.querySelector('#noti_re_count');
7 7
8 if (np || re) { 8 if (np) {
9 direct = parseInt(np.innerHTML) + parseInt(re.innerHTML); 9 direct += Ferdi.safeParseInt(np.innerHTML);
10 }
11 if (re) {
12 direct += Ferdi.safeParseInt(re.innerHTML);
10 } 13 }
11 14
12 Ferdi.setBadge(direct); 15 Ferdi.setBadge(direct);
diff --git a/recipes/protonet/package.json b/recipes/protonet/package.json
index bc4554d..80923de 100755
--- a/recipes/protonet/package.json
+++ b/recipes/protonet/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "protonet", 2 "id": "protonet",
3 "name": "protonet", 3 "name": "protonet",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://{teamID}.protonet.info", 7 "serviceURL": "https://{teamID}.protonet.info",
diff --git a/recipes/protonet/webview.js b/recipes/protonet/webview.js
index 9ada45a..497ee8c 100755
--- a/recipes/protonet/webview.js
+++ b/recipes/protonet/webview.js
@@ -1,7 +1,7 @@
1module.exports = (Ferdi) => { 1module.exports = (Ferdi) => {
2 const getMessages = () => { 2 const getMessages = () => {
3 const unreadPrivateMessages = parseInt($('.messages .unread-meeps').text()); 3 const unreadPrivateMessages = Ferdi.safeParseInt($('.messages .unread-meeps').text());
4 const unreadGroupMessages = parseInt($('.today .unread-meeps').text()); 4 const unreadGroupMessages = Ferdi.safeParseInt($('.today .unread-meeps').text());
5 5
6 Ferdi.setBadge(unreadPrivateMessages + unreadGroupMessages); 6 Ferdi.setBadge(unreadPrivateMessages + unreadGroupMessages);
7 }; 7 };
diff --git a/recipes/rainloop/package.json b/recipes/rainloop/package.json
index fad246a..04b6674 100644
--- a/recipes/rainloop/package.json
+++ b/recipes/rainloop/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "rainloop", 2 "id": "rainloop",
3 "name": "RainLoop", 3 "name": "RainLoop",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "repository": "https://github.com/promarcel/franz-recipe-rainloop", 5 "repository": "https://github.com/promarcel/franz-recipe-rainloop",
6 "license": "MIT", 6 "license": "MIT",
7 "config": { 7 "config": {
diff --git a/recipes/rainloop/webview.js b/recipes/rainloop/webview.js
index e5052b8..346e51f 100644
--- a/recipes/rainloop/webview.js
+++ b/recipes/rainloop/webview.js
@@ -9,10 +9,10 @@ module.exports = Ferdi => {
9 if (typeof countText === 'string' && countText !== '') { 9 if (typeof countText === 'string' && countText !== '') {
10 if ($(obj).hasClass('system')) { 10 if ($(obj).hasClass('system')) {
11 if ($(obj).hasClass('i-am-inbox')) { 11 if ($(obj).hasClass('i-am-inbox')) {
12 inbox += parseInt(countText); 12 inbox += Ferdi.safeParseInt(countText);
13 } 13 }
14 } else { 14 } else {
15 updates += parseInt(countText); 15 updates += Ferdi.safeParseInt(countText);
16 } 16 }
17 } 17 }
18 }); 18 });
diff --git a/recipes/reddit/package.json b/recipes/reddit/package.json
index 7dd62e2..b1e9399 100644
--- a/recipes/reddit/package.json
+++ b/recipes/reddit/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "reddit", 2 "id": "reddit",
3 "name": "Reddit", 3 "name": "Reddit",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "repository": "https://github.com/getferdi/recipes", 6 "repository": "https://github.com/getferdi/recipes",
7 "config": { 7 "config": {
diff --git a/recipes/reddit/webview.js b/recipes/reddit/webview.js
index dc83d3d..ad2c83e 100644
--- a/recipes/reddit/webview.js
+++ b/recipes/reddit/webview.js
@@ -8,10 +8,9 @@ module.exports = (Ferdi) => {
8 let count = 0; 8 let count = 0;
9 9
10 if (elements[0]) { 10 if (elements[0]) {
11 count = parseInt(elements[0].innerHTML, 10); 11 count = Ferdi.safeParseInt(elements[0].innerHTML);
12 } 12 }
13 13
14 console.log(count);
15 Ferdi.setBadge(count); 14 Ferdi.setBadge(count);
16 }; 15 };
17 16
diff --git a/recipes/riseup/package.json b/recipes/riseup/package.json
index 73f3234..82689aa 100644
--- a/recipes/riseup/package.json
+++ b/recipes/riseup/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "riseup", 2 "id": "riseup",
3 "name": "Riseup.net", 3 "name": "Riseup.net",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://mail.riseup.net" 7 "serviceURL": "https://mail.riseup.net"
diff --git a/recipes/riseup/webview.js b/recipes/riseup/webview.js
index 2a5f91f..7cbb736 100644
--- a/recipes/riseup/webview.js
+++ b/recipes/riseup/webview.js
@@ -5,7 +5,7 @@ module.exports = Ferdi => {
5 if (notificationBadge != undefined) { 5 if (notificationBadge != undefined) {
6 unread = notificationBadge.innerText; 6 unread = notificationBadge.innerText;
7 } 7 }
8 Ferdi.setBadge(parseInt(unread, 10)); 8 Ferdi.setBadge(unread);
9 }; 9 };
10 10
11 Ferdi.loop(getMessages); 11 Ferdi.loop(getMessages);
diff --git a/recipes/rocketchat/package.json b/recipes/rocketchat/package.json
index f4dedcf..111efbd 100644
--- a/recipes/rocketchat/package.json
+++ b/recipes/rocketchat/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "rocketchat", 2 "id": "rocketchat",
3 "name": "Rocket.Chat", 3 "name": "Rocket.Chat",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://{teamId}.rocket.chat", 7 "serviceURL": "https://{teamId}.rocket.chat",
diff --git a/recipes/rocketchat/webview.js b/recipes/rocketchat/webview.js
index 1702c74..d3d0a27 100644
--- a/recipes/rocketchat/webview.js
+++ b/recipes/rocketchat/webview.js
@@ -41,7 +41,7 @@ module.exports = Ferdi => {
41 let directMessagesCount = 0; 41 let directMessagesCount = 0;
42 42
43 for (const directMessage of directMessages) { 43 for (const directMessage of directMessages) {
44 directMessagesCount += parseInt(directMessage.textContent, 10); 44 directMessagesCount += Ferdi.safeParseInt(directMessage.textContent);
45 } 45 }
46 46
47 const indirectMessagesCount = Math.round( 47 const indirectMessagesCount = Math.round(
diff --git a/recipes/roundcube/package.json b/recipes/roundcube/package.json
index 2bd8dba..d36a816 100644
--- a/recipes/roundcube/package.json
+++ b/recipes/roundcube/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "roundcube", 2 "id": "roundcube",
3 "name": "Roundcube", 3 "name": "Roundcube",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "repository": "https://github.com/jonathanjuursema/franz-roundcube", 5 "repository": "https://github.com/jonathanjuursema/franz-roundcube",
6 "license": "MIT", 6 "license": "MIT",
7 "config": { 7 "config": {
diff --git a/recipes/roundcube/webview.js b/recipes/roundcube/webview.js
index 8a2ffef..ce9872a 100644
--- a/recipes/roundcube/webview.js
+++ b/recipes/roundcube/webview.js
@@ -3,8 +3,7 @@ module.exports = Ferdi => {
3 const directElements = document.querySelectorAll('.unreadcount'); 3 const directElements = document.querySelectorAll('.unreadcount');
4 let direct = 0; 4 let direct = 0;
5 for (let i = 0; i < directElements.length; i += 1) { 5 for (let i = 0; i < directElements.length; i += 1) {
6 const n = parseInt(directElements[i].innerHTML); 6 direct += Ferdi.safeParseInt(directElements[i].innerHTML);
7 direct += isNaN(n) ? 0 : n;
8 } 7 }
9 Ferdi.setBadge(direct); 8 Ferdi.setBadge(direct);
10 }; 9 };
diff --git a/recipes/simplenote/package.json b/recipes/simplenote/package.json
index cb07e51..a4867b9 100644
--- a/recipes/simplenote/package.json
+++ b/recipes/simplenote/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "simplenote", 2 "id": "simplenote",
3 "name": "Simplenote", 3 "name": "Simplenote",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://app.simplenote.com/" 7 "serviceURL": "https://app.simplenote.com/"
diff --git a/recipes/simplenote/webview.js b/recipes/simplenote/webview.js
index f109b0d..1017d26 100644
--- a/recipes/simplenote/webview.js
+++ b/recipes/simplenote/webview.js
@@ -6,9 +6,8 @@ module.exports = Ferdi => {
6 count = document.querySelectorAll('.msg-conversation-card__unread-count').length; 6 count = document.querySelectorAll('.msg-conversation-card__unread-count').length;
7 } else { 7 } else {
8 const element = document.querySelector('.nav-item--messaging .nav-item__badge-count'); 8 const element = document.querySelector('.nav-item--messaging .nav-item__badge-count');
9
10 if (element) { 9 if (element) {
11 count = parseInt(element.innerHTML, 10); 10 count = Ferdi.safeParseInt(element.innerHTML);
12 } 11 }
13 } 12 }
14 13
diff --git a/recipes/skype/package.json b/recipes/skype/package.json
index 57f4d87..342621c 100644
--- a/recipes/skype/package.json
+++ b/recipes/skype/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "skype", 2 "id": "skype",
3 "name": "Skype", 3 "name": "Skype",
4 "version": "3.1.0", 4 "version": "3.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://web.skype.com/", 7 "serviceURL": "https://web.skype.com/",
diff --git a/recipes/skype/webview.js b/recipes/skype/webview.js
index 9af7c2b..6e84d78 100644
--- a/recipes/skype/webview.js
+++ b/recipes/skype/webview.js
@@ -17,7 +17,9 @@ module.exports = (Ferdi, settings) => {
17 17
18 if (elementContainer) { 18 if (elementContainer) {
19 const element = elementContainer.querySelector('[data-text-as-pseudo-element]'); 19 const element = elementContainer.querySelector('[data-text-as-pseudo-element]');
20 count = parseInt(element.dataset.textAsPseudoElement, 10); 20 if (element && element.dataset) {
21 count = Ferdi.safeParseInt(element.dataset.textAsPseudoElement);
22 }
21 } 23 }
22 } 24 }
23 } 25 }
diff --git a/recipes/slite/package.json b/recipes/slite/package.json
index 5c38982..44ec123 100644
--- a/recipes/slite/package.json
+++ b/recipes/slite/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "slite", 2 "id": "slite",
3 "name": "Slite", 3 "name": "Slite",
4 "version": "1.0.3", 4 "version": "1.0.4",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://{teamId}.slite.com", 7 "serviceURL": "https://{teamId}.slite.com",
diff --git a/recipes/slite/webview.js b/recipes/slite/webview.js
index d892c3c..a044399 100644
--- a/recipes/slite/webview.js
+++ b/recipes/slite/webview.js
@@ -1,15 +1,7 @@
1const getInnerInt = selector => {
2 const element = document.querySelector(selector);
3 return element && parseInt(element.innerText);
4};
5
6module.exports = Ferdi => { 1module.exports = Ferdi => {
7 const getMessages = function getMessages() { 2 const getMessages = function getMessages() {
8 const direct = ( 3 const element = document.querySelector("#app button[data-test-id='notificationsCount']");
9 getInnerInt("#app button[data-test-id='notificationsCount']") || 0 4 Ferdi.setBadge(element ? Ferdi.safeParseInt(element.innerText) : 0);
10 );
11
12 Ferdi.setBadge(direct);
13 }; 5 };
14 6
15 Ferdi.loop(getMessages); 7 Ferdi.loop(getMessages);
diff --git a/recipes/steamchat/package.json b/recipes/steamchat/package.json
index 5899cc8..4edbb82 100644
--- a/recipes/steamchat/package.json
+++ b/recipes/steamchat/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "steamchat", 2 "id": "steamchat",
3 "name": "SteamChat", 3 "name": "SteamChat",
4 "version": "1.2.0", 4 "version": "1.2.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://steamcommunity.com/chat", 7 "serviceURL": "https://steamcommunity.com/chat",
diff --git a/recipes/steamchat/webview.js b/recipes/steamchat/webview.js
index b35cc6b..93e68ba 100644
--- a/recipes/steamchat/webview.js
+++ b/recipes/steamchat/webview.js
@@ -7,7 +7,7 @@ module.exports = Ferdi => {
7 const counters = document.querySelectorAll('[class*=FriendMessageCount]'); 7 const counters = document.querySelectorAll('[class*=FriendMessageCount]');
8 [].filter.call(counters, countValue => { 8 [].filter.call(counters, countValue => {
9 if (countValue) { 9 if (countValue) {
10 count += parseInt(countValue.innerHTML); 10 count += Ferdi.safeParseInt(countValue.innerHTML);
11 } 11 }
12 }); 12 });
13 13
diff --git a/recipes/teamleader/package.json b/recipes/teamleader/package.json
index 332f28f..83a8521 100644
--- a/recipes/teamleader/package.json
+++ b/recipes/teamleader/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "teamleader", 2 "id": "teamleader",
3 "name": "teamleader", 3 "name": "teamleader",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://app.teamleader.eu/?gotologin", 7 "serviceURL": "https://app.teamleader.eu/?gotologin",
diff --git a/recipes/teamleader/webview.js b/recipes/teamleader/webview.js
index 3041463..7eff414 100644
--- a/recipes/teamleader/webview.js
+++ b/recipes/teamleader/webview.js
@@ -4,8 +4,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
4 4
5module.exports = (Ferdi) => { 5module.exports = (Ferdi) => {
6 const getMessages = () => { 6 const getMessages = () => {
7 const unreadNotifications = parseInt(document.getElementById('notifications_amount').innerHTML); 7 Ferdi.setBadge(document.getElementById('notifications_amount').innerHTML);
8 Ferdi.setBadge(unreadNotifications);
9 }; 8 };
10 9
11 Ferdi.loop(getMessages); 10 Ferdi.loop(getMessages);
diff --git a/recipes/teamwork-projects/package.json b/recipes/teamwork-projects/package.json
index 573de82..50810b0 100644
--- a/recipes/teamwork-projects/package.json
+++ b/recipes/teamwork-projects/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "teamwork-projects", 2 "id": "teamwork-projects",
3 "name": "Teamwork Projects", 3 "name": "Teamwork Projects",
4 "version": "0.2.0", 4 "version": "0.2.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://{teamId}.teamwork.com/", 7 "serviceURL": "https://{teamId}.teamwork.com/",
diff --git a/recipes/teamwork-projects/webview.js b/recipes/teamwork-projects/webview.js
index 94e8dd0..734eb4f 100644
--- a/recipes/teamwork-projects/webview.js
+++ b/recipes/teamwork-projects/webview.js
@@ -4,7 +4,7 @@ module.exports = (Ferdi) => {
4 const badge = document.getElementById('numNotifs2'); 4 const badge = document.getElementById('numNotifs2');
5 5
6 if (badge && badge.innerText) { 6 if (badge && badge.innerText) {
7 indirectCount = parseInt(badge.innerText); 7 indirectCount = Ferdi.safeParseInt(badge.innerText);
8 } 8 }
9 9
10 Ferdi.setBadge(0, indirectCount); 10 Ferdi.setBadge(0, indirectCount);
diff --git a/recipes/telegram-react/package.json b/recipes/telegram-react/package.json
index ae8e451..b3dbde6 100644
--- a/recipes/telegram-react/package.json
+++ b/recipes/telegram-react/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "telegram-react", 2 "id": "telegram-react",
3 "name": "Telegram React", 3 "name": "Telegram React",
4 "version": "1.2.0", 4 "version": "1.2.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://webk.telegram.org", 7 "serviceURL": "https://webk.telegram.org",
diff --git a/recipes/telegram-react/webview.js b/recipes/telegram-react/webview.js
index b6240ff..c6111ee 100644
--- a/recipes/telegram-react/webview.js
+++ b/recipes/telegram-react/webview.js
@@ -5,7 +5,7 @@ module.exports = Ferdi => {
5 if (elements) { 5 if (elements) {
6 for (let i = 0; i < elements.length; i += 1) { 6 for (let i = 0; i < elements.length; i += 1) {
7 if (elements[i].querySelector('.unread') && elements[i].querySelector('.unread').innerHTML !== 0) { 7 if (elements[i].querySelector('.unread') && elements[i].querySelector('.unread').innerHTML !== 0) {
8 count += parseInt(elements[i].querySelector('.unread').innerHTML); 8 count += Ferdi.safeParseInt(elements[i].querySelector('.unread').innerHTML);
9 } 9 }
10 } 10 }
11 } 11 }
diff --git a/recipes/telegram/package.json b/recipes/telegram/package.json
index 47e53f0..024190f 100644
--- a/recipes/telegram/package.json
+++ b/recipes/telegram/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "telegram", 2 "id": "telegram",
3 "name": "Telegram", 3 "name": "Telegram",
4 "version": "3.2.0", 4 "version": "3.2.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://web.telegram.org", 7 "serviceURL": "https://web.telegram.org",
diff --git a/recipes/telegram/webview.js b/recipes/telegram/webview.js
index bf9ffec..a2be19b 100644
--- a/recipes/telegram/webview.js
+++ b/recipes/telegram/webview.js
@@ -12,13 +12,11 @@ module.exports = Ferdi => {
12 for (let i = 0; i < elements.length; i += 1) { 12 for (let i = 0; i < elements.length; i += 1) {
13 const subtitleBadge = elements[i].querySelector('.dialog-subtitle-badge'); 13 const subtitleBadge = elements[i].querySelector('.dialog-subtitle-badge');
14 if (subtitleBadge) { 14 if (subtitleBadge) {
15 const parsedValue = parseInt(subtitleBadge.innerText); 15 const parsedValue = Ferdi.safeParseInt(subtitleBadge.innerText);
16 if (!isNaN(parsedValue)) { 16 if (elements[i].dataset.peerId > 0) {
17 if (elements[i].dataset.peerId > 0) { 17 count += parsedValue;
18 count += parsedValue; 18 } else {
19 } else { 19 count_sec += parsedValue;
20 count_sec += parsedValue;
21 }
22 } 20 }
23 } 21 }
24 } 22 }
diff --git a/recipes/thelounge/package.json b/recipes/thelounge/package.json
index 816a4b1..a954b43 100644
--- a/recipes/thelounge/package.json
+++ b/recipes/thelounge/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "thelounge", 2 "id": "thelounge",
3 "name": "The Lounge", 3 "name": "The Lounge",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "hasCustomUrl": true, 7 "hasCustomUrl": true,
diff --git a/recipes/thelounge/webview.js b/recipes/thelounge/webview.js
index e993264..7174749 100644
--- a/recipes/thelounge/webview.js
+++ b/recipes/thelounge/webview.js
@@ -4,9 +4,10 @@ module.exports = Ferdi => {
4 const direct = document.querySelectorAll('.badge.highlight').length; 4 const direct = document.querySelectorAll('.badge.highlight').length;
5 let indirect = 0; 5 let indirect = 0;
6 for (let i = 0; i < indirectElements.length; i += 1) { 6 for (let i = 0; i < indirectElements.length; i += 1) {
7 if (indirectElements[i].innerHTML.length > 0) indirect++; 7 if (indirectElements[i].innerHTML.length > 0) {
8 indirect++;
9 }
8 } 10 }
9 console.log(direct, indirect);
10 Ferdi.setBadge(direct, indirect); 11 Ferdi.setBadge(direct, indirect);
11 }; 12 };
12 13
diff --git a/recipes/threema/package.json b/recipes/threema/package.json
index 00f3343..365c1d8 100644
--- a/recipes/threema/package.json
+++ b/recipes/threema/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "threema", 2 "id": "threema",
3 "name": "Threema", 3 "name": "Threema",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "repository": "https://github.com/Arany/franz-recipe-threema", 6 "repository": "https://github.com/Arany/franz-recipe-threema",
7 "config": { 7 "config": {
diff --git a/recipes/threema/webview.js b/recipes/threema/webview.js
index 8c7c137..d303b1b 100644
--- a/recipes/threema/webview.js
+++ b/recipes/threema/webview.js
@@ -9,7 +9,7 @@ module.exports = Ferdi => {
9 9
10 for (let i = 0; i < elements.length; i += 1) { 10 for (let i = 0; i < elements.length; i += 1) {
11 try { 11 try {
12 count += parseInt(elements[i].innerHTML.trim(), 10); 12 count += Ferdi.safeParseInt(elements[i].innerHTML);
13 } catch (e) { 13 } catch (e) {
14 console.error(e); 14 console.error(e);
15 } 15 }
diff --git a/recipes/todoist/package.json b/recipes/todoist/package.json
index ddcf188..dda30c8 100644
--- a/recipes/todoist/package.json
+++ b/recipes/todoist/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "todoist", 2 "id": "todoist",
3 "name": "Todoist", 3 "name": "Todoist",
4 "version": "1.3.0", 4 "version": "1.3.1",
5 "license": "MIT", 5 "license": "MIT",
6 "repository": "https://github.com/meetfranz/recipe-todoist", 6 "repository": "https://github.com/meetfranz/recipe-todoist",
7 "config": { 7 "config": {
diff --git a/recipes/todoist/webview.js b/recipes/todoist/webview.js
index a65be91..b548184 100644
--- a/recipes/todoist/webview.js
+++ b/recipes/todoist/webview.js
@@ -6,11 +6,11 @@ module.exports = (Ferdi) => {
6 const inboxElement = document.querySelector('#filter_inbox .item_counter'); 6 const inboxElement = document.querySelector('#filter_inbox .item_counter');
7 7
8 if (todayElement) { 8 if (todayElement) {
9 todayCount = parseInt(todayElement.innerHTML, 10); 9 todayCount = Ferdi.safeParseInt(todayElement.innerHTML);
10 } 10 }
11 11
12 if (inboxElement) { 12 if (inboxElement) {
13 inboxCount = parseInt(inboxElement.innerHTML, 10); 13 inboxCount = Ferdi.safeParseInt(inboxElement.innerHTML);
14 } 14 }
15 15
16 Ferdi.setBadge(inboxCount, todayCount); 16 Ferdi.setBadge(inboxCount, todayCount);
diff --git a/recipes/tweetdeck/package.json b/recipes/tweetdeck/package.json
index d564962..dd103f8 100644
--- a/recipes/tweetdeck/package.json
+++ b/recipes/tweetdeck/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "tweetdeck", 2 "id": "tweetdeck",
3 "name": "Tweetdeck", 3 "name": "Tweetdeck",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://tweetdeck.twitter.com/", 7 "serviceURL": "https://tweetdeck.twitter.com/",
diff --git a/recipes/tweetdeck/webview.js b/recipes/tweetdeck/webview.js
index 158f767..6de7d75 100644
--- a/recipes/tweetdeck/webview.js
+++ b/recipes/tweetdeck/webview.js
@@ -10,7 +10,7 @@ module.exports = Ferdi => {
10 const elements = document.querySelectorAll('.msg-unread-count'); 10 const elements = document.querySelectorAll('.msg-unread-count');
11 let count = 0; 11 let count = 0;
12 if (elements[0]) { 12 if (elements[0]) {
13 count = parseInt(elements[0].innerHTML, 10); 13 count = Ferdi.safeParseInt(elements[0].innerHTML);
14 } 14 }
15 15
16 Ferdi.setBadge(count); 16 Ferdi.setBadge(count);
diff --git a/recipes/twitter-dm/package.json b/recipes/twitter-dm/package.json
index 34b7aa2..066e699 100644
--- a/recipes/twitter-dm/package.json
+++ b/recipes/twitter-dm/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "twitter-dm", 2 "id": "twitter-dm",
3 "name": "Twitter DM", 3 "name": "Twitter DM",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://mobile.twitter.com/messages", 7 "serviceURL": "https://mobile.twitter.com/messages",
diff --git a/recipes/twitter-dm/webview.js b/recipes/twitter-dm/webview.js
index 25f9baa..d255ae9 100644
--- a/recipes/twitter-dm/webview.js
+++ b/recipes/twitter-dm/webview.js
@@ -2,9 +2,8 @@ module.exports = Ferdi => {
2 const getMessages = function getMessages() { 2 const getMessages = function getMessages() {
3 let count = 0; 3 let count = 0;
4 const elem = document.querySelector('a[href="/messages"] div div'); 4 const elem = document.querySelector('a[href="/messages"] div div');
5
6 if (elem) { 5 if (elem) {
7 count = parseInt(elem.innerText, 10); 6 count = Ferdi.safeParseInt(elem.innerText);
8 } 7 }
9 8
10 Ferdi.setBadge(count); 9 Ferdi.setBadge(count);
diff --git a/recipes/vk/package.json b/recipes/vk/package.json
index 19b4225..b46622d 100644
--- a/recipes/vk/package.json
+++ b/recipes/vk/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "vk", 2 "id": "vk",
3 "name": "VK", 3 "name": "VK",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "repository": "https://github.com/meetfranz/recipe-vk", 6 "repository": "https://github.com/meetfranz/recipe-vk",
7 "config": { 7 "config": {
diff --git a/recipes/vk/webview.js b/recipes/vk/webview.js
index e48866f..05d703e 100644
--- a/recipes/vk/webview.js
+++ b/recipes/vk/webview.js
@@ -1,8 +1,9 @@
1module.exports = Ferdi => { 1module.exports = Ferdi => {
2 const getMessages = function getMessages() { 2 const getMessages = function getMessages() {
3 let directs = 0; 3 let directs = 0;
4 if (document.getElementsByClassName('left_count').length > 0) { 4 const element = document.getElementsByClassName('left_count');
5 directs = parseInt(document.getElementsByClassName('left_count')[0].innerText, 10); 5 if (element.length > 0) {
6 directs = Ferdi.safeParseInt(element[0].innerText);
6 } 7 }
7 8
8 Ferdi.setBadge(directs); 9 Ferdi.setBadge(directs);
diff --git a/recipes/webex-teams/package.json b/recipes/webex-teams/package.json
index 0b8c3ee..d39962f 100644
--- a/recipes/webex-teams/package.json
+++ b/recipes/webex-teams/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "webex-teams", 2 "id": "webex-teams",
3 "name": "Webex Teams", 3 "name": "Webex Teams",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://web.webex.com", 7 "serviceURL": "https://web.webex.com",
diff --git a/recipes/webex-teams/webview.js b/recipes/webex-teams/webview.js
index 3880fd2..4b66233 100644
--- a/recipes/webex-teams/webview.js
+++ b/recipes/webex-teams/webview.js
@@ -9,11 +9,7 @@ module.exports = (Ferdi) => {
9 } 9 }
10 10
11 if (span.length > 0) { 11 if (span.length > 0) {
12 count = parseInt(span[0].innerText, 10); 12 count = Ferdi.safeParseInt(span[0].innerText);
13 }
14
15 if (Number.isNaN(count)) {
16 count = 0;
17 } 13 }
18 14
19 Ferdi.setBadge(count); 15 Ferdi.setBadge(count);
diff --git a/recipes/wechat/package.json b/recipes/wechat/package.json
index ec29d19..b8af764 100644
--- a/recipes/wechat/package.json
+++ b/recipes/wechat/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "wechat", 2 "id": "wechat",
3 "name": "WeChat", 3 "name": "WeChat",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "repository": "https://github.com/koma-private/recipe-wechat", 6 "repository": "https://github.com/koma-private/recipe-wechat",
7 "config": { 7 "config": {
diff --git a/recipes/wechat/webview.js b/recipes/wechat/webview.js
index 874ab55..b1d8e31 100644
--- a/recipes/wechat/webview.js
+++ b/recipes/wechat/webview.js
@@ -13,8 +13,8 @@ module.exports = (Ferdi) => {
13 const reddot = item.querySelector('i.web_wechat_reddot_middle'); 13 const reddot = item.querySelector('i.web_wechat_reddot_middle');
14 const avatarImage = item.querySelector('img.img'); 14 const avatarImage = item.querySelector('img.img');
15 15
16 if (reddot && reddot.innerText) { 16 if (reddot) {
17 count = parseInt(reddot.innerText); 17 count = Ferdi.safeParseInt(reddot.innerText);
18 } 18 }
19 19
20 if (avatarImage && avatarImage.getAttribute('src').search('webwxgeticon') != -1) { 20 if (avatarImage && avatarImage.getAttribute('src').search('webwxgeticon') != -1) {
diff --git a/recipes/whatsapp/package.json b/recipes/whatsapp/package.json
index 360cc47..6d2a93e 100644
--- a/recipes/whatsapp/package.json
+++ b/recipes/whatsapp/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "whatsapp", 2 "id": "whatsapp",
3 "name": "WhatsApp", 3 "name": "WhatsApp",
4 "version": "3.2.0", 4 "version": "3.2.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://web.whatsapp.com", 7 "serviceURL": "https://web.whatsapp.com",
diff --git a/recipes/whatsapp/webview.js b/recipes/whatsapp/webview.js
index 773caa8..9b979d2 100644
--- a/recipes/whatsapp/webview.js
+++ b/recipes/whatsapp/webview.js
@@ -36,7 +36,7 @@ module.exports = Ferdi => {
36 const chatElem = chatElems[i]; 36 const chatElem = chatElems[i];
37 const unreadElem = chatElem.children[0].children[0].children[1].children[1].children[1]; 37 const unreadElem = chatElem.children[0].children[0].children[1].children[1].children[1];
38 38
39 const countValue = parseInt(unreadElem.textContent) || 0; // Returns 0 in case of isNaN 39 const countValue = Ferdi.safeParseInt(unreadElem.textContent);
40 40
41 if (unreadElem.querySelectorAll('[data-icon=muted]').length === 0) { 41 if (unreadElem.querySelectorAll('[data-icon=muted]').length === 0) {
42 count += countValue; 42 count += countValue;
diff --git a/recipes/wire/package.json b/recipes/wire/package.json
index fdd8616..4a85ade 100644
--- a/recipes/wire/package.json
+++ b/recipes/wire/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "wire", 2 "id": "wire",
3 "name": "Wire", 3 "name": "Wire",
4 "version": "1.0.2", 4 "version": "1.0.3",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://app.wire.com/", 7 "serviceURL": "https://app.wire.com/",
diff --git a/recipes/wire/webview.js b/recipes/wire/webview.js
index efd37f3..b099eee 100644
--- a/recipes/wire/webview.js
+++ b/recipes/wire/webview.js
@@ -7,10 +7,7 @@ module.exports = (Ferdi) => {
7 const conversationElems = document.querySelectorAll('[data-uie-name="conversation-folder-badge"]'); 7 const conversationElems = document.querySelectorAll('[data-uie-name="conversation-folder-badge"]');
8 if (conversationElems) { 8 if (conversationElems) {
9 for (const conversationElem of conversationElems) { 9 for (const conversationElem of conversationElems) {
10 const count = parseInt(conversationElem.innerText); 10 direct += Ferdi.safeParseInt(conversationElem.innerText);
11 if (count) {
12 direct += count;
13 }
14 } 11 }
15 } 12 }
16 13
@@ -18,8 +15,8 @@ module.exports = (Ferdi) => {
18 const pendingElem = document.querySelector('[data-uie-name="item-pending-requests"]'); 15 const pendingElem = document.querySelector('[data-uie-name="item-pending-requests"]');
19 if (pendingElem) { 16 if (pendingElem) {
20 const matches = pendingElem.innerText.match(/^([1-9][0-9]*)/); 17 const matches = pendingElem.innerText.match(/^([1-9][0-9]*)/);
21 if (matches && matches.length > 0) { 18 if (matches && matches.length > 1) {
22 indirect += parseInt(matches[1]); 19 indirect += Ferdi.safeParseInt(matches[1]);
23 } 20 }
24 } 21 }
25 22
diff --git a/recipes/workplace/package.json b/recipes/workplace/package.json
index 61e317c..f730dd8 100644
--- a/recipes/workplace/package.json
+++ b/recipes/workplace/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "workplace", 2 "id": "workplace",
3 "name": "Workplace", 3 "name": "Workplace",
4 "version": "1.3.0", 4 "version": "1.3.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://{teamId}.workplace.com/chat", 7 "serviceURL": "https://{teamId}.workplace.com/chat",
diff --git a/recipes/workplace/webview.js b/recipes/workplace/webview.js
index e10c449..efa5e2a 100644
--- a/recipes/workplace/webview.js
+++ b/recipes/workplace/webview.js
@@ -10,7 +10,7 @@ module.exports = Ferdi => {
10 const notifications = document.querySelector('#notifications span span'); 10 const notifications = document.querySelector('#notifications span span');
11 11
12 if (notifications) { 12 if (notifications) {
13 indirect = parseInt(notifications.innerText, 10); 13 indirect = Ferdi.safeParseInt(notifications.innerText);
14 } 14 }
15 15
16 if (chatsElement) { 16 if (chatsElement) {
@@ -18,7 +18,7 @@ module.exports = Ferdi => {
18 const chatMessages = chatsElement.querySelector('span'); 18 const chatMessages = chatsElement.querySelector('span');
19 19
20 if (chatMessages) { 20 if (chatMessages) {
21 direct = parseInt(chatMessages.innerText, 10); 21 direct = Ferdi.safeParseInt(chatMessages.innerText);
22 } 22 }
23 } else { 23 } else {
24 direct = document.querySelectorAll('[data-pagelet="WorkGalahadChannel"] .uiList [role="gridcell"] [role="button"] .oxk9n0fw').length; 24 direct = document.querySelectorAll('[data-pagelet="WorkGalahadChannel"] .uiList [role="gridcell"] [role="button"] .oxk9n0fw').length;
diff --git a/recipes/wrike/package.json b/recipes/wrike/package.json
index 3d151a3..5eb0f04 100644
--- a/recipes/wrike/package.json
+++ b/recipes/wrike/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "wrike", 2 "id": "wrike",
3 "name": "Wrike", 3 "name": "Wrike",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "repository": "https://github.com/koma-private/recipe-wrike", 6 "repository": "https://github.com/koma-private/recipe-wrike",
7 "config": { 7 "config": {
diff --git a/recipes/wrike/webview.js b/recipes/wrike/webview.js
index be80318..39e293d 100644
--- a/recipes/wrike/webview.js
+++ b/recipes/wrike/webview.js
@@ -2,9 +2,8 @@ module.exports = (Ferdi) => {
2 function getMessages() { 2 function getMessages() {
3 let directCount = 0; 3 let directCount = 0;
4 const element = document.querySelector('.ws-navigation-button__indicator.ws-navigation-button-indicator'); 4 const element = document.querySelector('.ws-navigation-button__indicator.ws-navigation-button-indicator');
5 5 if (element) {
6 if (element && element.innerText) { 6 directCount = Ferdi.safeParseInt(element.innerText);
7 directCount = parseInt(element.innerText);
8 } 7 }
9 8
10 Ferdi.setBadge(directCount); 9 Ferdi.setBadge(directCount);
diff --git a/recipes/xing/package.json b/recipes/xing/package.json
index 0e3637d..12a2c6f 100644
--- a/recipes/xing/package.json
+++ b/recipes/xing/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "xing", 2 "id": "xing",
3 "name": "XING", 3 "name": "XING",
4 "version": "1.2.0", 4 "version": "1.2.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://www.xing.com/messenger/global" 7 "serviceURL": "https://www.xing.com/messenger/global"
diff --git a/recipes/xing/webview.js b/recipes/xing/webview.js
index 97daed2..9effe95 100644
--- a/recipes/xing/webview.js
+++ b/recipes/xing/webview.js
@@ -1,9 +1,6 @@
1module.exports = Ferdi => { 1module.exports = Ferdi => {
2 function getUnreadConversations() { 2 function getUnreadConversations() {
3 let unreadConversations = 0; 3 Ferdi.setBadge(document.querySelector('#unread-conversations').innerHTML);
4 unreadConversations = parseInt(document.querySelector('#unread-conversations').innerHTML, 10);
5
6 Ferdi.setBadge(unreadConversations);
7 } 4 }
8 5
9 Ferdi.loop(getUnreadConversations); 6 Ferdi.loop(getUnreadConversations);
diff --git a/recipes/yammer/package.json b/recipes/yammer/package.json
index 86b5bc6..f0a20d6 100644
--- a/recipes/yammer/package.json
+++ b/recipes/yammer/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "yammer", 2 "id": "yammer",
3 "name": "Yammer", 3 "name": "Yammer",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://www.yammer.com/login", 7 "serviceURL": "https://www.yammer.com/login",
diff --git a/recipes/yammer/webview.js b/recipes/yammer/webview.js
index 91daba6..79d428f 100644
--- a/recipes/yammer/webview.js
+++ b/recipes/yammer/webview.js
@@ -5,12 +5,12 @@ module.exports = Ferdi => {
5 const notificationElement = document.querySelector('.yj-notifications-indicator-count'); 5 const notificationElement = document.querySelector('.yj-notifications-indicator-count');
6 const newMessagesElement = document.querySelector('.yj-thread-list--new-messages-notice:not(.is-hidden) .yj-thread-list--new-message-text'); 6 const newMessagesElement = document.querySelector('.yj-thread-list--new-messages-notice:not(.is-hidden) .yj-thread-list--new-message-text');
7 7
8 if (notificationElement && notificationElement.innerHTML.length) { 8 if (notificationElement) {
9 directMessages = parseInt(notificationElement.innerHTML, 10); 9 directMessages = Ferdi.safeParseInt(notificationElement.innerHTML);
10 } 10 }
11 11
12 if (newMessagesElement && newMessagesElement.innerHTML.length) { 12 if (newMessagesElement) {
13 indirectMessages = parseInt(newMessagesElement.innerHTML.match(/\d+/)[0], 10); 13 indirectMessages = Ferdi.safeParseInt(newMessagesElement.innerHTML.match(/\d+/)[0]);
14 } 14 }
15 15
16 Ferdi.setBadge(directMessages, indirectMessages); 16 Ferdi.setBadge(directMessages, indirectMessages);
diff --git a/recipes/zendesk/package.json b/recipes/zendesk/package.json
index 922195b..18e11e0 100644
--- a/recipes/zendesk/package.json
+++ b/recipes/zendesk/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "zendesk", 2 "id": "zendesk",
3 "name": "zendesk", 3 "name": "zendesk",
4 "version": "1.1.0", 4 "version": "1.1.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://{teamId}.zendesk.com/agent", 7 "serviceURL": "https://{teamId}.zendesk.com/agent",
diff --git a/recipes/zendesk/webview.js b/recipes/zendesk/webview.js
index 8bc58ac..b781121 100644
--- a/recipes/zendesk/webview.js
+++ b/recipes/zendesk/webview.js
@@ -5,10 +5,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
5module.exports = Ferdi => { 5module.exports = Ferdi => {
6 const getMessages = () => { 6 const getMessages = () => {
7 let count = 0; 7 let count = 0;
8 const el = document.querySelector('.dashboard-top-panel .indicators .stats-group .cell-value'); 8 const element = document.querySelector('.dashboard-top-panel .indicators .stats-group .cell-value');
9 9 if (element) {
10 if (el) { 10 count = Ferdi.safeParseInt(element.innerHTML);
11 count = parseInt(el.innerHTML, 10);
12 } 11 }
13 12
14 Ferdi.setBadge(count); 13 Ferdi.setBadge(count);