aboutsummaryrefslogtreecommitdiffstats
path: root/recipes
diff options
context:
space:
mode:
authorLibravatar Markus Hatvan <markus_hatvan@aon.at>2021-10-05 17:04:09 +0200
committerLibravatar GitHub <noreply@github.com>2021-10-05 17:04:09 +0200
commitd3841b766f9d37d557646003899f67525c5f755f (patch)
tree1bcab990c94f2b05678b7a83ffebe08298500f0b /recipes
parentchore: repo maintenance (#732) (diff)
downloadferdium-recipes-d3841b766f9d37d557646003899f67525c5f755f.tar.gz
ferdium-recipes-d3841b766f9d37d557646003899f67525c5f755f.tar.zst
ferdium-recipes-d3841b766f9d37d557646003899f67525c5f755f.zip
chore: add eslint-plugin-unicorn (#733)
Diffstat (limited to 'recipes')
-rw-r--r--recipes/amazon-web-services/index.js3
-rw-r--r--recipes/amazon-work-mail/webview.js15
-rw-r--r--recipes/android-messages/webview.js20
-rw-r--r--recipes/anonaddy/index.js3
-rw-r--r--recipes/anydo/webview.js14
-rw-r--r--recipes/azure-devops/index.js3
-rw-r--r--recipes/basecamp/webview.js39
-rw-r--r--recipes/binance/index.js3
-rw-r--r--recipes/bip/index.js4
-rw-r--r--recipes/bip/webview.js4
-rw-r--r--recipes/bitbucket/index.js3
-rw-r--r--recipes/bitwarden/index.js3
-rw-r--r--recipes/campuswire/webview.js24
-rw-r--r--recipes/canvas/webview.js6
-rw-r--r--recipes/chatwork/webview.js21
-rw-r--r--recipes/cliq/webview.js8
-rw-r--r--recipes/clockify/webview.js2
-rw-r--r--recipes/devRant/webview.js27
-rw-r--r--recipes/devdocs/index.js3
-rw-r--r--recipes/dingtalk/webview.js27
-rw-r--r--recipes/disqus/webview.js7
-rw-r--r--recipes/epicgames/index.js3
-rw-r--r--recipes/erepublik/index.js3
-rw-r--r--recipes/erepublik/webview.js12
-rwxr-xr-xrecipes/facebook/webview.js16
-rw-r--r--recipes/fastmail/webview.js12
-rw-r--r--recipes/feedbin/webview.js2
-rw-r--r--recipes/feedly/webview.js8
-rw-r--r--recipes/figma/index.js3
-rw-r--r--recipes/fleep/index.js3
-rw-r--r--recipes/freshdesk/index.js3
-rw-r--r--recipes/gadugadu/webview.js4
-rw-r--r--recipes/github/index.js3
-rw-r--r--recipes/github/webview.js2
-rw-r--r--recipes/gitlab/index.js3
-rw-r--r--recipes/gitter/webview.js10
-rw-r--r--recipes/glowing-bear/webview.js7
-rw-r--r--recipes/gmail/index.js3
-rw-r--r--recipes/gmail/webview.js28
-rw-r--r--recipes/google-translate/index.js3
-rw-r--r--recipes/google-voice/webview.js7
-rw-r--r--recipes/googlecalendar/index.js3
-rw-r--r--recipes/googlecalendar/webview-unsafe.js8
-rw-r--r--recipes/googleclassroom/index.js3
-rw-r--r--recipes/googleclassroom/webview.js4
-rw-r--r--recipes/googledrive/index.js3
-rw-r--r--recipes/googlekeep/index.js3
-rw-r--r--recipes/googlemeet/index.js3
-rw-r--r--recipes/googlemeet/webview.js14
-rw-r--r--recipes/grape/index.js6
-rw-r--r--recipes/guilded/webview.js9
-rwxr-xr-xrecipes/habitica/webview.js4
-rw-r--r--recipes/hackmd/index.js3
-rw-r--r--recipes/hangouts/index.js3
-rw-r--r--recipes/hangoutschat/index.js3
-rw-r--r--recipes/hangoutschat/webview.js20
-rw-r--r--recipes/hey/webview.js28
-rw-r--r--recipes/hipchat/index.js6
-rw-r--r--recipes/icloud-reminders/index.js3
-rw-r--r--recipes/icq/webview.js12
-rw-r--r--recipes/idobata/webview.js4
-rw-r--r--recipes/infomaniak-mail/index.js3
-rw-r--r--recipes/infomaniak-mail/webview.js14
-rw-r--r--recipes/instagram/webview.js8
-rw-r--r--recipes/intercom/webview.js10
-rw-r--r--recipes/irccloud/webview.js4
-rw-r--r--recipes/jira/webview.js8
-rw-r--r--recipes/jitsi/webview.js5
-rw-r--r--recipes/jollor/webview.js12
-rw-r--r--recipes/keybase.io/index.js3
-rw-r--r--recipes/lark/webview.js14
-rw-r--r--recipes/lastpass/webview.js22
-rw-r--r--recipes/line-me/index.js3
-rw-r--r--recipes/linkedin/webview.js10
-rw-r--r--recipes/mattermost/index.js4
-rw-r--r--recipes/messenger/webview.js4
-rw-r--r--recipes/mewe/webview.js12
-rw-r--r--recipes/misskey/index.js4
-rwxr-xr-xrecipes/monday/webview.js4
-rw-r--r--recipes/msteams/webview.js14
-rw-r--r--recipes/mstodo/index.js3
-rw-r--r--recipes/mstodo/webview.js4
-rw-r--r--recipes/mysms/webview.js10
-rw-r--r--recipes/nextcloud-talk/webview.js7
-rw-r--r--recipes/nextdoor/webview.js6
-rw-r--r--recipes/notion/webview.js10
-rw-r--r--recipes/odoo/index.js3
-rw-r--r--recipes/office365-owa/webview.js26
-rw-r--r--recipes/onenote/index.js3
-rw-r--r--recipes/pinterest/index.js3
-rw-r--r--recipes/pivotal-tracker/webview.js6
-rw-r--r--recipes/plek/webview.js14
-rw-r--r--recipes/pleroma/index.js6
-rw-r--r--recipes/pleroma/webview.js8
-rw-r--r--recipes/plurk/webview.js8
-rw-r--r--recipes/podio/webview.js8
-rw-r--r--recipes/pomodoro-tracker/index.js3
-rw-r--r--recipes/producthunt/webview.js16
-rw-r--r--recipes/proton-mail/webview.js11
-rw-r--r--recipes/pulsesms/webview.js8
-rw-r--r--recipes/reddit/webview.js19
-rw-r--r--recipes/redditchat/webview.js3
-rw-r--r--recipes/riseup/index.js3
-rw-r--r--recipes/riseup/webview.js4
-rw-r--r--recipes/rocketchat/index.js4
-rw-r--r--recipes/rocketchat/webview.js6
-rw-r--r--recipes/roundcube/webview.js4
-rw-r--r--recipes/scribens/index.js3
-rw-r--r--recipes/scrumpy/webview.js12
-rw-r--r--recipes/simplenote/index.js3
-rw-r--r--recipes/simplenote/webview.js10
-rw-r--r--recipes/slack/webview.js2
-rw-r--r--recipes/slite/webview.js6
-rw-r--r--recipes/slowly/webview.js3
-rw-r--r--recipes/sococo/webview.js8
-rw-r--r--recipes/stackexchange/index.js3
-rw-r--r--recipes/stackoverflow-chat/index.js3
-rw-r--r--recipes/stackoverflow-chat/webview.js10
-rw-r--r--recipes/stackoverflow/webview.js4
-rw-r--r--recipes/steamchat/webview.js33
-rw-r--r--recipes/stride/webview.js4
-rw-r--r--recipes/sync/index.js3
-rw-r--r--recipes/teamleader/webview.js26
-rw-r--r--recipes/teamweek/index.js3
-rw-r--r--recipes/teamwork-projects/webview.js10
-rw-r--r--recipes/telegram-react/webview.js11
-rw-r--r--recipes/telegram/webview.js12
-rw-r--r--recipes/thelounge/webview.js8
-rw-r--r--recipes/threema/webview.js16
-rw-r--r--recipes/tinder/index.js3
-rw-r--r--recipes/todoist/webview.js6
-rw-r--r--recipes/trello/webview.js2
-rw-r--r--recipes/tutanota/index.js3
-rw-r--r--recipes/tweetdeck/webview.js2
-rw-r--r--recipes/twitter-dm/webview.js2
-rw-r--r--recipes/twitter/webview.js12
-rw-r--r--recipes/vk/webview.js4
-rw-r--r--recipes/wakatime/index.js3
-rw-r--r--recipes/webex-teams/webview.js12
-rw-r--r--recipes/wechat/webview.js17
-rw-r--r--recipes/weekplan/webview.js4
-rw-r--r--recipes/whatsapp/webview.js5
-rw-r--r--recipes/whereby/webview.js4
-rw-r--r--recipes/wire/webview.js19
-rw-r--r--recipes/workplace/webview.js21
-rw-r--r--recipes/wrike/webview.js10
-rw-r--r--recipes/xing/webview.js2
-rw-r--r--recipes/yammer/webview.js14
-rw-r--r--recipes/yandex-mail/webview.js4
-rw-r--r--recipes/youtrack/index.js3
-rw-r--r--recipes/zalo/webview.js2
-rw-r--r--recipes/zendesk/webview.js10
-rw-r--r--recipes/zulip/index.js4
-rw-r--r--recipes/zulip/webview.js8
154 files changed, 745 insertions, 504 deletions
diff --git a/recipes/amazon-web-services/index.js b/recipes/amazon-web-services/index.js
index d0e2779..057cd19 100644
--- a/recipes/amazon-web-services/index.js
+++ b/recipes/amazon-web-services/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class AmazonWebServices extends Ferdi { module.exports = Ferdi => class AmazonWebServices extends Ferdi {};
2};
diff --git a/recipes/amazon-work-mail/webview.js b/recipes/amazon-work-mail/webview.js
index 944a15c..44f3058 100644
--- a/recipes/amazon-work-mail/webview.js
+++ b/recipes/amazon-work-mail/webview.js
@@ -1,6 +1,6 @@
1module.exports = (Ferdi) => { 1const reload = EventType =>
2 const reload = (EventType) => new Promise((resolve, reject) => { 2 new Promise((resolve, reject) => {
3 const btn = document.getElementsByClassName('giraffe-hierarchy-node-refresh')[0]; 3 const btn = document.querySelectorAll('.giraffe-hierarchy-node-refresh')[0];
4 const EventObject = document.createEvent('Events'); 4 const EventObject = document.createEvent('Events');
5 EventObject.initEvent(EventType, true, false); 5 EventObject.initEvent(EventType, true, false);
6 6
@@ -11,12 +11,13 @@ module.exports = (Ferdi) => {
11 } 11 }
12 }); 12 });
13 13
14module.exports = Ferdi => {
14 const getUnread = () => { 15 const getUnread = () => {
15 const nodes = document.getElementsByClassName('giraffe-hierarchy-node-counter'); 16 const nodes = document.querySelectorAll('.giraffe-hierarchy-node-counter');
16 let counter = 0; 17 let counter = 0;
17 18
18 for (let i = 0; i < nodes.length; i++) { 19 for (const node of nodes) {
19 counter += Ferdi.safeParseInt(nodes[i].innerText); 20 counter += Ferdi.safeParseInt(node.textContent);
20 } 21 }
21 22
22 Ferdi.setBadge(counter); 23 Ferdi.setBadge(counter);
@@ -27,6 +28,6 @@ module.exports = (Ferdi) => {
27 28
28 window.setInterval(() => { 29 window.setInterval(() => {
29 reload('click'); 30 reload('click');
30 }, 60000); 31 }, 60_000);
31 } 32 }
32}; 33};
diff --git a/recipes/android-messages/webview.js b/recipes/android-messages/webview.js
index 13def91..35d5de2 100644
--- a/recipes/android-messages/webview.js
+++ b/recipes/android-messages/webview.js
@@ -2,7 +2,13 @@ setTimeout(() => {
2 const elem = document.querySelector('#af-error-container'); 2 const elem = document.querySelector('#af-error-container');
3 3
4 // TODO: This will not work for non-english locales 4 // TODO: This will not work for non-english locales
5 if (elem && elem.innerText.toLowerCase().includes('the requested url was not found on this server')) { 5 if (
6 elem &&
7 elem.textContent &&
8 elem.textContent
9 .toLowerCase()
10 .includes('the requested url was not found on this server')
11 ) {
6 window.location.reload(); 12 window.location.reload();
7 } 13 }
8}, 1000); 14}, 1000);
@@ -11,10 +17,18 @@ module.exports = (Ferdi, settings) => {
11 const getMessages = () => { 17 const getMessages = () => {
12 const messages = document.querySelectorAll('.text-content.unread').length; 18 const messages = document.querySelectorAll('.text-content.unread').length;
13 Ferdi.setBadge(messages); 19 Ferdi.setBadge(messages);
14 } 20 };
15 21
16 window.addEventListener('beforeunload', async () => { 22 window.addEventListener('beforeunload', async () => {
17 Ferdi.clearStorageData(settings.id, { storages: ['appcache', 'serviceworkers', 'cachestorage', 'websql', 'indexdb'] }); 23 Ferdi.clearStorageData(settings.id, {
24 storages: [
25 'appcache',
26 'serviceworkers',
27 'cachestorage',
28 'websql',
29 'indexdb',
30 ],
31 });
18 Ferdi.releaseServiceWorkers(); 32 Ferdi.releaseServiceWorkers();
19 }); 33 });
20 34
diff --git a/recipes/anonaddy/index.js b/recipes/anonaddy/index.js
index d14a262..b8cdae2 100644
--- a/recipes/anonaddy/index.js
+++ b/recipes/anonaddy/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class anonaddy extends Ferdi { module.exports = Ferdi => class anonaddy extends Ferdi {};
2};
diff --git a/recipes/anydo/webview.js b/recipes/anydo/webview.js
index 4f4749b..e1ee479 100644
--- a/recipes/anydo/webview.js
+++ b/recipes/anydo/webview.js
@@ -1,13 +1,15 @@
1module.exports = (Ferdi) => { 1module.exports = Ferdi => {
2 function getTasks() { 2 function getTasks() {
3 let incompleteCount = 0; 3 let incompleteCount = 0;
4 4
5 const countEls = document.querySelectorAll('.AppSidebarListsItems__itemContainer__sizeContainer:not([hidden]) > .AppSidebarListsItems__itemContainer__size'); 5 const countEls = document.querySelectorAll(
6 '.AppSidebarListsItems__itemContainer__sizeContainer:not([hidden]) > .AppSidebarListsItems__itemContainer__size',
7 );
6 8
7 if (countEls.length) { 9 if (countEls.length > 0) {
8 Array.from(countEls).forEach((el) => { 10 for (const el of countEls) {
9 incompleteCount += Ferdi.safeParseInt(el.innerHTML); 11 incompleteCount += Ferdi.safeParseInt(el.textContent);
10 }); 12 }
11 } 13 }
12 14
13 Ferdi.setBadge(incompleteCount); 15 Ferdi.setBadge(incompleteCount);
diff --git a/recipes/azure-devops/index.js b/recipes/azure-devops/index.js
index 2864cca..a6cb2af 100644
--- a/recipes/azure-devops/index.js
+++ b/recipes/azure-devops/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class azuredevops extends Ferdi { module.exports = Ferdi => class azuredevops extends Ferdi {};
2};
diff --git a/recipes/basecamp/webview.js b/recipes/basecamp/webview.js
index 16eced3..9d8e677 100644
--- a/recipes/basecamp/webview.js
+++ b/recipes/basecamp/webview.js
@@ -4,6 +4,14 @@ function _interopRequireDefault(obj) {
4 return obj && obj.__esModule ? obj : { default: obj }; 4 return obj && obj.__esModule ? obj : { default: obj };
5} 5}
6 6
7function show(element) {
8 element.style.display = 'inherit';
9}
10
11function hide(element) {
12 element.style.display = 'none';
13}
14
7module.exports = Ferdi => { 15module.exports = Ferdi => {
8 const modal = document.createElement('div'); 16 const modal = document.createElement('div');
9 17
@@ -16,12 +24,21 @@ module.exports = Ferdi => {
16 }; 24 };
17 function showModal(text) { 25 function showModal(text) {
18 show(modal); 26 show(modal);
19 modal.querySelector('p').innerHTML = text; 27
28 let p = modal.querySelector('p');
29
30 if (p) {
31 p.textContent = text;
32 }
20 } 33 }
21 34
22 function hideModal() { 35 function hideModal() {
23 hide(modal); 36 hide(modal);
24 modal.querySelector('p').innerHTML = ''; 37 let p = modal.querySelector('p');
38
39 if (p) {
40 p.textContent = '';
41 }
25 } 42 }
26 43
27 // Replace window.alert to hide alerts in Ferdi 44 // Replace window.alert to hide alerts in Ferdi
@@ -31,21 +48,17 @@ module.exports = Ferdi => {
31 showModal.apply(oldAlert, arguments); 48 showModal.apply(oldAlert, arguments);
32 }; 49 };
33 50
34 function show(element) {
35 element.style.display = 'inherit';
36 }
37
38 function hide(element) {
39 element.style.display = 'none';
40 }
41
42 modal.id = 'franz-modal'; 51 modal.id = 'franz-modal';
43 modal.innerHTML = 52 modal.textContent =
44 '<div class="modal-content"><span class="close">&times;</span><p></p></div>'; 53 '<div class="modal-content"><span class="close">&times;</span><p></p></div>';
45 modal.querySelector('.close').addEventListener('click', hideModal); 54
55 let close = modal.querySelector('.close');
56 if (close) {
57 close.addEventListener('click', hideModal);
58 }
46 waitFor( 59 waitFor(
47 () => document.body, 60 () => document.body,
48 () => document.body.appendChild(modal), 61 () => document.body.append(modal),
49 ); 62 );
50 63
51 document.addEventListener('keydown', e => { 64 document.addEventListener('keydown', e => {
diff --git a/recipes/binance/index.js b/recipes/binance/index.js
index a6681d5..b4d7495 100644
--- a/recipes/binance/index.js
+++ b/recipes/binance/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class Binance extends Ferdi { module.exports = Ferdi => class Binance extends Ferdi {};
2};
diff --git a/recipes/bip/index.js b/recipes/bip/index.js
index 4507e72..8949ee0 100644
--- a/recipes/bip/index.js
+++ b/recipes/bip/index.js
@@ -1,3 +1 @@
1module.exports = Ferdi => class bip extends Ferdi { module.exports = Ferdi => class bip extends Ferdi {};
2
3};
diff --git a/recipes/bip/webview.js b/recipes/bip/webview.js
index ea8fa5f..f3166ce 100644
--- a/recipes/bip/webview.js
+++ b/recipes/bip/webview.js
@@ -6,8 +6,8 @@ module.exports = Ferdi => {
6 const getMessages = () => { 6 const getMessages = () => {
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 (const element of elements) {
10 count += Ferdi.safeParseInt(elements[i].textContent); 10 count += Ferdi.safeParseInt(element.textContent);
11 } 11 }
12 Ferdi.setBadge(count, 0); 12 Ferdi.setBadge(count, 0);
13 }; 13 };
diff --git a/recipes/bitbucket/index.js b/recipes/bitbucket/index.js
index 7983bf0..3709b27 100644
--- a/recipes/bitbucket/index.js
+++ b/recipes/bitbucket/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class bitbucket extends Ferdi { module.exports = Ferdi => class bitbucket extends Ferdi {};
2};
diff --git a/recipes/bitwarden/index.js b/recipes/bitwarden/index.js
index a59e581..ab7de5f 100644
--- a/recipes/bitwarden/index.js
+++ b/recipes/bitwarden/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class Bitwarden extends Ferdi { module.exports = Ferdi => class Bitwarden extends Ferdi {};
2};
diff --git a/recipes/campuswire/webview.js b/recipes/campuswire/webview.js
index 9837030..418ac9d 100644
--- a/recipes/campuswire/webview.js
+++ b/recipes/campuswire/webview.js
@@ -1,10 +1,12 @@
1module.exports = Ferdi => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 let count = document.querySelectorAll('._5fx8:not(._569x),._1ht3:not(._569x)').length; 3 let count = document.querySelectorAll(
4 '._5fx8:not(._569x),._1ht3:not(._569x)',
5 ).length;
4 const messageRequestsElement = document.querySelector('._5nxf'); 6 const messageRequestsElement = document.querySelector('._5nxf');
5 7
6 if (messageRequestsElement) { 8 if (messageRequestsElement) {
7 count += Ferdi.safeParseInt(messageRequestsElement.innerHTML); 9 count += Ferdi.safeParseInt(messageRequestsElement.textContent);
8 } 10 }
9 11
10 Ferdi.setBadge(count); 12 Ferdi.setBadge(count);
@@ -12,19 +14,25 @@ module.exports = Ferdi => {
12 14
13 Ferdi.loop(getMessages); 15 Ferdi.loop(getMessages);
14 16
15 localStorage.setItem('_cs_desktopNotifsEnabled', JSON.stringify({ 17 localStorage.setItem(
16 __t: new Date().getTime(), 18 '_cs_desktopNotifsEnabled',
17 __v: true, 19 JSON.stringify({
18 })); 20 __t: Date.now(),
21 __v: true,
22 }),
23 );
19 24
20 if (typeof Ferdi.onNotify === 'function') { 25 if (typeof Ferdi.onNotify === 'function') {
21 Ferdi.onNotify(notification => { 26 Ferdi.onNotify(notification => {
22 if (typeof notification.title !== 'string') { 27 if (typeof notification.title !== 'string') {
23 notification.title = ((notification.title.props || {}).content || [])[0] || 'Campuswire'; 28 notification.title =
29 ((notification.title.props || {}).content || [])[0] || 'Campuswire';
24 } 30 }
25 31
26 if (typeof notification.options.body !== 'string') { 32 if (typeof notification.options.body !== 'string') {
27 notification.options.body = (((notification.options.body || {}).props || {}).content || [])[0] || ''; 33 notification.options.body =
34 (((notification.options.body || {}).props || {}).content || [])[0] ||
35 '';
28 } 36 }
29 37
30 return notification; 38 return notification;
diff --git a/recipes/canvas/webview.js b/recipes/canvas/webview.js
index a70f448..070a975 100644
--- a/recipes/canvas/webview.js
+++ b/recipes/canvas/webview.js
@@ -2,9 +2,11 @@ module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 let direct = 0; 3 let direct = 0;
4 4
5 const MessageElement = document.querySelector('[id=global_nav_conversations_link]'); 5 const MessageElement = document.querySelector(
6 '[id=global_nav_conversations_link]',
7 );
6 if (MessageElement) { 8 if (MessageElement) {
7 direct += Ferdi.safeParseInt(MessageElement.innerHTML); 9 direct += Ferdi.safeParseInt(MessageElement.textContent);
8 } 10 }
9 11
10 Ferdi.setBadge(direct); 12 Ferdi.setBadge(direct);
diff --git a/recipes/chatwork/webview.js b/recipes/chatwork/webview.js
index 05e1912..ed09ef7 100644
--- a/recipes/chatwork/webview.js
+++ b/recipes/chatwork/webview.js
@@ -1,19 +1,26 @@
1module.exports = (Ferdi) => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 let directCount = 0; 3 let directCount = 0;
4 let indirectCount = 0; 4 let indirectCount = 0;
5 const roomInfoContainer = document.querySelectorAll('li.sc-dnqmqq'); 5 const roomInfoContainer = document.querySelectorAll('li.sc-dnqmqq');
6 Array.prototype.forEach.call(roomInfoContainer, (room) => { 6 Array.prototype.forEach.call(roomInfoContainer, room => {
7 let count = 0; 7 let count = 0;
8 const unreadBadge = room.querySelector('span.sc-kAzzGY'); 8 const unreadBadge = room.querySelector('span.sc-kAzzGY');
9 const unreadBadgeHasMention = room.querySelector('li._unreadBadge.sc-cSHVUG'); 9 const unreadBadgeHasMention = room.querySelector(
10 'li._unreadBadge.sc-cSHVUG',
11 );
10 12
11 if (unreadBadge && unreadBadge.innerText) { 13 if (unreadBadge && unreadBadge.textContent) {
12 count = Ferdi.safeParseInt(unreadBadge.innerText); 14 count = Ferdi.safeParseInt(unreadBadge.textContent);
13 } 15 }
14 16
15 if (count > 0) { 17 if (count > 0) {
16 if (room.querySelector('img.sc-gqjmRU').getAttribute('src').indexOf('avatar') < 0) { 18 if (
19 !room
20 .querySelector('img.sc-gqjmRU')
21 .getAttribute('src')
22 .includes('avatar')
23 ) {
17 if (unreadBadgeHasMention) { 24 if (unreadBadgeHasMention) {
18 directCount++; 25 directCount++;
19 } else { 26 } else {
@@ -25,7 +32,7 @@ module.exports = (Ferdi) => {
25 } 32 }
26 }); 33 });
27 Ferdi.setBadge(directCount, indirectCount); 34 Ferdi.setBadge(directCount, indirectCount);
28 } 35 };
29 36
30 Ferdi.loop(getMessages); 37 Ferdi.loop(getMessages);
31}; 38};
diff --git a/recipes/cliq/webview.js b/recipes/cliq/webview.js
index 0c6e550..23607bd 100644
--- a/recipes/cliq/webview.js
+++ b/recipes/cliq/webview.js
@@ -1,7 +1 @@
1module.exports = Ferdi => { module.exports = Ferdi => Ferdi;
2 const getMessages = () => {
3 // Ferdi.setBadge(ConversationsList.getUnreadBadgeCount());
4 };
5
6 Ferdi.loop(getMessages);
7};
diff --git a/recipes/clockify/webview.js b/recipes/clockify/webview.js
index 9fbb613..bf926e4 100644
--- a/recipes/clockify/webview.js
+++ b/recipes/clockify/webview.js
@@ -1,7 +1,7 @@
1module.exports = Ferdi => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 const notifications = document.querySelectorAll('.notification--number'); 3 const notifications = document.querySelectorAll('.notification--number');
4 Ferdi.setBadge(0, notifications.length >= 1 ? 1 : 0); 4 Ferdi.setBadge(0, notifications.length > 0 ? 1 : 0);
5 }; 5 };
6 6
7 Ferdi.loop(getMessages); 7 Ferdi.loop(getMessages);
diff --git a/recipes/devRant/webview.js b/recipes/devRant/webview.js
index 9e8b31c..7385db5 100644
--- a/recipes/devRant/webview.js
+++ b/recipes/devRant/webview.js
@@ -1,10 +1,16 @@
1const _path = _interopRequireDefault(require('path')); 1const _path = _interopRequireDefault(require('path'));
2 2
3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3function _interopRequireDefault(obj) {
4 return obj && obj.__esModule ? obj : { default: obj };
5}
4 6
5setTimeout(() => { 7setTimeout(() => {
6 const elem = document.querySelector('.landing-title.version-title'); 8 const elem = document.querySelector('.landing-title.version-title');
7 if (elem && elem.innerText.toLowerCase().includes('google chrome')) { 9 if (
10 elem &&
11 elem.textContent &&
12 elem.textContent.toLowerCase().includes('google chrome')
13 ) {
8 window.location.reload(); 14 window.location.reload();
9 } 15 }
10}, 1000); 16}, 1000);
@@ -13,8 +19,11 @@ module.exports = (Ferdi, settings) => {
13 const getMessages = () => { 19 const getMessages = () => {
14 const elements = document.querySelectorAll('.CxUIE, .unread, ._0LqQ'); 20 const elements = document.querySelectorAll('.CxUIE, .unread, ._0LqQ');
15 let count = 0; 21 let count = 0;
16 for (let i = 0; i < elements.length; i += 1) { 22 for (const element of elements) {
17 if (elements[i].querySelectorAll('.P6z4j').length === 1 && elements[i].querySelectorAll('*[data-icon="muted"]').length === 0) { 23 if (
24 element.querySelectorAll('.P6z4j').length === 1 &&
25 element.querySelectorAll('*[data-icon="muted"]').length === 0
26 ) {
18 count += 1; 27 count += 1;
19 } 28 }
20 } 29 }
@@ -23,7 +32,15 @@ module.exports = (Ferdi, settings) => {
23 }; 32 };
24 33
25 window.addEventListener('beforeunload', async () => { 34 window.addEventListener('beforeunload', async () => {
26 Ferdi.clearStorageData(settings.id, { storages: ['appcache', 'serviceworkers', 'cachestorage', 'websql', 'indexdb'] }); 35 Ferdi.clearStorageData(settings.id, {
36 storages: [
37 'appcache',
38 'serviceworkers',
39 'cachestorage',
40 'websql',
41 'indexdb',
42 ],
43 });
27 Ferdi.releaseServiceWorkers(); 44 Ferdi.releaseServiceWorkers();
28 }); 45 });
29 46
diff --git a/recipes/devdocs/index.js b/recipes/devdocs/index.js
index 91113e0..119cbe1 100644
--- a/recipes/devdocs/index.js
+++ b/recipes/devdocs/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class devdocs extends Ferdi { module.exports = Ferdi => class devdocs extends Ferdi {};
2};
diff --git a/recipes/dingtalk/webview.js b/recipes/dingtalk/webview.js
index aa5f2a3..59881cf 100644
--- a/recipes/dingtalk/webview.js
+++ b/recipes/dingtalk/webview.js
@@ -1,21 +1,28 @@
1const _path = _interopRequireDefault(require('path')); 1const _path = _interopRequireDefault(require('path'));
2 2
3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3function _interopRequireDefault(obj) {
4 return obj && obj.__esModule ? obj : { default: obj };
5}
4 6
5module.exports = (Ferdi) => { 7module.exports = Ferdi => {
6 let checkIsRun = false; 8 let checkIsRun = false;
7 const checkHeightAction = () => { 9 const checkHeightAction = () => {
8 checkIsRun = true; 10 checkIsRun = true;
9 let checkHeight = setInterval(() => { 11 let checkHeight = setInterval(() => {
10 let menuPanel = document.getElementById('menu-pannel') 12 let menuPanel = document.querySelector('#menu-pannel');
11 if (!menuPanel) { 13 if (!menuPanel) {
12 return 14 return;
15 }
16 if (menuPanel.parentElement) {
17 menuPanel.parentElement.setAttribute(
18 'style',
19 'height:' + (window.outerHeight - 60) + 'px',
20 );
13 } 21 }
14 menuPanel.parentElement.setAttribute('style', 'height:' + (window.outerHeight - 60) + 'px');
15 clearInterval(checkHeight); 22 clearInterval(checkHeight);
16 checkIsRun = false 23 checkIsRun = false;
17 }, 1000) 24 }, 1000);
18 } 25 };
19 26
20 checkHeightAction(); 27 checkHeightAction();
21 28
@@ -26,8 +33,8 @@ module.exports = (Ferdi) => {
26 }); 33 });
27 34
28 const getMessages = () => { 35 const getMessages = () => {
29 const x = document.querySelectorAll('.unread-num em.ng-binding') 36 const x = document.querySelectorAll('.unread-num em.ng-binding');
30 Ferdi.setBadge(x.length > 0 ? x[0].innerHTML : 0); 37 Ferdi.setBadge(x.length > 0 ? x[0].textContent : 0);
31 }; 38 };
32 39
33 Ferdi.loop(getMessages); 40 Ferdi.loop(getMessages);
diff --git a/recipes/disqus/webview.js b/recipes/disqus/webview.js
index a79f5e7..fcdd386 100644
--- a/recipes/disqus/webview.js
+++ b/recipes/disqus/webview.js
@@ -1,15 +1,14 @@
1module.exports = Ferdi => { 1module.exports = Ferdi => {
2 const getInnerInt = selector => { 2 const getInnerInt = selector => {
3 const element = document.querySelector(selector); 3 const element = document.querySelector(selector);
4 return element && Ferdi.safeParseInt(element.innerText); 4 return element && Ferdi.safeParseInt(element.textContent);
5 }; 5 };
6 6
7 const getMessages = () => { 7 const getMessages = () => {
8 const direct = ( 8 const direct =
9 getInnerInt("header div[data-role='unread-notification-count']") || 9 getInnerInt("header div[data-role='unread-notification-count']") ||
10 getInnerInt('a.has-notifs div.notif-count') || 10 getInnerInt('a.has-notifs div.notif-count') ||
11 0 11 0;
12 );
13 12
14 Ferdi.setBadge(direct); 13 Ferdi.setBadge(direct);
15 }; 14 };
diff --git a/recipes/epicgames/index.js b/recipes/epicgames/index.js
index 891040d..35bf240 100644
--- a/recipes/epicgames/index.js
+++ b/recipes/epicgames/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class epicgames extends Ferdi { module.exports = Ferdi => class epicgames extends Ferdi {};
2};
diff --git a/recipes/erepublik/index.js b/recipes/erepublik/index.js
index 146e5fb..12cdd73 100644
--- a/recipes/erepublik/index.js
+++ b/recipes/erepublik/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class erepublik extends Ferdi { module.exports = Ferdi => class erepublik extends Ferdi {};
2};
diff --git a/recipes/erepublik/webview.js b/recipes/erepublik/webview.js
index 6a105e1..a47c57d 100644
--- a/recipes/erepublik/webview.js
+++ b/recipes/erepublik/webview.js
@@ -4,19 +4,19 @@ 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 elementNotify = document.getElementsByClassName('notify'); 7 const elementNotify = document.querySelectorAll('.notify');
8 const elementFeed = document.getElementsByClassName('unreadCounter ng-binding ng-scope'); 8 const elementFeed = document.querySelectorAll('.unreadCounter.ng-binding.ng-scope');
9 9
10 let countNotify = 0; 10 let countNotify = 0;
11 let countFeed = 0; 11 let countFeed = 0;
12 12
13 for (let i = 0; i < elementNotify.length; i++) { 13 for (const element of elementNotify) {
14 const splitText = elementNotify[i].title.split(':'); 14 const splitText = element.title.split(':');
15 countNotify += Ferdi.safeParseInt(splitText[1]); 15 countNotify += Ferdi.safeParseInt(splitText[1]);
16 } 16 }
17 17
18 for (let i = 0; i < elementFeed.length; i++) { 18 for (const element of elementFeed) {
19 countFeed += Ferdi.safeParseInt(elementFeed[i].textContent); 19 countFeed += Ferdi.safeParseInt(element.textContent);
20 } 20 }
21 21
22 Ferdi.setBadge(countNotify, countFeed); 22 Ferdi.setBadge(countNotify, countFeed);
diff --git a/recipes/facebook/webview.js b/recipes/facebook/webview.js
index 43de149..b38a2fb 100755
--- a/recipes/facebook/webview.js
+++ b/recipes/facebook/webview.js
@@ -1,19 +1,21 @@
1module.exports = (Ferdi) => { 1module.exports = Ferdi => {
2 const getNotifications = function getNotifications() { 2 const getNotifications = function getNotifications() {
3 let count = 0; 3 let count = 0;
4 4
5 const elements = [ 5 const elements = [
6 document.getElementById('requestsCountValue'), 6 document.querySelector('#requestsCountValue'),
7 // document.getElementById('mercurymessagesCountValue'), 7 // document.getElementById('mercurymessagesCountValue'),
8 document.getElementById('notificationsCountValue'), 8 document.querySelector('#notificationsCountValue'),
9 document.querySelector('.k4urcfbm.qnrpqo6b.qt6c0cv9.jxrgncrl.jb3vyjys.taijpn5t.datstx6m.pq6dq46d.ljqsnud1.bp9cbjyn'), 9 document.querySelector(
10 '.k4urcfbm.qnrpqo6b.qt6c0cv9.jxrgncrl.jb3vyjys.taijpn5t.datstx6m.pq6dq46d.ljqsnud1.bp9cbjyn',
11 ),
10 ]; 12 ];
11 13
12 elements.forEach((element) => { 14 for (const element of elements) {
13 if (element !== null) { 15 if (element !== null) {
14 count += Ferdi.safeParseInt(element.innerHTML); 16 count += Ferdi.safeParseInt(element.textContent);
15 } 17 }
16 }); 18 }
17 19
18 Ferdi.setBadge(count); 20 Ferdi.setBadge(count);
19 }; 21 };
diff --git a/recipes/fastmail/webview.js b/recipes/fastmail/webview.js
index 42883e8..782963b 100644
--- a/recipes/fastmail/webview.js
+++ b/recipes/fastmail/webview.js
@@ -1,14 +1,18 @@
1const _path = _interopRequireDefault(require('path')); 1const _path = _interopRequireDefault(require('path'));
2 2
3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3function _interopRequireDefault(obj) {
4 return obj && obj.__esModule ? obj : { default: obj };
5}
4 6
5module.exports = (Ferdi) => { 7module.exports = Ferdi => {
6 const getMessages = () => { 8 const getMessages = () => {
7 const inbox = document.querySelector('.v-MailboxSource--inbox .v-MailboxSource-badge'); 9 const inbox = document.querySelector(
10 '.v-MailboxSource--inbox .v-MailboxSource-badge',
11 );
8 if (!inbox) { 12 if (!inbox) {
9 return; 13 return;
10 } 14 }
11 const messages = Ferdi.safeParseInt(inbox.innerText); 15 const messages = Ferdi.safeParseInt(inbox.textContent);
12 Ferdi.setBadge(messages); 16 Ferdi.setBadge(messages);
13 }; 17 };
14 18
diff --git a/recipes/feedbin/webview.js b/recipes/feedbin/webview.js
index 197814e..85df36f 100644
--- a/recipes/feedbin/webview.js
+++ b/recipes/feedbin/webview.js
@@ -1,7 +1,7 @@
1module.exports = Ferdi => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 // eslint-disable-next-line no-undef 3 // eslint-disable-next-line no-undef
4 const count = feedbin.count_data.unread_entries.length || 0; 4 const count = feedbin.count_data.unread_entries.length > 0 || 0;
5 Ferdi.setBadge(count); 5 Ferdi.setBadge(count);
6 }; 6 };
7 7
diff --git a/recipes/feedly/webview.js b/recipes/feedly/webview.js
index 1c313e7..3e15fd5 100644
--- a/recipes/feedly/webview.js
+++ b/recipes/feedly/webview.js
@@ -1,10 +1,12 @@
1module.exports = Ferdi => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 const newsDOM = document.querySelectorAll("div[title='All'] > .LeftnavListRow__count")[0].innerHTML; 3 const newsDOM = document.querySelectorAll(
4 "div[title='All'] > .LeftnavListRow__count",
5 )[0].textContent;
4 let counter = Ferdi.safeParseInt(newsDOM); 6 let counter = Ferdi.safeParseInt(newsDOM);
5 7
6 if (newsDOM.indexOf('K') !== -1 || newsDOM.indexOf('+') !== -1) { 8 if (newsDOM && (newsDOM.includes('K') || newsDOM.includes('+'))) {
7 counter = `${newsDOM.substring(0, newsDOM.indexOf('K'))}000`; 9 counter = `${newsDOM.slice(0, Math.max(0, newsDOM.indexOf('K')))}000`;
8 } 10 }
9 11
10 Ferdi.setBadge(counter); 12 Ferdi.setBadge(counter);
diff --git a/recipes/figma/index.js b/recipes/figma/index.js
index 734a454..1542871 100644
--- a/recipes/figma/index.js
+++ b/recipes/figma/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class figma extends Ferdi { module.exports = Ferdi => class figma extends Ferdi {};
2};
diff --git a/recipes/fleep/index.js b/recipes/fleep/index.js
index 8f5370b..44283d7 100644
--- a/recipes/fleep/index.js
+++ b/recipes/fleep/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class fleep extends Ferdi { module.exports = Ferdi => class fleep extends Ferdi {};
2};
diff --git a/recipes/freshdesk/index.js b/recipes/freshdesk/index.js
index 4484d30..f2cc5c2 100644
--- a/recipes/freshdesk/index.js
+++ b/recipes/freshdesk/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class Freshdesk extends Ferdi { module.exports = Ferdi => class Freshdesk extends Ferdi {};
2};
diff --git a/recipes/gadugadu/webview.js b/recipes/gadugadu/webview.js
index a3c1ee2..2f90db2 100644
--- a/recipes/gadugadu/webview.js
+++ b/recipes/gadugadu/webview.js
@@ -7,8 +7,8 @@ module.exports = Ferdi => {
7 const updates = Ferdi.safeParseInt(document.querySelector('i#sr-last-counter').textContent); 7 const updates = Ferdi.safeParseInt(document.querySelector('i#sr-last-counter').textContent);
8 let messages = 0; 8 let messages = 0;
9 const elements = document.querySelectorAll('.chat-counter:not(.d-none)'); 9 const elements = document.querySelectorAll('.chat-counter:not(.d-none)');
10 for (let i = 0; i < elements.length; i++) { 10 for (const element of elements) {
11 messages += Ferdi.safeParseInt(elements[i].textContent); 11 messages += Ferdi.safeParseInt(element.textContent);
12 } 12 }
13 13
14 Ferdi.setBadge(messages, updates); 14 Ferdi.setBadge(messages, updates);
diff --git a/recipes/github/index.js b/recipes/github/index.js
index a84e54a..84cb38d 100644
--- a/recipes/github/index.js
+++ b/recipes/github/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class GitHub extends Ferdi { module.exports = Ferdi => class GitHub extends Ferdi {};
2};
diff --git a/recipes/github/webview.js b/recipes/github/webview.js
index 47d4a13..d63a4c5 100644
--- a/recipes/github/webview.js
+++ b/recipes/github/webview.js
@@ -5,7 +5,7 @@ module.exports = Ferdi => {
5 ); 5 );
6 let directCount = 0; 6 let directCount = 0;
7 if (directCountElement) { 7 if (directCountElement) {
8 directCount = Ferdi.safeParseInt(directCountElement.innerHTML); 8 directCount = Ferdi.safeParseInt(directCountElement.textContent);
9 } 9 }
10 10
11 const indirectCountElement = document.querySelector( 11 const indirectCountElement = document.querySelector(
diff --git a/recipes/gitlab/index.js b/recipes/gitlab/index.js
index 500d8e8..7183771 100644
--- a/recipes/gitlab/index.js
+++ b/recipes/gitlab/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class gitlab extends Ferdi { module.exports = Ferdi => class gitlab extends Ferdi {};
2};
diff --git a/recipes/gitter/webview.js b/recipes/gitter/webview.js
index e78cadf..0026790 100644
--- a/recipes/gitter/webview.js
+++ b/recipes/gitter/webview.js
@@ -1,14 +1,16 @@
1const _path = _interopRequireDefault(require('path')); 1const _path = _interopRequireDefault(require('path'));
2 2
3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3function _interopRequireDefault(obj) {
4 return obj && obj.__esModule ? obj : { default: obj };
5}
4 6
5module.exports = Ferdi => { 7module.exports = Ferdi => {
6 const getMessages = () => { 8 const getMessages = () => {
7 // get unread messages 9 // get unread messages
8 let count = 0; 10 let count = 0;
9 document.querySelectorAll('div.unread-indicator').forEach((node) => { 11 for (const node of document.querySelectorAll('div.unread-indicator')) {
10 count += Ferdi.safeParseInt(node.innerText); 12 count += Ferdi.safeParseInt(node.textContent);
11 }); 13 }
12 14
13 // set Ferdi badge 15 // set Ferdi badge
14 Ferdi.setBadge(count); 16 Ferdi.setBadge(count);
diff --git a/recipes/glowing-bear/webview.js b/recipes/glowing-bear/webview.js
index 6abd69a..8bb9dfd 100644
--- a/recipes/glowing-bear/webview.js
+++ b/recipes/glowing-bear/webview.js
@@ -3,8 +3,11 @@ module.exports = Ferdi => {
3 const indirectElements = document.querySelectorAll('.badge:not(.danger)'); 3 const indirectElements = document.querySelectorAll('.badge:not(.danger)');
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 (const indirectElement of indirectElements) {
7 if (indirectElements[i].innerHTML.length > 0) { 7 if (
8 indirectElement.textContent &&
9 indirectElement.textContent.length > 0
10 ) {
8 indirect++; 11 indirect++;
9 } 12 }
10 } 13 }
diff --git a/recipes/gmail/index.js b/recipes/gmail/index.js
index 8aae88f..fe5d29b 100644
--- a/recipes/gmail/index.js
+++ b/recipes/gmail/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class Gmail extends Ferdi { module.exports = Ferdi => class Gmail extends Ferdi {};
2};
diff --git a/recipes/gmail/webview.js b/recipes/gmail/webview.js
index 23b1382..9b94d33 100644
--- a/recipes/gmail/webview.js
+++ b/recipes/gmail/webview.js
@@ -1,21 +1,33 @@
1const _path = _interopRequireDefault(require('path')); 1const _path = _interopRequireDefault(require('path'));
2 2
3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3function _interopRequireDefault(obj) {
4 return obj && obj.__esModule ? obj : { default: obj };
5}
4 6
5module.exports = (Ferdi) => { 7module.exports = Ferdi => {
6 // if the user is on gmail's landing page, go to the login page. 8 // if the user is on gmail's landing page, go to the login page.
7 if (location.hostname == 'www.google.com' && location.href.includes('gmail/about/')) { 9 if (
8 location.href = 'https://accounts.google.com/AccountChooser?service=mail&continue=https://mail.google.com/mail/'; 10 location.hostname == 'www.google.com' &&
11 location.href.includes('gmail/about/')
12 ) {
13 location.href =
14 'https://accounts.google.com/AccountChooser?service=mail&continue=https://mail.google.com/mail/';
9 } 15 }
10 16
11 const getMessages = () => { 17 const getMessages = () => {
12 let count = 0; 18 let count = 0;
13 19
14 const inboxLinks = document.getElementsByClassName('J-Ke n0'); 20 const inboxLinks = document.querySelectorAll('.J-Ke.n0');
15 if (inboxLinks.length > 0) { 21 if (inboxLinks.length > 0) {
16 const unreadCounts = inboxLinks[0].parentNode.parentNode.getElementsByClassName('bsU'); 22 let parentNode = inboxLinks[0].parentNode;
17 if (unreadCounts.length > 0) { 23 if (parentNode) {
18 count = Ferdi.safeParseInt(unreadCounts[0].innerHTML); 24 let parentNodeOfParentNode = parentNode.parentNode;
25 if (parentNodeOfParentNode) {
26 const unreadCounts = parentNodeOfParentNode.querySelectorAll('.bsU');
27 if (unreadCounts.length > 0) {
28 count = Ferdi.safeParseInt(unreadCounts[0].textContent);
29 }
30 }
19 } 31 }
20 } 32 }
21 33
diff --git a/recipes/google-translate/index.js b/recipes/google-translate/index.js
index f714165..4ce580f 100644
--- a/recipes/google-translate/index.js
+++ b/recipes/google-translate/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class GoogleTranslate extends Ferdi { module.exports = Ferdi => class GoogleTranslate extends Ferdi {};
2};
diff --git a/recipes/google-voice/webview.js b/recipes/google-voice/webview.js
index eb3004d..8b2d2b3 100644
--- a/recipes/google-voice/webview.js
+++ b/recipes/google-voice/webview.js
@@ -1,16 +1,15 @@
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 && Ferdi.safeParseInt(el.innerHTML); 4 return el && Ferdi.safeParseInt(el.textContent);
5 } 5 }
6 6
7 const getMessages = () => { 7 const getMessages = () => {
8 const el = document.querySelector('.msgCount'); 8 const el = document.querySelector('.msgCount');
9 let count; 9 let count;
10 10
11 if (el) { 11 if (el && el.textContent) {
12 // eslint-disable-next-line no-useless-escape 12 count = Ferdi.safeParseInt(el.textContent.replace(/[ ()]/gi, ''));
13 count = Ferdi.safeParseInt(el.innerHTML.replace(/[\(\) ]/gi, ''));
14 } else { 13 } else {
15 const count_messages = parseQuery( 14 const count_messages = parseQuery(
16 'gv-nav-tab[tooltip="Messages"] div[aria-label="Unread count"]', 15 'gv-nav-tab[tooltip="Messages"] div[aria-label="Unread count"]',
diff --git a/recipes/googlecalendar/index.js b/recipes/googlecalendar/index.js
index 553d5ef..e84eca2 100644
--- a/recipes/googlecalendar/index.js
+++ b/recipes/googlecalendar/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class GoogleCalendar extends Ferdi { module.exports = Ferdi => class GoogleCalendar extends Ferdi {};
2};
diff --git a/recipes/googlecalendar/webview-unsafe.js b/recipes/googlecalendar/webview-unsafe.js
index 54a7338..141d3bc 100644
--- a/recipes/googlecalendar/webview-unsafe.js
+++ b/recipes/googlecalendar/webview-unsafe.js
@@ -10,14 +10,14 @@ const waitFor = (condition, callback) => {
10}; 10};
11 11
12const showModal = text => { 12const showModal = text => {
13 modal.querySelector('p').innerHTML = text; 13 modal.querySelector('p').textContent = text;
14 updates += 1; 14 updates += 1;
15 window.ferdi.setBadge(updates); 15 window.ferdi.setBadge(updates);
16 modal.classList.add('open'); 16 modal.classList.add('open');
17}; 17};
18 18
19const hideModal = () => { 19const hideModal = () => {
20 modal.querySelector('p').innerHTML = ''; 20 modal.querySelector('p').textContent = '';
21 updates -= 1; 21 updates -= 1;
22 window.ferdi.setBadge(updates); 22 window.ferdi.setBadge(updates);
23 modal.classList.remove('open'); 23 modal.classList.remove('open');
@@ -26,7 +26,7 @@ const hideModal = () => {
26const createModal = () => { 26const createModal = () => {
27 const modalDialog = document.createElement('div'); 27 const modalDialog = document.createElement('div');
28 modalDialog.setAttribute('id', 'franz-modal'); 28 modalDialog.setAttribute('id', 'franz-modal');
29 modalDialog.innerHTML = 29 modalDialog.textContent =
30 '<div class="modal-content"><span class="close">&times;</span><p></p></div>'; 30 '<div class="modal-content"><span class="close">&times;</span><p></p></div>';
31 modalDialog.querySelector('.close').addEventListener('click', hideModal); 31 modalDialog.querySelector('.close').addEventListener('click', hideModal);
32 32
@@ -38,7 +38,7 @@ window.alert = showModal;
38modal = createModal(); 38modal = createModal();
39waitFor( 39waitFor(
40 () => document.body, 40 () => document.body,
41 () => document.body.appendChild(modal), 41 () => document.body.append(modal),
42); 42);
43document.addEventListener( 43document.addEventListener(
44 'keydown', 44 'keydown',
diff --git a/recipes/googleclassroom/index.js b/recipes/googleclassroom/index.js
index 9ccb30b..e46ccef 100644
--- a/recipes/googleclassroom/index.js
+++ b/recipes/googleclassroom/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class GoogleClassroom extends Ferdi { module.exports = Ferdi => class GoogleClassroom extends Ferdi {};
2};
diff --git a/recipes/googleclassroom/webview.js b/recipes/googleclassroom/webview.js
index 0f24597..f542b00 100644
--- a/recipes/googleclassroom/webview.js
+++ b/recipes/googleclassroom/webview.js
@@ -1,8 +1,8 @@
1module.exports = Ferdi => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 let homework = 0; 3 let homework = 0;
4 const upcomingAssignment = document.getElementsByClassName('hrUpcomingAssignmentGroup'); 4 const upcomingAssignment = document.querySelectorAll('.hrUpcomingAssignmentGroup');
5 if (upcomingAssignment.length != 0) { 5 if (upcomingAssignment.length > 0) {
6 let i; 6 let i;
7 for (i = 0; i < upcomingAssignment.length; i++) { 7 for (i = 0; i < upcomingAssignment.length; i++) {
8 homework += upcomingAssignment[i].childElementCount; 8 homework += upcomingAssignment[i].childElementCount;
diff --git a/recipes/googledrive/index.js b/recipes/googledrive/index.js
index c3580bd..7b71e60 100644
--- a/recipes/googledrive/index.js
+++ b/recipes/googledrive/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class googledrive extends Ferdi { module.exports = Ferdi => class googledrive extends Ferdi {};
2};
diff --git a/recipes/googlekeep/index.js b/recipes/googlekeep/index.js
index e311079..4e1c164 100644
--- a/recipes/googlekeep/index.js
+++ b/recipes/googlekeep/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class GoogleKeep extends Ferdi { module.exports = Ferdi => class GoogleKeep extends Ferdi {};
2};
diff --git a/recipes/googlemeet/index.js b/recipes/googlemeet/index.js
index 58aff86..e5d1742 100644
--- a/recipes/googlemeet/index.js
+++ b/recipes/googlemeet/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class GoogleMeet extends Ferdi { module.exports = Ferdi => class GoogleMeet extends Ferdi {};
2};
diff --git a/recipes/googlemeet/webview.js b/recipes/googlemeet/webview.js
index 7a97505..6ea36f3 100644
--- a/recipes/googlemeet/webview.js
+++ b/recipes/googlemeet/webview.js
@@ -1,22 +1,24 @@
1const _path = _interopRequireDefault(require('path')); 1const _path = _interopRequireDefault(require('path'));
2 2
3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3function _interopRequireDefault(obj) {
4 return obj && obj.__esModule ? obj : { default: obj };
5}
4 6
5window.onload = () => { 7window.addEventListener('load', () => {
6 const title = document.querySelector('.window-title').innerHTML; 8 const title = document.querySelector('.window-title').textContent;
7 9
8 if (title && title.includes('Google Chrome 36+')) { 10 if (title && title.includes('Google Chrome 36+')) {
9 window.location.reload(); 11 window.location.reload();
10 } 12 }
11}; 13});
12 14
13module.exports = (Ferdi, settings) => { 15module.exports = (Ferdi, settings) => {
14 const getMessages = () => { 16 const getMessages = () => {
15 const elements = document.querySelectorAll('.CxUIE, .unread'); 17 const elements = document.querySelectorAll('.CxUIE, .unread');
16 let count = 0; 18 let count = 0;
17 19
18 for (let i = 0; i < elements.length; i += 1) { 20 for (const element of elements) {
19 if (elements[i].querySelectorAll('*[data-icon="muted"]').length === 0) { 21 if (element.querySelectorAll('*[data-icon="muted"]').length === 0) {
20 count += 1; 22 count += 1;
21 } 23 }
22 } 24 }
diff --git a/recipes/grape/index.js b/recipes/grape/index.js
index 356b57a..2039c8d 100644
--- a/recipes/grape/index.js
+++ b/recipes/grape/index.js
@@ -1,4 +1,4 @@
1function _asyncToGenerator(fn) { return function () { const gen = fn.apply(this, arguments); return new Promise((resolve, reject) => { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then((value) => { step('next', value); }, (err) => { step('throw', err); }); } } return step('next'); }); }; } 1function _asyncToGenerator(fn) { return function () { const gen = Reflect.apply(fn, this, arguments); return new Promise((resolve, reject) => { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then((value) => { step('next', value); }, (error) => { step('throw', error); }); } } return step('next'); }); }; }
2 2
3module.exports = Ferdi => class Grape extends Ferdi { 3module.exports = Ferdi => class Grape extends Ferdi {
4 validateUrl(url) { 4 validateUrl(url) {
@@ -8,8 +8,8 @@ module.exports = Ferdi => class Grape extends Ferdi {
8 method: 'GET', 8 method: 'GET',
9 }); 9 });
10 return resp.status === 200; 10 return resp.status === 200;
11 } catch (err) { 11 } catch (error) {
12 console.error(err); 12 console.error(error);
13 } 13 }
14 14
15 return false; 15 return false;
diff --git a/recipes/guilded/webview.js b/recipes/guilded/webview.js
index c8d33f2..69c3bcb 100644
--- a/recipes/guilded/webview.js
+++ b/recipes/guilded/webview.js
@@ -1,10 +1,13 @@
1module.exports = Ferdi => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 let unread = 0; 3 let unread = 0;
4 const notificationBadge = document.getElementsByClassName('NavSelectorItem-unread-badge')[0]; 4 const notificationBadge = document.querySelectorAll(
5 '.NavSelectorItem-unread-badge',
6 )[0];
5 if (notificationBadge != undefined) { 7 if (notificationBadge != undefined) {
6 const innerBadge = notificationBadge.getElementsByClassName('BadgeV2-count')[0]; 8 const innerBadge =
7 unread = Ferdi.safeParseInt(innerBadge.innerText); 9 notificationBadge.querySelectorAll('.BadgeV2-count')[0];
10 unread = Ferdi.safeParseInt(innerBadge.textContent);
8 } 11 }
9 Ferdi.setBadge(unread); 12 Ferdi.setBadge(unread);
10 }; 13 };
diff --git a/recipes/habitica/webview.js b/recipes/habitica/webview.js
index c856fca..aa678b5 100755
--- a/recipes/habitica/webview.js
+++ b/recipes/habitica/webview.js
@@ -1,9 +1,9 @@
1module.exports = (Ferdi) => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 let count = 0; 3 let count = 0;
4 const element = document.querySelector('.message-count'); 4 const element = document.querySelector('.message-count');
5 if (element) { 5 if (element) {
6 count = Ferdi.safeParseInt(element.innerText); 6 count = Ferdi.safeParseInt(element.textContent);
7 } 7 }
8 Ferdi.setBadge(count); 8 Ferdi.setBadge(count);
9 }; 9 };
diff --git a/recipes/hackmd/index.js b/recipes/hackmd/index.js
index c3d5c52..3a2908b 100644
--- a/recipes/hackmd/index.js
+++ b/recipes/hackmd/index.js
@@ -1,3 +1,2 @@
1// todo allow custom url 1// todo allow custom url
2module.exports = Ferdi => class HackMd extends Ferdi { 2module.exports = Ferdi => class HackMd extends Ferdi {};
3};
diff --git a/recipes/hangouts/index.js b/recipes/hangouts/index.js
index 0a1336f..e2a5585 100644
--- a/recipes/hangouts/index.js
+++ b/recipes/hangouts/index.js
@@ -1,2 +1 @@
1module.exports = (Ferdi) => class Hangouts extends Ferdi { module.exports = (Ferdi) => class Hangouts extends Ferdi {};
2};
diff --git a/recipes/hangoutschat/index.js b/recipes/hangoutschat/index.js
index 6bed9d7..bd7fbe7 100644
--- a/recipes/hangoutschat/index.js
+++ b/recipes/hangoutschat/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class HangoutsChat extends Ferdi { module.exports = Ferdi => class HangoutsChat extends Ferdi {};
2};
diff --git a/recipes/hangoutschat/webview.js b/recipes/hangoutschat/webview.js
index c8aa952..e2e5912 100644
--- a/recipes/hangoutschat/webview.js
+++ b/recipes/hangoutschat/webview.js
@@ -1,4 +1,4 @@
1module.exports = (Ferdi) => { 1module.exports = Ferdi => {
2 // class corresponding to the red badge that is visible for direct messages 2 // class corresponding to the red badge that is visible for direct messages
3 const directMessageSelector = 'div.V6.CL.su.ahD.X9.Y2 span.akt span.XU'; 3 const directMessageSelector = 'div.V6.CL.su.ahD.X9.Y2 span.akt span.XU';
4 4
@@ -7,10 +7,21 @@ module.exports = (Ferdi) => {
7 7
8 const getMessages = () => { 8 const getMessages = () => {
9 // get unread direct messages 9 // get unread direct messages
10 const directCount = Number(document.querySelector(directMessageSelector).innerText); 10 let directCount;
11 let indirectCount;
12
13 const directCountSelector = document.querySelector(directMessageSelector);
14 if (directCountSelector) {
15 directCount = Number(directCountSelector.textContent);
16 }
11 17
12 // get unread indirect messages 18 // get unread indirect messages
13 const indirectCount = Number(document.querySelector(indirectMessageSelector).innerText); 19 const indirectCountSelector = document.querySelector(
20 indirectMessageSelector,
21 );
22 if (indirectCountSelector) {
23 indirectCount = Number(indirectCountSelector.textContent);
24 }
14 25
15 // set Ferdi badge 26 // set Ferdi badge
16 Ferdi.setBadge(directCount, indirectCount); 27 Ferdi.setBadge(directCount, indirectCount);
@@ -18,7 +29,8 @@ module.exports = (Ferdi) => {
18 29
19 Ferdi.loop(getMessages); 30 Ferdi.loop(getMessages);
20 31
21 document.addEventListener('click', (e) => { 32 document.addEventListener('click', e => {
33 // @ts-ignore
22 const { tagName, target, href } = e.target; 34 const { tagName, target, href } = e.target;
23 35
24 if (tagName === 'A' && target === '_blank') { 36 if (tagName === 'A' && target === '_blank') {
diff --git a/recipes/hey/webview.js b/recipes/hey/webview.js
index 686e811..67e87d4 100644
--- a/recipes/hey/webview.js
+++ b/recipes/hey/webview.js
@@ -1,23 +1,29 @@
1module.exports = (Ferdi) => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 if (document.location.href == "https://app.hey.com/") { 3 if (document.location.href == 'https://app.hey.com/') {
4 let screener = 0; 4 let screener = 0;
5 let unread = 0; 5 let unread = 0;
6 6
7 if (document.getElementsByClassName('btn--icon-screener').length > 0) { 7 if (document.querySelectorAll('.btn--icon-screener').length > 0) {
8 let text = document.getElementsByClassName('btn--icon-screener')[0].innerText; 8 let text = document.querySelectorAll('.btn--icon-screener')[0]
9 9 .textContent;
10 screener = Ferdi.safeParseInt(/[0-9]+/.exec(text)[0]); 10 if (text) {
11 const parsedText = Ferdi.safeParseInt(/\d+/.exec(text));
12 screener = parsedText[0];
13 }
11 } 14 }
12 15
13 let postings = document.getElementsByClassName('posting'); 16 let postings = document.querySelectorAll('.posting');
14 17
15 if (postings.length > 0) { 18 if (postings.length > 0) {
16 Array.from(postings).forEach(p => { 19 for (const p of postings) {
17 if (p.nodeName == "ARTICLE" && p.getAttribute("data-seen") !== "true") { 20 if (
21 p.nodeName == 'ARTICLE' &&
22 p.getAttribute('data-seen') !== 'true'
23 ) {
18 unread++; 24 unread++;
19 } 25 }
20 }); 26 }
21 } 27 }
22 28
23 Ferdi.setBadge(unread, screener); 29 Ferdi.setBadge(unread, screener);
@@ -25,4 +31,4 @@ module.exports = (Ferdi) => {
25 }; 31 };
26 32
27 Ferdi.loop(getMessages); 33 Ferdi.loop(getMessages);
28} 34};
diff --git a/recipes/hipchat/index.js b/recipes/hipchat/index.js
index 5c550d8..0a461ab 100644
--- a/recipes/hipchat/index.js
+++ b/recipes/hipchat/index.js
@@ -1,4 +1,4 @@
1function _asyncToGenerator(fn) { return function () { const gen = fn.apply(this, arguments); return new Promise((resolve, reject) => { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then((value) => { step('next', value); }, (err) => { step('throw', err); }); } } return step('next'); }); }; } 1function _asyncToGenerator(fn) { return function () { const gen = Reflect.apply(fn, this, arguments); return new Promise((resolve, reject) => { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then((value) => { step('next', value); }, (error) => { step('throw', error); }); } } return step('next'); }); }; }
2 2
3module.exports = Ferdi => class HipChat extends Ferdi { 3module.exports = Ferdi => class HipChat extends Ferdi {
4 validateUrl(url) { 4 validateUrl(url) {
@@ -13,8 +13,8 @@ module.exports = Ferdi => class HipChat extends Ferdi {
13 const data = yield resp.json(); 13 const data = yield resp.json();
14 14
15 return Object.hasOwnProperty.call(data, 'features'); 15 return Object.hasOwnProperty.call(data, 'features');
16 } catch (err) { 16 } catch (error) {
17 console.error(err); 17 console.error(error);
18 } 18 }
19 19
20 return false; 20 return false;
diff --git a/recipes/icloud-reminders/index.js b/recipes/icloud-reminders/index.js
index f26900d..3fb9a8f 100644
--- a/recipes/icloud-reminders/index.js
+++ b/recipes/icloud-reminders/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class icloudreminders extends Ferdi { module.exports = Ferdi => class icloudreminders extends Ferdi {};
2};
diff --git a/recipes/icq/webview.js b/recipes/icq/webview.js
index 1bffd27..e782eb4 100644
--- a/recipes/icq/webview.js
+++ b/recipes/icq/webview.js
@@ -1,9 +1,15 @@
1module.exports = Ferdi => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 let directs = 0; 3 let directs = 0;
4 const elements = document.getElementsByClassName('nwa-msg-counter icq-recent_state-read'); 4 const elements = document.querySelectorAll(
5 for (let i = 0; i < elements.length; i++) { 5 '.nwa-msg-counter.icq-recent_state-read',
6 if (Ferdi.safeParseInt(elements[i].innerText.replace(/[^0-9.]/g, '')) > 0) { 6 );
7 for (const element of elements) {
8 if (
9 Ferdi.safeParseInt(
10 element.textContent && element.textContent.replace(/[^\d.]/g, ''),
11 ) > 0
12 ) {
7 directs += 1; // count 1 per channel with messages 13 directs += 1; // count 1 per channel with messages
8 } 14 }
9 } 15 }
diff --git a/recipes/idobata/webview.js b/recipes/idobata/webview.js
index 075316d..d30e2ad 100644
--- a/recipes/idobata/webview.js
+++ b/recipes/idobata/webview.js
@@ -1,10 +1,10 @@
1module.exports = Ferdi => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 const title = document.querySelector('title').innerHTML.match(/\d+/); 3 const title = document.querySelector('title').textContent.match(/\d+/);
4 const count = title !== null ? title[0] : 0; 4 const count = title !== null ? title[0] : 0;
5 5
6 Ferdi.setBadge(count); 6 Ferdi.setBadge(count);
7 } 7 };
8 8
9 Ferdi.loop(getMessages); 9 Ferdi.loop(getMessages);
10}; 10};
diff --git a/recipes/infomaniak-mail/index.js b/recipes/infomaniak-mail/index.js
index 93f2dcf..24184f8 100644
--- a/recipes/infomaniak-mail/index.js
+++ b/recipes/infomaniak-mail/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class infomaniakmail extends Ferdi { module.exports = Ferdi => class infomaniakmail extends Ferdi {};
2};
diff --git a/recipes/infomaniak-mail/webview.js b/recipes/infomaniak-mail/webview.js
index 04ac42d..f4e39dc 100644
--- a/recipes/infomaniak-mail/webview.js
+++ b/recipes/infomaniak-mail/webview.js
@@ -1,8 +1,16 @@
1module.exports = Ferdi => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 const count = document.querySelector('.ws-tree-node-badge').innerText; 3 const count = document.querySelector('.ws-tree-node-badge');
4 Ferdi.setBadge(count ? Number(count.substring(1, count.length - 1)) : 0); 4 if (count) {
5 } 5 const countText = count.textContent;
6 if (countText) {
7 Ferdi.setBadge(
8 // eslint-disable-next-line unicorn/prefer-string-slice
9 count ? Number(countText.substring(1, countText.length - 1)) : 0,
10 );
11 }
12 }
13 };
6 14
7 Ferdi.loop(getMessages); 15 Ferdi.loop(getMessages);
8}; 16};
diff --git a/recipes/instagram/webview.js b/recipes/instagram/webview.js
index b971021..797f544 100644
--- a/recipes/instagram/webview.js
+++ b/recipes/instagram/webview.js
@@ -1,11 +1,13 @@
1const _path = _interopRequireDefault(require('path')); 1const _path = _interopRequireDefault(require('path'));
2 2
3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3function _interopRequireDefault(obj) {
4 return obj && obj.__esModule ? obj : { default: obj };
5}
4 6
5module.exports = (Ferdi) => { 7module.exports = Ferdi => {
6 const getMessages = () => { 8 const getMessages = () => {
7 const element = document.querySelector('a[href^="/direct/inbox"]'); 9 const element = document.querySelector('a[href^="/direct/inbox"]');
8 Ferdi.setBadge(element ? Ferdi.safeParseInt(element.innerText) : 0); 10 Ferdi.setBadge(element ? Ferdi.safeParseInt(element.textContent) : 0);
9 }; 11 };
10 12
11 Ferdi.loop(getMessages); 13 Ferdi.loop(getMessages);
diff --git a/recipes/intercom/webview.js b/recipes/intercom/webview.js
index 1ccf8a0..ff3e9a0 100644
--- a/recipes/intercom/webview.js
+++ b/recipes/intercom/webview.js
@@ -1,8 +1,12 @@
1module.exports = (Ferdi) => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 const numMessages = Ferdi.safeParseInt(document.querySelector('.left-nav [data-content="Inbox"] .unread__container .unread').innerHTML); 3 const numMessages = Ferdi.safeParseInt(
4 document.querySelector(
5 '.left-nav [data-content="Inbox"] .unread__container .unread',
6 ).textContent,
7 );
4 Ferdi.setBadge(numMessages); 8 Ferdi.setBadge(numMessages);
5 } 9 };
6 10
7 Ferdi.loop(getMessages); 11 Ferdi.loop(getMessages);
8}; 12};
diff --git a/recipes/irccloud/webview.js b/recipes/irccloud/webview.js
index 0c46c46..ab26279 100644
--- a/recipes/irccloud/webview.js
+++ b/recipes/irccloud/webview.js
@@ -1,7 +1,7 @@
1module.exports = Ferdi => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 const directMessages = document.getElementsByClassName('buffer conversation active unread activeBadge').length; 3 const directMessages = document.querySelectorAll('.buffer.conversation.active.unread.activeBadge').length;
4 const indirectMessages = document.getElementsByClassName('buffer channel active unread').length; 4 const indirectMessages = document.querySelectorAll('.buffer.channel.active.unread').length;
5 5
6 Ferdi.setBadge(directMessages, indirectMessages); 6 Ferdi.setBadge(directMessages, indirectMessages);
7 }; 7 };
diff --git a/recipes/jira/webview.js b/recipes/jira/webview.js
index 246511e..9599b66 100644
--- a/recipes/jira/webview.js
+++ b/recipes/jira/webview.js
@@ -1,8 +1,10 @@
1module.exports = (Ferdi) => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 // get unread messages 3 // get unread messages
4 const element = document.querySelector('#atlassian-navigation-notification-count span'); 4 const element = document.querySelector(
5 Ferdi.setBadge(element ? element.innerText : 0); 5 '#atlassian-navigation-notification-count span',
6 );
7 Ferdi.setBadge(element ? element.textContent : 0);
6 }; 8 };
7 9
8 Ferdi.loop(getMessages); 10 Ferdi.loop(getMessages);
diff --git a/recipes/jitsi/webview.js b/recipes/jitsi/webview.js
index 69c468e..f4121e9 100644
--- a/recipes/jitsi/webview.js
+++ b/recipes/jitsi/webview.js
@@ -3,7 +3,10 @@ const NOTIFICATION_BADGE_CLASS = '.badge-round';
3module.exports = Ferdi => { 3module.exports = Ferdi => {
4 const getMessages = () => { 4 const getMessages = () => {
5 const badges = [...document.querySelectorAll(NOTIFICATION_BADGE_CLASS)]; 5 const badges = [...document.querySelectorAll(NOTIFICATION_BADGE_CLASS)];
6 const messages = badges.reduce((currentValue, element) => currentValue + Number(element.innerText), 0); 6 const messages = badges.reduce(
7 (currentValue, element) => currentValue + Number(element.textContent),
8 0,
9 );
7 10
8 Ferdi.setBadge(messages); 11 Ferdi.setBadge(messages);
9 }; 12 };
diff --git a/recipes/jollor/webview.js b/recipes/jollor/webview.js
index 695a7fa..693e454 100644
--- a/recipes/jollor/webview.js
+++ b/recipes/jollor/webview.js
@@ -1,12 +1,16 @@
1const _path = _interopRequireDefault(require('path')); 1const _path = _interopRequireDefault(require('path'));
2 2
3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3function _interopRequireDefault(obj) {
4 return obj && obj.__esModule ? obj : { default: obj };
5}
4 6
5module.exports = (Ferdi) => { 7module.exports = Ferdi => {
6 const getMessages = () => { 8 const getMessages = () => {
7 const count = document.querySelector('.user-menu-message-item-count').innerHTML; 9 const count = document.querySelector(
10 '.user-menu-message-item-count',
11 ).textContent;
8 Ferdi.setBadge(count); 12 Ferdi.setBadge(count);
9 } 13 };
10 14
11 Ferdi.loop(getMessages); 15 Ferdi.loop(getMessages);
12 16
diff --git a/recipes/keybase.io/index.js b/recipes/keybase.io/index.js
index 3ffa657..ef5d5bc 100644
--- a/recipes/keybase.io/index.js
+++ b/recipes/keybase.io/index.js
@@ -1,2 +1 @@
1module.exports = (Ferdi) => class LineMe extends Ferdi { module.exports = (Ferdi) => class LineMe extends Ferdi {};
2};
diff --git a/recipes/lark/webview.js b/recipes/lark/webview.js
index 4e3a614..dfccccf 100644
--- a/recipes/lark/webview.js
+++ b/recipes/lark/webview.js
@@ -1,15 +1,19 @@
1const _path = _interopRequireDefault(require('path')); 1const _path = _interopRequireDefault(require('path'));
2 2
3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3function _interopRequireDefault(obj) {
4 return obj && obj.__esModule ? obj : { default: obj };
5}
4 6
5module.exports = (Ferdi) => { 7module.exports = Ferdi => {
6 const getMessages = () => { 8 const getMessages = () => {
7 const ele = document.querySelectorAll('.larkc-badge-count.navbarMenu-badge'); 9 const ele = document.querySelectorAll(
8 if (!ele.length) { 10 '.larkc-badge-count.navbarMenu-badge',
11 );
12 if (ele.length === 0) {
9 Ferdi.setBadge(0); 13 Ferdi.setBadge(0);
10 return; 14 return;
11 } 15 }
12 Ferdi.setBadge(ele[0].innerHTML); 16 Ferdi.setBadge(ele[0].textContent);
13 }; 17 };
14 18
15 Ferdi.loop(getMessages); 19 Ferdi.loop(getMessages);
diff --git a/recipes/lastpass/webview.js b/recipes/lastpass/webview.js
index 8bcf058..df3bd77 100644
--- a/recipes/lastpass/webview.js
+++ b/recipes/lastpass/webview.js
@@ -1,9 +1,13 @@
1const _path = _interopRequireDefault(require('path')); 1const _path = _interopRequireDefault(require('path'));
2 2
3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3function _interopRequireDefault(obj) {
4 return obj && obj.__esModule ? obj : { default: obj };
5}
4 6
5setTimeout(() => { 7setTimeout(() => {
6 if (document.querySelector('body').innerHTML.includes('Google Chrome 36+')) { 8 if (
9 document.querySelector('body').textContent.includes('Google Chrome 36+')
10 ) {
7 window.location.reload(); 11 window.location.reload();
8 } 12 }
9}, 1000); 13}, 1000);
@@ -13,8 +17,8 @@ module.exports = (Ferdi, settings) => {
13 const elements = document.querySelectorAll('.CxUIE, .unread'); 17 const elements = document.querySelectorAll('.CxUIE, .unread');
14 let count = 0; 18 let count = 0;
15 19
16 for (let i = 0; i < elements.length; i += 1) { 20 for (const element of elements) {
17 if (elements[i].querySelectorAll('*[data-icon="muted"]').length === 0) { 21 if (element.querySelectorAll('*[data-icon="muted"]').length === 0) {
18 count += 1; 22 count += 1;
19 } 23 }
20 } 24 }
@@ -23,7 +27,15 @@ module.exports = (Ferdi, settings) => {
23 }; 27 };
24 28
25 window.addEventListener('beforeunload', async () => { 29 window.addEventListener('beforeunload', async () => {
26 Ferdi.clearStorageData(settings.id, { storages: ['appcache', 'serviceworkers', 'cachestorage', 'websql', 'indexdb'] }); 30 Ferdi.clearStorageData(settings.id, {
31 storages: [
32 'appcache',
33 'serviceworkers',
34 'cachestorage',
35 'websql',
36 'indexdb',
37 ],
38 });
27 Ferdi.releaseServiceWorkers(); 39 Ferdi.releaseServiceWorkers();
28 }); 40 });
29 41
diff --git a/recipes/line-me/index.js b/recipes/line-me/index.js
index 3ffa657..ef5d5bc 100644
--- a/recipes/line-me/index.js
+++ b/recipes/line-me/index.js
@@ -1,2 +1 @@
1module.exports = (Ferdi) => class LineMe extends Ferdi { module.exports = (Ferdi) => class LineMe extends Ferdi {};
2};
diff --git a/recipes/linkedin/webview.js b/recipes/linkedin/webview.js
index 8d1afc8..ae392f5 100644
--- a/recipes/linkedin/webview.js
+++ b/recipes/linkedin/webview.js
@@ -3,11 +3,15 @@ module.exports = Ferdi => {
3 let count = 0; 3 let count = 0;
4 4
5 if (window.location.pathname.includes('messaging')) { 5 if (window.location.pathname.includes('messaging')) {
6 count = document.querySelectorAll('.msg-conversation-card__unread-count').length; 6 count = document.querySelectorAll(
7 '.msg-conversation-card__unread-count',
8 ).length;
7 } else { 9 } else {
8 const element = document.querySelector('.nav-item--messaging .nav-item__badge-count'); 10 const element = document.querySelector(
11 '.nav-item--messaging .nav-item__badge-count',
12 );
9 if (element) { 13 if (element) {
10 count = Ferdi.safeParseInt(element.innerHTML); 14 count = Ferdi.safeParseInt(element.textContent);
11 } 15 }
12 } 16 }
13 17
diff --git a/recipes/mattermost/index.js b/recipes/mattermost/index.js
index 290cdbc..3a9a791 100644
--- a/recipes/mattermost/index.js
+++ b/recipes/mattermost/index.js
@@ -8,8 +8,8 @@ module.exports = Ferdi => class Mattermost extends Ferdi {
8 }, 8 },
9 }); 9 });
10 return resp.status.toString().startsWith('2'); 10 return resp.status.toString().startsWith('2');
11 } catch (err) { 11 } catch (error) {
12 console.error(err); 12 console.error(error);
13 } 13 }
14 14
15 return false; 15 return false;
diff --git a/recipes/messenger/webview.js b/recipes/messenger/webview.js
index 5b2f2ad..d2d85fe 100644
--- a/recipes/messenger/webview.js
+++ b/recipes/messenger/webview.js
@@ -33,7 +33,7 @@ module.exports = Ferdi => {
33 */ 33 */
34 const messageRequestsElement = document.querySelector('._5nxf'); 34 const messageRequestsElement = document.querySelector('._5nxf');
35 if (messageRequestsElement) { 35 if (messageRequestsElement) {
36 count += Ferdi.safeParseInt(messageRequestsElement.innerHTML); 36 count += Ferdi.safeParseInt(messageRequestsElement.textContent);
37 } 37 }
38 38
39 Ferdi.setBadge(count); 39 Ferdi.setBadge(count);
@@ -44,7 +44,7 @@ module.exports = Ferdi => {
44 localStorage.setItem( 44 localStorage.setItem(
45 '_cs_desktopNotifsEnabled', 45 '_cs_desktopNotifsEnabled',
46 JSON.stringify({ 46 JSON.stringify({
47 __t: new Date().getTime(), 47 __t: Date.now(),
48 __v: true, 48 __v: true,
49 }), 49 }),
50 ); 50 );
diff --git a/recipes/mewe/webview.js b/recipes/mewe/webview.js
index fcf5918..84438f2 100644
--- a/recipes/mewe/webview.js
+++ b/recipes/mewe/webview.js
@@ -1,11 +1,17 @@
1const _path = _interopRequireDefault(require('path')); 1const _path = _interopRequireDefault(require('path'));
2 2
3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3function _interopRequireDefault(obj) {
4 return obj && obj.__esModule ? obj : { default: obj };
5}
4 6
5module.exports = Ferdi => { 7module.exports = Ferdi => {
6 const calculateTotalDirectMessages = () => 8 const calculateTotalDirectMessages = () =>
7 Array.from(document.getElementsByClassName('chats-list-element')) 9 [...document.querySelectorAll('.chats-list-element')]
8 .map(el => Ferdi.safeParseInt(el.querySelector('.m-indicator .number').innerHTML)) 10 .map(el =>
11 Ferdi.safeParseInt(
12 el.querySelector('.m-indicator .number').textContent,
13 ),
14 )
9 .reduce((curr, prev) => curr + prev, 0); 15 .reduce((curr, prev) => curr + prev, 0);
10 16
11 Ferdi.loop(() => Ferdi.setBadge(calculateTotalDirectMessages())); 17 Ferdi.loop(() => Ferdi.setBadge(calculateTotalDirectMessages()));
diff --git a/recipes/misskey/index.js b/recipes/misskey/index.js
index 5805c37..51960a6 100644
--- a/recipes/misskey/index.js
+++ b/recipes/misskey/index.js
@@ -22,8 +22,8 @@ module.exports = Ferdi =>
22 'notesCount', 22 'notesCount',
23 'originalNotesCount', 23 'originalNotesCount',
24 ].reduce(r => r && Object.hasOwnProperty.call(data, 'uri'), true); 24 ].reduce(r => r && Object.hasOwnProperty.call(data, 'uri'), true);
25 } catch (err) { 25 } catch (error) {
26 console.error(err); 26 console.error(error);
27 } 27 }
28 return false; 28 return false;
29 } 29 }
diff --git a/recipes/monday/webview.js b/recipes/monday/webview.js
index 15f6335..aa0d9a8 100755
--- a/recipes/monday/webview.js
+++ b/recipes/monday/webview.js
@@ -8,8 +8,8 @@ module.exports = Ferdi => {
8 8
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 (const counter of counters) {
12 count += Ferdi.safeParseInt(counters[i].textContent); 12 count += Ferdi.safeParseInt(counter.textContent);
13 } 13 }
14 14
15 Ferdi.setBadge(count); 15 Ferdi.setBadge(count);
diff --git a/recipes/msteams/webview.js b/recipes/msteams/webview.js
index 0345105..1dc5aee 100644
--- a/recipes/msteams/webview.js
+++ b/recipes/msteams/webview.js
@@ -1,16 +1,22 @@
1const _path = _interopRequireDefault(require('path')); 1const _path = _interopRequireDefault(require('path'));
2 2
3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3function _interopRequireDefault(obj) {
4 return obj && obj.__esModule ? obj : { default: obj };
5}
4 6
5module.exports = Ferdi => { 7module.exports = Ferdi => {
6 const getMessages = () => { 8 const getMessages = () => {
7 let messages = 0; 9 let messages = 0;
8 const badge = document.querySelector('.activity-badge.dot-activity-badge .activity-badge'); 10 const badge = document.querySelector(
11 '.activity-badge.dot-activity-badge .activity-badge',
12 );
9 if (badge) { 13 if (badge) {
10 messages = Ferdi.safeParseInt(badge.innerHTML); 14 messages = Ferdi.safeParseInt(badge.textContent);
11 } 15 }
12 16
13 const indirectMessages = document.querySelectorAll('[class*=channel-anchor][class*=ts-unread-channel]').length; 17 const indirectMessages = document.querySelectorAll(
18 '[class*=channel-anchor][class*=ts-unread-channel]',
19 ).length;
14 20
15 Ferdi.setBadge(messages, indirectMessages); 21 Ferdi.setBadge(messages, indirectMessages);
16 }; 22 };
diff --git a/recipes/mstodo/index.js b/recipes/mstodo/index.js
index 73107f7..c0a684b 100644
--- a/recipes/mstodo/index.js
+++ b/recipes/mstodo/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class mstodo extends Ferdi { module.exports = Ferdi => class mstodo extends Ferdi {};
2};
diff --git a/recipes/mstodo/webview.js b/recipes/mstodo/webview.js
index 9f4efef..1692a4d 100644
--- a/recipes/mstodo/webview.js
+++ b/recipes/mstodo/webview.js
@@ -7,8 +7,8 @@ module.exports = Ferdi => {
7 const elements = document.querySelectorAll('.taskItem'); 7 const elements = document.querySelectorAll('.taskItem');
8 let count = 0; 8 let count = 0;
9 9
10 for (let i = 0; i < elements.length; i += 1) { 10 for (const element of elements) {
11 if (elements[i].querySelectorAll('.completed').length === 0) { 11 if (element.querySelectorAll('.completed').length === 0) {
12 count += 1; 12 count += 1;
13 } 13 }
14 } 14 }
diff --git a/recipes/mysms/webview.js b/recipes/mysms/webview.js
index 3f3415a..1878120 100644
--- a/recipes/mysms/webview.js
+++ b/recipes/mysms/webview.js
@@ -1,10 +1,14 @@
1module.exports = Ferdi => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 const elements = document.getElementsByClassName('unread'); 3 const elements = document.querySelectorAll('.unread');
4 4
5 let count = 0; 5 let count = 0;
6 for (let i = 0; i < elements.length; i++) { 6 for (const element of elements) {
7 if (Ferdi.safeParseInt(elements[i].innerText.replace(/[^0-9.]/g, '')) > 0) { 7 if (
8 Ferdi.safeParseInt(
9 element.textContent && element.textContent.replace(/[^\d.]/g, ''),
10 ) > 0
11 ) {
8 count++; // count 1 per channel with messages 12 count++; // count 1 per channel with messages
9 } 13 }
10 } 14 }
diff --git a/recipes/nextcloud-talk/webview.js b/recipes/nextcloud-talk/webview.js
index 1b55203..49a3e29 100644
--- a/recipes/nextcloud-talk/webview.js
+++ b/recipes/nextcloud-talk/webview.js
@@ -17,11 +17,10 @@ module.exports = Ferdi => {
17 17
18 let indirect = 0; 18 let indirect = 0;
19 19
20 document.querySelectorAll('.app-navigation-entry__counter').forEach( 20 for (const counter of document.querySelectorAll('.app-navigation-entry__counter')) {
21 (counter) => {
22 indirect += Number(counter.textContent); 21 indirect += Number(counter.textContent);
23 }, 22 }
24 ); 23
25 Ferdi.setBadge(direct, indirect); 24 Ferdi.setBadge(direct, indirect);
26 }; 25 };
27 26
diff --git a/recipes/nextdoor/webview.js b/recipes/nextdoor/webview.js
index 503d9a4..809e368 100644
--- a/recipes/nextdoor/webview.js
+++ b/recipes/nextdoor/webview.js
@@ -1,9 +1,11 @@
1module.exports = Ferdi => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 let unread = 0; 3 let unread = 0;
4 const notificationBadge = document.getElementsByClassName('notification-badge')[0]; 4 const notificationBadge = document.querySelectorAll(
5 '.notification-badge',
6 )[0];
5 if (notificationBadge != undefined) { 7 if (notificationBadge != undefined) {
6 unread = Ferdi.safeParseInt(notificationBadge.innerText); 8 unread = Ferdi.safeParseInt(notificationBadge.textContent);
7 } 9 }
8 Ferdi.setBadge(unread); 10 Ferdi.setBadge(unread);
9 }; 11 };
diff --git a/recipes/notion/webview.js b/recipes/notion/webview.js
index cd8f566..b209e75 100644
--- a/recipes/notion/webview.js
+++ b/recipes/notion/webview.js
@@ -1,13 +1,15 @@
1module.exports = (Ferdi) => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 let direct = 0; 3 let direct = 0;
4 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(
5 '.notion-sidebar-container > div > div > div > :nth-child(4) > :nth-child(2) > div > :nth-child(3) > div > div',
6 );
5 if (badgeDiv) { 7 if (badgeDiv) {
6 direct = Ferdi.safeParseInt(badgeDiv.innerText); 8 direct = Ferdi.safeParseInt(badgeDiv.textContent);
7 } 9 }
8 10
9 Ferdi.setBadge(direct); 11 Ferdi.setBadge(direct);
10 } 12 };
11 13
12 Ferdi.loop(getMessages); 14 Ferdi.loop(getMessages);
13}; 15};
diff --git a/recipes/odoo/index.js b/recipes/odoo/index.js
index 23328b9..ad78a76 100644
--- a/recipes/odoo/index.js
+++ b/recipes/odoo/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class Odoo extends Ferdi { module.exports = Ferdi => class Odoo extends Ferdi {};
2};
diff --git a/recipes/office365-owa/webview.js b/recipes/office365-owa/webview.js
index b897c8d..17649fd 100644
--- a/recipes/office365-owa/webview.js
+++ b/recipes/office365-owa/webview.js
@@ -1,12 +1,14 @@
1module.exports = (Ferdi, settings) => { 1module.exports = (Ferdi, settings) => {
2 const collectCounts = (selector) => { 2 const collectCounts = selector => {
3 let unreadCount = 0; 3 let unreadCount = 0;
4 const foldersElement = document.querySelector(selector); 4 const foldersElement = document.querySelector(selector);
5 if (foldersElement) { 5 if (foldersElement) {
6 const allScreenReaders = foldersElement.querySelectorAll('span.screenReaderOnly'); 6 const allScreenReaders = foldersElement.querySelectorAll(
7 'span.screenReaderOnly',
8 );
7 for (const child of allScreenReaders) { 9 for (const child of allScreenReaders) {
8 if (child.previousSibling) { 10 if (child.previousSibling) {
9 unreadCount += Ferdi.safeParseInt(child.previousSibling.innerText); 11 unreadCount += Ferdi.safeParseInt(child.previousSibling.textContent);
10 } 12 }
11 } 13 }
12 } 14 }
@@ -17,22 +19,24 @@ module.exports = (Ferdi, settings) => {
17 let directUnreadCount = 0; 19 let directUnreadCount = 0;
18 let indirectUnreadCount = 0; 20 let indirectUnreadCount = 0;
19 21
20 if (location.pathname.match(/\/owa/)) { 22 if (/\/owa/.test(location.pathname)) {
21 // classic app 23 // classic app
22 directUnreadCount = Ferdi.safeParseInt(jQuery("span[title*='Inbox'] + div > span").first().text()); 24 directUnreadCount = Ferdi.safeParseInt(
25 document.querySelectorAll("span[title*='Inbox'] + div > span")[0]
26 .textContent,
27 );
23 } else { 28 } else {
24 // new app 29 // new app
25 if (settings.onlyShowFavoritesInUnreadCount === true) { 30 directUnreadCount =
26 directUnreadCount = collectCounts('div[role=tree]:nth-child(2)'); // favorites 31 settings.onlyShowFavoritesInUnreadCount === true
27 } else { 32 ? collectCounts('div[role=tree]:nth-child(2)')
28 directUnreadCount = collectCounts('div[role=tree]:nth-child(3)'); // folders 33 : collectCounts('div[role=tree]:nth-child(3)');
29 }
30 34
31 indirectUnreadCount = collectCounts('div[role=tree]:nth-child(4)'); // groups 35 indirectUnreadCount = collectCounts('div[role=tree]:nth-child(4)'); // groups
32 } 36 }
33 37
34 Ferdi.setBadge(directUnreadCount, indirectUnreadCount); 38 Ferdi.setBadge(directUnreadCount, indirectUnreadCount);
35 } 39 };
36 40
37 Ferdi.loop(getMessages); 41 Ferdi.loop(getMessages);
38}; 42};
diff --git a/recipes/onenote/index.js b/recipes/onenote/index.js
index b322187..b6a0630 100644
--- a/recipes/onenote/index.js
+++ b/recipes/onenote/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class onenote extends Ferdi { module.exports = Ferdi => class onenote extends Ferdi {};
2};
diff --git a/recipes/pinterest/index.js b/recipes/pinterest/index.js
index f48f249..2495a63 100644
--- a/recipes/pinterest/index.js
+++ b/recipes/pinterest/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class pinterest extends Ferdi { module.exports = Ferdi => class pinterest extends Ferdi {};
2};
diff --git a/recipes/pivotal-tracker/webview.js b/recipes/pivotal-tracker/webview.js
index e4899a5..1775292 100644
--- a/recipes/pivotal-tracker/webview.js
+++ b/recipes/pivotal-tracker/webview.js
@@ -1,10 +1,10 @@
1module.exports = (Ferdi) => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 const bell = document.querySelectorAll('#view65 > span')[0]; 3 const bell = document.querySelectorAll('#view65 > span')[0];
4 if (bell) { 4 if (bell) {
5 Ferdi.setBadge(bell.innerText); 5 Ferdi.setBadge(bell.textContent);
6 } 6 }
7 } 7 };
8 8
9 Ferdi.loop(getMessages); 9 Ferdi.loop(getMessages);
10}; 10};
diff --git a/recipes/plek/webview.js b/recipes/plek/webview.js
index bc6d5aa..0ac618b 100644
--- a/recipes/plek/webview.js
+++ b/recipes/plek/webview.js
@@ -1,20 +1,22 @@
1const _path = _interopRequireDefault(require('path')); 1const _path = _interopRequireDefault(require('path'));
2 2
3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3function _interopRequireDefault(obj) {
4 return obj && obj.__esModule ? obj : { default: obj };
5}
4 6
5module.exports = (Ferdi) => { 7module.exports = Ferdi => {
6 const getMessages = () => { 8 const getMessages = () => {
7 let directMessages = 0; 9 let directMessages = 0;
8 let indirectMessages = 0; 10 let indirectMessages = 0;
9 11
10 const elements = document.querySelectorAll('.counter'); 12 const elements = document.querySelectorAll('.counter');
11 for (let i = 0; i < elements.length; i += 1) { 13 for (const element of elements) {
12 directMessages += Ferdi.safeParseInt(elements[i].innerText); 14 directMessages += Ferdi.safeParseInt(element.textContent);
13 } 15 }
14 16
15 const elements2 = document.querySelectorAll('.badge'); 17 const elements2 = document.querySelectorAll('.badge');
16 for (let i = 0; i < elements2.length; i += 1) { 18 for (const element of elements2) {
17 indirectMessages += Ferdi.safeParseInt(elements2[i].innerText); 19 indirectMessages += Ferdi.safeParseInt(element.textContent);
18 } 20 }
19 21
20 Ferdi.setBadge(directMessages, indirectMessages); 22 Ferdi.setBadge(directMessages, indirectMessages);
diff --git a/recipes/pleroma/index.js b/recipes/pleroma/index.js
index c6cf368..06a6e2d 100644
--- a/recipes/pleroma/index.js
+++ b/recipes/pleroma/index.js
@@ -6,9 +6,9 @@ module.exports = Ferdi => class Pleroma extends Ferdi {
6 }); 6 });
7 const data = await resp.json(); 7 const data = await resp.json();
8 const version = data.version; 8 const version = data.version;
9 return typeof (version) === 'string' && version.indexOf('Pleroma') >= 0; 9 return typeof (version) === 'string' && version.includes('Pleroma');
10 } catch (err) { 10 } catch (error) {
11 console.log('Pleroma server validation error', err); 11 console.log('Pleroma server validation error', error);
12 } 12 }
13 return false; 13 return false;
14 } 14 }
diff --git a/recipes/pleroma/webview.js b/recipes/pleroma/webview.js
index 2ba184e..c7a6530 100644
--- a/recipes/pleroma/webview.js
+++ b/recipes/pleroma/webview.js
@@ -15,8 +15,8 @@ const getInstanceConfig = async () => {
15 ); 15 );
16 const pleromaFeConfig = frontendConfig.pleroma_fe || {}; 16 const pleromaFeConfig = frontendConfig.pleroma_fe || {};
17 return { ...staticConfig, ...pleromaFeConfig }; 17 return { ...staticConfig, ...pleromaFeConfig };
18 } catch (e) { 18 } catch (error) {
19 console.log('Failed to load dynamic frontend configuration', e); 19 console.log('Failed to load dynamic frontend configuration', error);
20 return staticConfig; 20 return staticConfig;
21 } 21 }
22}; 22};
@@ -161,8 +161,8 @@ module.exports = Ferdi => {
161 } 161 }
162 }); 162 });
163 }, 163 },
164 e => { 164 error => {
165 console.log('Failed to load instance logo', e); 165 console.log('Failed to load instance logo', error);
166 Ferdi.loop(getMessages); 166 Ferdi.loop(getMessages);
167 }, 167 },
168 ); 168 );
diff --git a/recipes/plurk/webview.js b/recipes/plurk/webview.js
index c79853d..09f15da 100644
--- a/recipes/plurk/webview.js
+++ b/recipes/plurk/webview.js
@@ -6,14 +6,14 @@ module.exports = Ferdi => {
6 const re = document.querySelector('#noti_re_count'); 6 const re = document.querySelector('#noti_re_count');
7 7
8 if (np) { 8 if (np) {
9 direct += Ferdi.safeParseInt(np.innerHTML); 9 direct += Ferdi.safeParseInt(np.textContent);
10 } 10 }
11 if (re) { 11 if (re) {
12 direct += Ferdi.safeParseInt(re.innerHTML); 12 direct += Ferdi.safeParseInt(re.textContent);
13 } 13 }
14 14
15 Ferdi.setBadge(direct); 15 Ferdi.setBadge(direct);
16 } 16 };
17 17
18 Ferdi.loop(getMessages, 10000); 18 Ferdi.loop(getMessages, 10_000);
19}; 19};
diff --git a/recipes/podio/webview.js b/recipes/podio/webview.js
index 1bfa60d..0a0c31e 100644
--- a/recipes/podio/webview.js
+++ b/recipes/podio/webview.js
@@ -1,10 +1,12 @@
1const _path = _interopRequireDefault(require('path')); 1const _path = _interopRequireDefault(require('path'));
2 2
3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3function _interopRequireDefault(obj) {
4 return obj && obj.__esModule ? obj : { default: obj };
5}
4 6
5module.exports = (Ferdi) => { 7module.exports = Ferdi => {
6 const getMessages = () => { 8 const getMessages = () => {
7 const updates = document.getElementsByClassName('counter')[0].innerHTML; 9 const updates = document.querySelectorAll('.counter')[0].textContent;
8 Ferdi.setBadge(updates, 0); 10 Ferdi.setBadge(updates, 0);
9 }; 11 };
10 12
diff --git a/recipes/pomodoro-tracker/index.js b/recipes/pomodoro-tracker/index.js
index 6bc8da9..52abf4d 100644
--- a/recipes/pomodoro-tracker/index.js
+++ b/recipes/pomodoro-tracker/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class pomodorotracker extends Ferdi { module.exports = Ferdi => class pomodorotracker extends Ferdi {};
2};
diff --git a/recipes/producthunt/webview.js b/recipes/producthunt/webview.js
index c03de9b..7f6c74b 100644
--- a/recipes/producthunt/webview.js
+++ b/recipes/producthunt/webview.js
@@ -1,7 +1,13 @@
1module.exports = (Ferdi) => { 1module.exports = Ferdi => {
2 const notificationsSelector = document.querySelector(
3 '[class*=header_] [class*=content_] [class*=actions_] [class*=notificationsButton_]',
4 );
5
2 const getMessages = () => { 6 const getMessages = () => {
3 Ferdi.setBadge(document.querySelector('[class*=header_] [class*=content_] [class*=actions_] [class*=notificationsButton_]').innerText) 7 if (notificationsSelector) {
4 } 8 Ferdi.setBadge(notificationsSelector.textContent);
9 }
10 };
5 11
6 Ferdi.loop(getMessages) 12 Ferdi.loop(getMessages);
7} 13};
diff --git a/recipes/proton-mail/webview.js b/recipes/proton-mail/webview.js
index ed66db5..395b779 100644
--- a/recipes/proton-mail/webview.js
+++ b/recipes/proton-mail/webview.js
@@ -4,10 +4,13 @@ module.exports = Ferdi => {
4 if (!element) { 4 if (!element) {
5 return; 5 return;
6 } 6 }
7 const text = element.innerText; 7 const text = element.textContent;
8 const count = Ferdi.safeParseInt(text.substring(1, text.length - 1)); 8 if (text) {
9 Ferdi.setBadge(count); 9 // eslint-disable-next-line unicorn/prefer-string-slice
10 } 10 const count = Ferdi.safeParseInt(text.substring(1, text.length - 1));
11 Ferdi.setBadge(count);
12 }
13 };
11 14
12 Ferdi.loop(getMessages); 15 Ferdi.loop(getMessages);
13}; 16};
diff --git a/recipes/pulsesms/webview.js b/recipes/pulsesms/webview.js
index 48bb2ad..d6d123c 100644
--- a/recipes/pulsesms/webview.js
+++ b/recipes/pulsesms/webview.js
@@ -1,7 +1,9 @@
1module.exports = (Ferdi) => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 Ferdi.setBadge(document.querySelector('#unread_count').innerHTML.replace(/\s/g, '')); 3 Ferdi.setBadge(
4 } 4 document.querySelector('#unread_count').textContent.replace(/\s/g, ''),
5 );
6 };
5 7
6 Ferdi.loop(getMessages); 8 Ferdi.loop(getMessages);
7}; 9};
diff --git a/recipes/reddit/webview.js b/recipes/reddit/webview.js
index 5095ba1..8d165aa 100644
--- a/recipes/reddit/webview.js
+++ b/recipes/reddit/webview.js
@@ -12,16 +12,21 @@ module.exports = Ferdi => {
12 let count = 0; 12 let count = 0;
13 13
14 if (elements[0]) { 14 if (elements[0]) {
15 count = Ferdi.safeParseInt(elements[0].innerHTML); 15 count = Ferdi.safeParseInt(elements[0].textContent);
16 } 16 }
17 17
18 Ferdi.setBadge(count); 18 Ferdi.setBadge(count);
19 }; 19 };
20 20
21 if (document.querySelectorAll('.promotedlink').length > 0) { 21 if (document.querySelectorAll('.promotedlink').length > 0) {
22 document.querySelectorAll('.promotedlink').forEach(sponsoredLink => { 22 for (const sponsoredLink of document.querySelectorAll('.promotedlink')) {
23 sponsoredLink.parentElement.parentElement.style.display = 'none'; 23 if (
24 }); 24 sponsoredLink.parentElement &&
25 sponsoredLink.parentElement.parentElement
26 ) {
27 sponsoredLink.parentElement.parentElement.style.display = 'none';
28 }
29 }
25 } 30 }
26 31
27 Ferdi.loop(getMessages); 32 Ferdi.loop(getMessages);
@@ -41,8 +46,10 @@ module.exports = Ferdi => {
41 const btn = document.querySelector('[role=menu] button button'); 46 const btn = document.querySelector('[role=menu] button button');
42 const checked = btn && btn.getAttribute('aria-checked') === 'true'; 47 const checked = btn && btn.getAttribute('aria-checked') === 'true';
43 48
44 if ((checked && !isEnabled) || (!checked && isEnabled)) { 49 if (
45 // Click the button to switch between modes 50 ((checked && !isEnabled) || (!checked && isEnabled)) && // Click the button to switch between modes
51 btn
52 ) {
46 btn.click(); 53 btn.click();
47 } 54 }
48 }, 50); 55 }, 50);
diff --git a/recipes/redditchat/webview.js b/recipes/redditchat/webview.js
index 14f7f6c..19b306c 100644
--- a/recipes/redditchat/webview.js
+++ b/recipes/redditchat/webview.js
@@ -1,7 +1,6 @@
1module.exports = Ferdi => { 1module.exports = Ferdi => {
2 // Regular expression for (*) or (1), will extract the asterisk or the number 2 // Regular expression for (*) or (1), will extract the asterisk or the number
3 // eslint-disable-next-line no-useless-escape 3 const titleRegEx = /^\(([\d*])\)/;
4 const titleRegEx = /^\(([\*\d])\)/;
5 const getMessages = function unreadCount() { 4 const getMessages = function unreadCount() {
6 let directCount = 0; 5 let directCount = 0;
7 let indirectCount = 0; 6 let indirectCount = 0;
diff --git a/recipes/riseup/index.js b/recipes/riseup/index.js
index b4e1380..d24be1d 100644
--- a/recipes/riseup/index.js
+++ b/recipes/riseup/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class riseupnet extends Ferdi { module.exports = Ferdi => class riseupnet extends Ferdi {};
2};
diff --git a/recipes/riseup/webview.js b/recipes/riseup/webview.js
index 0fb21f8..b3a78cf 100644
--- a/recipes/riseup/webview.js
+++ b/recipes/riseup/webview.js
@@ -1,9 +1,9 @@
1module.exports = Ferdi => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 let unread = 0; 3 let unread = 0;
4 const notificationBadge = document.getElementsByClassName('unreadcount')[0]; 4 const notificationBadge = document.querySelectorAll('.unreadcount')[0];
5 if (notificationBadge != undefined) { 5 if (notificationBadge != undefined) {
6 unread = Ferdi.safeParseInt(notificationBadge.innerText); 6 unread = Ferdi.safeParseInt(notificationBadge.textContent);
7 } 7 }
8 Ferdi.setBadge(unread); 8 Ferdi.setBadge(unread);
9 }; 9 };
diff --git a/recipes/rocketchat/index.js b/recipes/rocketchat/index.js
index 062b5ec..97de4fe 100644
--- a/recipes/rocketchat/index.js
+++ b/recipes/rocketchat/index.js
@@ -9,8 +9,8 @@ module.exports = Ferdi => class RocketChat extends Ferdi {
9 }); 9 });
10 const status = resp.status.toString(); 10 const status = resp.status.toString();
11 return status.startsWith('2') || status.startsWith('3'); 11 return status.startsWith('2') || status.startsWith('3');
12 } catch (err) { 12 } catch (error) {
13 console.error(err); 13 console.error(error);
14 } 14 }
15 15
16 return false; 16 return false;
diff --git a/recipes/rocketchat/webview.js b/recipes/rocketchat/webview.js
index 5ed7866..95ada6f 100644
--- a/recipes/rocketchat/webview.js
+++ b/recipes/rocketchat/webview.js
@@ -33,17 +33,17 @@ module.exports = Ferdi => {
33 33
34 const xmlhttp = new XMLHttpRequest(); 34 const xmlhttp = new XMLHttpRequest();
35 35
36 xmlhttp.onreadystatechange = function () { 36 xmlhttp.addEventListener('readystatechange', function () {
37 if (this.readyState != 4 || this.status != 200) { 37 if (this.readyState != 4 || this.status != 200) {
38 return; 38 return;
39 } 39 }
40 40
41 const response = JSON.parse(this.responseText); 41 const response = JSON.parse(this.responseText);
42 42
43 if (response.icons.length >= 1) { 43 if (response.icons.length > 0) {
44 Ferdi.setAvatarImage(`${window.location.protocol}//${window.location.host}${response.icons[0].src}`); 44 Ferdi.setAvatarImage(`${window.location.protocol}//${window.location.host}${response.icons[0].src}`);
45 } 45 }
46 }; 46 });
47 47
48 xmlhttp.open('GET', manifestUrl, true); 48 xmlhttp.open('GET', manifestUrl, true);
49 xmlhttp.send(); 49 xmlhttp.send();
diff --git a/recipes/roundcube/webview.js b/recipes/roundcube/webview.js
index c59da2f..08c6a95 100644
--- a/recipes/roundcube/webview.js
+++ b/recipes/roundcube/webview.js
@@ -2,8 +2,8 @@ module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
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 (const directElement of directElements) {
6 direct += Ferdi.safeParseInt(directElements[i].innerHTML); 6 direct += Ferdi.safeParseInt(directElement.textContent);
7 } 7 }
8 Ferdi.setBadge(direct); 8 Ferdi.setBadge(direct);
9 }; 9 };
diff --git a/recipes/scribens/index.js b/recipes/scribens/index.js
index 3851554..ae7e2d2 100644
--- a/recipes/scribens/index.js
+++ b/recipes/scribens/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class Scribens extends Ferdi { module.exports = Ferdi => class Scribens extends Ferdi {};
2};
diff --git a/recipes/scrumpy/webview.js b/recipes/scrumpy/webview.js
index 5c762e4..46f6424 100644
--- a/recipes/scrumpy/webview.js
+++ b/recipes/scrumpy/webview.js
@@ -1,8 +1,12 @@
1module.exports = Ferdi => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 const notifications = document.querySelector('.c-notifications-dropdown__count') 3 const notifications = document.querySelector(
4 Ferdi.setBadge(notifications.innerText); 4 '.c-notifications-dropdown__count',
5 }; 5 );
6 if (notifications) {
7 Ferdi.setBadge(notifications.textContent);
8 }
9 };
6 10
7 Ferdi.loop(getMessages); 11 Ferdi.loop(getMessages);
8}; 12};
diff --git a/recipes/simplenote/index.js b/recipes/simplenote/index.js
index 18db071..15ecf81 100644
--- a/recipes/simplenote/index.js
+++ b/recipes/simplenote/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class simplenote extends Ferdi { module.exports = Ferdi => class simplenote extends Ferdi {};
2};
diff --git a/recipes/simplenote/webview.js b/recipes/simplenote/webview.js
index 8d1afc8..ae392f5 100644
--- a/recipes/simplenote/webview.js
+++ b/recipes/simplenote/webview.js
@@ -3,11 +3,15 @@ module.exports = Ferdi => {
3 let count = 0; 3 let count = 0;
4 4
5 if (window.location.pathname.includes('messaging')) { 5 if (window.location.pathname.includes('messaging')) {
6 count = document.querySelectorAll('.msg-conversation-card__unread-count').length; 6 count = document.querySelectorAll(
7 '.msg-conversation-card__unread-count',
8 ).length;
7 } else { 9 } else {
8 const element = document.querySelector('.nav-item--messaging .nav-item__badge-count'); 10 const element = document.querySelector(
11 '.nav-item--messaging .nav-item__badge-count',
12 );
9 if (element) { 13 if (element) {
10 count = Ferdi.safeParseInt(element.innerHTML); 14 count = Ferdi.safeParseInt(element.textContent);
11 } 15 }
12 } 16 }
13 17
diff --git a/recipes/slack/webview.js b/recipes/slack/webview.js
index 23cede8..f436ba9 100644
--- a/recipes/slack/webview.js
+++ b/recipes/slack/webview.js
@@ -24,7 +24,7 @@ module.exports = Ferdi => {
24 24
25 if (icon) { 25 if (icon) {
26 bgUrl = window.getComputedStyle(icon, null).getPropertyValue('background-image'); 26 bgUrl = window.getComputedStyle(icon, null).getPropertyValue('background-image');
27 bgUrl = /^url\((['"]?)(.*)\1\)$/.exec(bgUrl); 27 bgUrl = /^url\((["']?)(.*)\1\)$/.exec(bgUrl);
28 bgUrl = bgUrl ? bgUrl[2] : ''; 28 bgUrl = bgUrl ? bgUrl[2] : '';
29 } 29 }
30 30
diff --git a/recipes/slite/webview.js b/recipes/slite/webview.js
index d54b2d3..f1d9f32 100644
--- a/recipes/slite/webview.js
+++ b/recipes/slite/webview.js
@@ -1,7 +1,9 @@
1module.exports = Ferdi => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 const element = document.querySelector("#app button[data-test-id='notificationsCount']"); 3 const element = document.querySelector(
4 Ferdi.setBadge(element ? Ferdi.safeParseInt(element.innerText) : 0); 4 "#app button[data-test-id='notificationsCount']",
5 );
6 Ferdi.setBadge(element ? Ferdi.safeParseInt(element.textContent) : 0);
5 }; 7 };
6 8
7 Ferdi.loop(getMessages); 9 Ferdi.loop(getMessages);
diff --git a/recipes/slowly/webview.js b/recipes/slowly/webview.js
index e005ea1..cc40a46 100644
--- a/recipes/slowly/webview.js
+++ b/recipes/slowly/webview.js
@@ -1,2 +1 @@
1module.exports = () => { module.exports = () => {};
2};
diff --git a/recipes/sococo/webview.js b/recipes/sococo/webview.js
index 4f7e045..c0bb20f 100644
--- a/recipes/sococo/webview.js
+++ b/recipes/sococo/webview.js
@@ -1,10 +1,10 @@
1module.exports = (Ferdi) => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 let indirect = document.querySelectorAll('.new-messages'); 3 let indirect = document.querySelectorAll('.new-messages');
4 let direct = 0; 4 let direct = 0;
5 document.querySelectorAll('.people-pane .badge').forEach(function(badge){ 5 for (const badge of document.querySelectorAll('.people-pane .badge')) {
6 direct += Ferdi.safeParseInt(badge.innerText); 6 direct += Ferdi.safeParseInt(badge.textContent);
7 }); 7 }
8 Ferdi.setBadge(direct, indirect); 8 Ferdi.setBadge(direct, indirect);
9 }; 9 };
10 10
diff --git a/recipes/stackexchange/index.js b/recipes/stackexchange/index.js
index 907a90f..d9328a9 100644
--- a/recipes/stackexchange/index.js
+++ b/recipes/stackexchange/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class stackexchange extends Ferdi { module.exports = Ferdi => class stackexchange extends Ferdi {};
2};
diff --git a/recipes/stackoverflow-chat/index.js b/recipes/stackoverflow-chat/index.js
index c6cfcdf..ea29aa3 100644
--- a/recipes/stackoverflow-chat/index.js
+++ b/recipes/stackoverflow-chat/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class stackoverflowchat extends Ferdi { module.exports = Ferdi => class stackoverflowchat extends Ferdi {};
2};
diff --git a/recipes/stackoverflow-chat/webview.js b/recipes/stackoverflow-chat/webview.js
index cf487b5..4157600 100644
--- a/recipes/stackoverflow-chat/webview.js
+++ b/recipes/stackoverflow-chat/webview.js
@@ -1,13 +1,17 @@
1var _path = _interopRequireDefault(require('path')); 1var _path = _interopRequireDefault(require('path'));
2 2
3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3function _interopRequireDefault(obj) {
4 return obj && obj.__esModule ? obj : { default: obj };
5}
4 6
5module.exports = Ferdi => { 7module.exports = Ferdi => {
6 const getMessages = () => { 8 const getMessages = () => {
7 const unreadSpan = document.querySelector('span.flag-count.message-count.unread-count'); 9 const unreadSpan = document.querySelector(
10 'span.flag-count.message-count.unread-count',
11 );
8 let directCount = 0; 12 let directCount = 0;
9 if (unreadSpan) { 13 if (unreadSpan) {
10 directCount = Ferdi.safeParseInt(unreadSpan.innerText); 14 directCount = Ferdi.safeParseInt(unreadSpan.textContent);
11 } 15 }
12 Ferdi.setBadge(directCount); 16 Ferdi.setBadge(directCount);
13 }; 17 };
diff --git a/recipes/stackoverflow/webview.js b/recipes/stackoverflow/webview.js
index 437fb49..83fd5dd 100644
--- a/recipes/stackoverflow/webview.js
+++ b/recipes/stackoverflow/webview.js
@@ -6,8 +6,8 @@ module.exports = (Ferdi) => {
6 const getMessages = () => { 6 const getMessages = () => {
7 const elements = document.querySelectorAll('.CxUIE, .unread'); 7 const elements = document.querySelectorAll('.CxUIE, .unread');
8 let count = 0; 8 let count = 0;
9 for (let i = 0; i < elements.length; i += 1) { 9 for (const element of elements) {
10 if (elements[i].querySelectorAll('*[data-icon="muted"]').length === 0) { 10 if (element.querySelectorAll('*[data-icon="muted"]').length === 0) {
11 count += 1; 11 count += 1;
12 } 12 }
13 } 13 }
diff --git a/recipes/steamchat/webview.js b/recipes/steamchat/webview.js
index 61d57ad..2990131 100644
--- a/recipes/steamchat/webview.js
+++ b/recipes/steamchat/webview.js
@@ -3,19 +3,24 @@ module.exports = Ferdi => {
3 // get new msg count 3 // get new msg count
4 let count = 0; 4 let count = 0;
5 const counters = document.querySelectorAll('[class*=FriendMessageCount]'); 5 const counters = document.querySelectorAll('[class*=FriendMessageCount]');
6 [].filter.call(counters, countValue => { 6 Array.prototype.filter.call(counters, countValue => {
7 if (countValue) { 7 if (countValue) {
8 count += Ferdi.safeParseInt(countValue.innerHTML); 8 count += Ferdi.safeParseInt(countValue.textContent);
9 } 9 }
10 }); 10 });
11 11
12 const indirectMessages = document.querySelectorAll('[class*=ChatUnreadMessageIndicator]').length; 12 const indirectMessages = document.querySelectorAll(
13 '[class*=ChatUnreadMessageIndicator]',
14 ).length;
13 Ferdi.setBadge(count, indirectMessages); 15 Ferdi.setBadge(count, indirectMessages);
14 16
15 // force scroll to bottom of chat window 17 // force scroll to bottom of chat window
16 const chatBoxes = document.querySelectorAll('.chat_dialog'); 18 const chatBoxes = document.querySelectorAll('.chat_dialog');
17 if (chatBoxes) { 19 if (chatBoxes) {
18 const chatBox = [].filter.call(chatBoxes, chat => chat.style.display !== 'none'); 20 const chatBox = Array.prototype.filter.call(
21 chatBoxes,
22 chat => chat.style.display !== 'none',
23 );
19 if (chatBox[0]) { 24 if (chatBox[0]) {
20 const chatWindow = chatBox[0].querySelector('.chat_dialog_scroll'); 25 const chatWindow = chatBox[0].querySelector('.chat_dialog_scroll');
21 chatWindow.scrollTop = chatWindow.scrollHeight; 26 chatWindow.scrollTop = chatWindow.scrollHeight;
@@ -25,13 +30,17 @@ module.exports = Ferdi => {
25 30
26 Ferdi.loop(getMessages); 31 Ferdi.loop(getMessages);
27 32
28 document.addEventListener('click', event => { 33 document.addEventListener(
29 const link = event.target.closest('a[href^="http"]'); 34 'click',
35 event => {
36 const link = event.target.closest('a[href^="http"]');
30 37
31 if (link && link.getAttribute('target') === '_top') { 38 if (link && link.getAttribute('target') === '_top') {
32 event.preventDefault(); 39 event.preventDefault();
33 event.stopPropagation(); 40 event.stopPropagation();
34 Ferdi.openNewWindow(link.getAttribute('href')); 41 Ferdi.openNewWindow(link.getAttribute('href'));
35 } 42 }
36 }, true); 43 },
44 true,
45 );
37}; 46};
diff --git a/recipes/stride/webview.js b/recipes/stride/webview.js
index 6b62e08..002fca5 100644
--- a/recipes/stride/webview.js
+++ b/recipes/stride/webview.js
@@ -10,7 +10,7 @@ module.exports = Ferdi => {
10 let indirectCount = 0; 10 let indirectCount = 0;
11 11
12 // get unread direct messages by tring to read the badge values 12 // get unread direct messages by tring to read the badge values
13 allBadges.forEach(item => { 13 for (const item of allBadges) {
14 if (item.hasAttribute('data-count')) { 14 if (item.hasAttribute('data-count')) {
15 // Count for DMs should be in the data-count attribute 15 // Count for DMs should be in the data-count attribute
16 directCount += Math.max(1, +item.getAttribute('data-count')); 16 directCount += Math.max(1, +item.getAttribute('data-count'));
@@ -18,7 +18,7 @@ module.exports = Ferdi => {
18 // this will be the case for indirect messages 18 // this will be the case for indirect messages
19 indirectCount++; 19 indirectCount++;
20 } 20 }
21 }); 21 }
22 22
23 // set Ferdi badge 23 // set Ferdi badge
24 Ferdi.setBadge(directCount, indirectCount); 24 Ferdi.setBadge(directCount, indirectCount);
diff --git a/recipes/sync/index.js b/recipes/sync/index.js
index a3e9be5..745078f 100644
--- a/recipes/sync/index.js
+++ b/recipes/sync/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class sync extends Ferdi { module.exports = Ferdi => class sync extends Ferdi {};
2};
diff --git a/recipes/teamleader/webview.js b/recipes/teamleader/webview.js
index 241d787..f846f55 100644
--- a/recipes/teamleader/webview.js
+++ b/recipes/teamleader/webview.js
@@ -1,26 +1,36 @@
1const _path = _interopRequireDefault(require('path')); 1const _path = _interopRequireDefault(require('path'));
2 2
3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3function _interopRequireDefault(obj) {
4 return obj && obj.__esModule ? obj : { default: obj };
5}
4 6
5module.exports = (Ferdi) => { 7module.exports = Ferdi => {
6 const getMessages = () => { 8 const getMessages = () => {
7 let notifications = 0; 9 let notifications = 0;
8 let indirectNotifications = 0; 10 let indirectNotifications = 0;
9 11
10 const notification_element = document.getElementById('notifications_amount'); 12 const notification_element = document.querySelector(
11 const ticket_element = document.querySelector("a[href='tickets.php'] > span"); 13 '#notifications_amount',
12 const call_element = document.getElementById('queue_amount'); 14 );
15 const ticket_element = document.querySelector(
16 "a[href='tickets.php'] > span",
17 );
18 const call_element = document.querySelector('#queue_amount');
13 19
14 if (notification_element) { 20 if (notification_element) {
15 notifications = Ferdi.safeParseInt(notification_element.getAttribute("datacount")); 21 notifications = Ferdi.safeParseInt(
22 notification_element.getAttribute('datacount'),
23 );
16 } 24 }
17 25
18 if (ticket_element != null) { 26 if (ticket_element != null) {
19 indirectNotifications = Ferdi.safeParseInt(ticket_element.innerHTML); 27 indirectNotifications = Ferdi.safeParseInt(ticket_element.textContent);
20 } 28 }
21 29
22 if (call_element) { 30 if (call_element) {
23 indirectNotifications += Ferdi.safeParseInt(call_element.getAttribute("datacount")); 31 indirectNotifications += Ferdi.safeParseInt(
32 call_element.getAttribute('datacount'),
33 );
24 } 34 }
25 35
26 Ferdi.setBadge(notifications, indirectNotifications); 36 Ferdi.setBadge(notifications, indirectNotifications);
diff --git a/recipes/teamweek/index.js b/recipes/teamweek/index.js
index 1b32271..b28967d 100644
--- a/recipes/teamweek/index.js
+++ b/recipes/teamweek/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class Teamweek extends Ferdi { module.exports = Ferdi => class Teamweek extends Ferdi {};
2};
diff --git a/recipes/teamwork-projects/webview.js b/recipes/teamwork-projects/webview.js
index aa3e7be..7d3e845 100644
--- a/recipes/teamwork-projects/webview.js
+++ b/recipes/teamwork-projects/webview.js
@@ -1,14 +1,14 @@
1module.exports = (Ferdi) => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 let indirectCount = 0; 3 let indirectCount = 0;
4 const badge = document.getElementById('numNotifs2'); 4 const badge = document.querySelector('#numNotifs2');
5 5
6 if (badge && badge.innerText) { 6 if (badge && badge.textContent) {
7 indirectCount = Ferdi.safeParseInt(badge.innerText); 7 indirectCount = Ferdi.safeParseInt(badge.textContent);
8 } 8 }
9 9
10 Ferdi.setBadge(0, indirectCount); 10 Ferdi.setBadge(0, indirectCount);
11 } 11 };
12 12
13 Ferdi.loop(getMessages); 13 Ferdi.loop(getMessages);
14}; 14};
diff --git a/recipes/telegram-react/webview.js b/recipes/telegram-react/webview.js
index bf41404..c17b200 100644
--- a/recipes/telegram-react/webview.js
+++ b/recipes/telegram-react/webview.js
@@ -3,9 +3,14 @@ module.exports = Ferdi => {
3 let count = 0; 3 let count = 0;
4 const elements = document.querySelectorAll('.chatlist > li:not(.is-muted)'); 4 const elements = document.querySelectorAll('.chatlist > li:not(.is-muted)');
5 if (elements) { 5 if (elements) {
6 for (let i = 0; i < elements.length; i += 1) { 6 for (const element of elements) {
7 if (elements[i].querySelector('.unread') && elements[i].querySelector('.unread').innerHTML !== 0) { 7 if (
8 count += Ferdi.safeParseInt(elements[i].querySelector('.unread').innerHTML); 8 element.querySelector('.unread') &&
9 element.querySelector('.unread').textContent !== 0
10 ) {
11 count += Ferdi.safeParseInt(
12 element.querySelector('.unread').textContent,
13 );
9 } 14 }
10 } 15 }
11 } 16 }
diff --git a/recipes/telegram/webview.js b/recipes/telegram/webview.js
index 3b36483..358bdaa 100644
--- a/recipes/telegram/webview.js
+++ b/recipes/telegram/webview.js
@@ -2,18 +2,20 @@
2 2
3const _path = _interopRequireDefault(require('path')); 3const _path = _interopRequireDefault(require('path'));
4 4
5function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 5function _interopRequireDefault(obj) {
6 return obj && obj.__esModule ? obj : { default: obj };
7}
6 8
7module.exports = Ferdi => { 9module.exports = Ferdi => {
8 const getMessages = () => { 10 const getMessages = () => {
9 let count = 0; 11 let count = 0;
10 let count_sec = 0; 12 let count_sec = 0;
11 const elements = document.querySelectorAll('.rp'); 13 const elements = document.querySelectorAll('.rp');
12 for (let i = 0; i < elements.length; i += 1) { 14 for (const element of elements) {
13 const subtitleBadge = elements[i].querySelector('.dialog-subtitle-badge'); 15 const subtitleBadge = element.querySelector('.dialog-subtitle-badge');
14 if (subtitleBadge) { 16 if (subtitleBadge) {
15 const parsedValue = Ferdi.safeParseInt(subtitleBadge.innerText); 17 const parsedValue = Ferdi.safeParseInt(subtitleBadge.textContent);
16 if (elements[i].dataset.peerId > 0) { 18 if (element.dataset.peerId > 0) {
17 count += parsedValue; 19 count += parsedValue;
18 } else { 20 } else {
19 count_sec += parsedValue; 21 count_sec += parsedValue;
diff --git a/recipes/thelounge/webview.js b/recipes/thelounge/webview.js
index 28f647c..b950e8a 100644
--- a/recipes/thelounge/webview.js
+++ b/recipes/thelounge/webview.js
@@ -1,10 +1,12 @@
1module.exports = Ferdi => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 const indirectElements = document.querySelectorAll('.badge:not(.highlight)'); 3 const indirectElements = document.querySelectorAll(
4 '.badge:not(.highlight)',
5 );
4 const direct = document.querySelectorAll('.badge.highlight').length; 6 const direct = document.querySelectorAll('.badge.highlight').length;
5 let indirect = 0; 7 let indirect = 0;
6 for (let i = 0; i < indirectElements.length; i += 1) { 8 for (const indirectElement of indirectElements) {
7 if (indirectElements[i].innerHTML.length > 0) { 9 if (indirectElement.textContent.length > 0) {
8 indirect++; 10 indirect++;
9 } 11 }
10 } 12 }
diff --git a/recipes/threema/webview.js b/recipes/threema/webview.js
index 40f5203..cf7d1e1 100644
--- a/recipes/threema/webview.js
+++ b/recipes/threema/webview.js
@@ -1,17 +1,21 @@
1const _path = _interopRequireDefault(require('path')); 1const _path = _interopRequireDefault(require('path'));
2 2
3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3function _interopRequireDefault(obj) {
4 return obj && obj.__esModule ? obj : { default: obj };
5}
4 6
5module.exports = Ferdi => { 7module.exports = Ferdi => {
6 const getMessages = () => { 8 const getMessages = () => {
7 const elements = document.querySelectorAll('.badge.unread-count:not(.ng-hide)'); 9 const elements = document.querySelectorAll(
10 '.badge.unread-count:not(.ng-hide)',
11 );
8 let count = 0; 12 let count = 0;
9 13
10 for (let i = 0; i < elements.length; i += 1) { 14 for (const element of elements) {
11 try { 15 try {
12 count += Ferdi.safeParseInt(elements[i].innerHTML); 16 count += Ferdi.safeParseInt(element.textContent);
13 } catch (e) { 17 } catch (error) {
14 console.error(e); 18 console.error(error);
15 } 19 }
16 } 20 }
17 21
diff --git a/recipes/tinder/index.js b/recipes/tinder/index.js
index 38c3f5c..c0c5dd1 100644
--- a/recipes/tinder/index.js
+++ b/recipes/tinder/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class Tinder extends Ferdi { module.exports = Ferdi => class Tinder extends Ferdi {};
2};
diff --git a/recipes/todoist/webview.js b/recipes/todoist/webview.js
index b548184..30030d5 100644
--- a/recipes/todoist/webview.js
+++ b/recipes/todoist/webview.js
@@ -1,4 +1,4 @@
1module.exports = (Ferdi) => { 1module.exports = Ferdi => {
2 function getTasks() { 2 function getTasks() {
3 let todayCount = 0; 3 let todayCount = 0;
4 let inboxCount = 0; 4 let inboxCount = 0;
@@ -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 = Ferdi.safeParseInt(todayElement.innerHTML); 9 todayCount = Ferdi.safeParseInt(todayElement.textContent);
10 } 10 }
11 11
12 if (inboxElement) { 12 if (inboxElement) {
13 inboxCount = Ferdi.safeParseInt(inboxElement.innerHTML); 13 inboxCount = Ferdi.safeParseInt(inboxElement.textContent);
14 } 14 }
15 15
16 Ferdi.setBadge(inboxCount, todayCount); 16 Ferdi.setBadge(inboxCount, todayCount);
diff --git a/recipes/trello/webview.js b/recipes/trello/webview.js
index d9749b0..e359de9 100644
--- a/recipes/trello/webview.js
+++ b/recipes/trello/webview.js
@@ -1,7 +1,7 @@
1module.exports = Ferdi => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 const notifications = document.querySelectorAll('[class*=_3W-zkl4-bnVKzJ]'); 3 const notifications = document.querySelectorAll('[class*=_3W-zkl4-bnVKzJ]');
4 Ferdi.setBadge(0, notifications.length >= 1 ? 1 : 0); 4 Ferdi.setBadge(0, notifications.length > 0 ? 1 : 0);
5 }; 5 };
6 6
7 Ferdi.loop(getMessages); 7 Ferdi.loop(getMessages);
diff --git a/recipes/tutanota/index.js b/recipes/tutanota/index.js
index 3947605..5cb28eb 100644
--- a/recipes/tutanota/index.js
+++ b/recipes/tutanota/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class tutanota extends Ferdi { module.exports = Ferdi => class tutanota extends Ferdi {};
2};
diff --git a/recipes/tweetdeck/webview.js b/recipes/tweetdeck/webview.js
index 9bdc2be..7f99509 100644
--- a/recipes/tweetdeck/webview.js
+++ b/recipes/tweetdeck/webview.js
@@ -8,7 +8,7 @@ module.exports = Ferdi => {
8 const elements = document.querySelectorAll('.msg-unread-count'); 8 const elements = document.querySelectorAll('.msg-unread-count');
9 let count = 0; 9 let count = 0;
10 if (elements[0]) { 10 if (elements[0]) {
11 count = Ferdi.safeParseInt(elements[0].innerHTML); 11 count = Ferdi.safeParseInt(elements[0].textContent);
12 } 12 }
13 13
14 Ferdi.setBadge(count); 14 Ferdi.setBadge(count);
diff --git a/recipes/twitter-dm/webview.js b/recipes/twitter-dm/webview.js
index ac47134..dd6856a 100644
--- a/recipes/twitter-dm/webview.js
+++ b/recipes/twitter-dm/webview.js
@@ -3,7 +3,7 @@ module.exports = Ferdi => {
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 if (elem) { 5 if (elem) {
6 count = Ferdi.safeParseInt(elem.innerText); 6 count = Ferdi.safeParseInt(elem.textContent);
7 } 7 }
8 8
9 Ferdi.setBadge(count); 9 Ferdi.setBadge(count);
diff --git a/recipes/twitter/webview.js b/recipes/twitter/webview.js
index dfd06d1..d88e3e4 100644
--- a/recipes/twitter/webview.js
+++ b/recipes/twitter/webview.js
@@ -4,13 +4,17 @@ module.exports = Ferdi => {
4 4
5 // "Notifications" and "Messages" - aria-label ending in 5 // "Notifications" and "Messages" - aria-label ending in
6 // "unread items". Sum the values for direct badge. 6 // "unread items". Sum the values for direct badge.
7 const notificationsElement = document.querySelector('[data-testid=AppTabBar_Notifications_Link] div div div'); 7 const notificationsElement = document.querySelector(
8 '[data-testid=AppTabBar_Notifications_Link] div div div',
9 );
8 if (notificationsElement) { 10 if (notificationsElement) {
9 direct += Ferdi.safeParseInt(notificationsElement.innerHTML); 11 direct += Ferdi.safeParseInt(notificationsElement.textContent);
10 } 12 }
11 const DMElement = document.querySelector('[data-testid=AppTabBar_DirectMessage_Link] div div div'); 13 const DMElement = document.querySelector(
14 '[data-testid=AppTabBar_DirectMessage_Link] div div div',
15 );
12 if (DMElement) { 16 if (DMElement) {
13 direct += Ferdi.safeParseInt(DMElement.innerHTML); 17 direct += Ferdi.safeParseInt(DMElement.textContent);
14 } 18 }
15 19
16 Ferdi.setBadge(direct); 20 Ferdi.setBadge(direct);
diff --git a/recipes/vk/webview.js b/recipes/vk/webview.js
index aeab0ec..decec13 100644
--- a/recipes/vk/webview.js
+++ b/recipes/vk/webview.js
@@ -1,9 +1,9 @@
1module.exports = Ferdi => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 let directs = 0; 3 let directs = 0;
4 const element = document.getElementsByClassName('left_count'); 4 const element = document.querySelectorAll('.left_count');
5 if (element.length > 0) { 5 if (element.length > 0) {
6 directs = Ferdi.safeParseInt(element[0].innerText); 6 directs = Ferdi.safeParseInt(element[0].textContent);
7 } 7 }
8 8
9 Ferdi.setBadge(directs); 9 Ferdi.setBadge(directs);
diff --git a/recipes/wakatime/index.js b/recipes/wakatime/index.js
index f16f627..4caa1ec 100644
--- a/recipes/wakatime/index.js
+++ b/recipes/wakatime/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class Wakatime extends Ferdi { module.exports = Ferdi => class Wakatime extends Ferdi {};
2};
diff --git a/recipes/webex-teams/webview.js b/recipes/webex-teams/webview.js
index d29bed9..8a748e8 100644
--- a/recipes/webex-teams/webview.js
+++ b/recipes/webex-teams/webview.js
@@ -1,15 +1,17 @@
1module.exports = (Ferdi) => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 let count = 0; 3 let count = 0;
4 4
5 let span = document.getElementsByClassName('navigation-list-item--badgeCount'); 5 let span = document.querySelectorAll('.navigation-list-item--badgeCount');
6 6
7 if (span.length == 0) { 7 if (span.length === 0) {
8 span = document.getElementsByClassName('navigation-list-item--badgeCount-minimized'); 8 span = document.querySelectorAll(
9 '.navigation-list-item--badgeCount-minimized',
10 );
9 } 11 }
10 12
11 if (span.length > 0) { 13 if (span.length > 0) {
12 count = Ferdi.safeParseInt(span[0].innerText); 14 count = Ferdi.safeParseInt(span[0].textContent);
13 } 15 }
14 16
15 Ferdi.setBadge(count); 17 Ferdi.setBadge(count);
diff --git a/recipes/wechat/webview.js b/recipes/wechat/webview.js
index d75bd72..e7de1f1 100644
--- a/recipes/wechat/webview.js
+++ b/recipes/wechat/webview.js
@@ -1,23 +1,28 @@
1const _path = _interopRequireDefault(require('path')); 1const _path = _interopRequireDefault(require('path'));
2 2
3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3function _interopRequireDefault(obj) {
4 return obj && obj.__esModule ? obj : { default: obj };
5}
4 6
5module.exports = (Ferdi) => { 7module.exports = Ferdi => {
6 const getMessages = () => { 8 const getMessages = () => {
7 let directCount = 0; 9 let directCount = 0;
8 let indirectCount = 0; 10 let indirectCount = 0;
9 const chat_item = document.querySelectorAll('div.chat_item'); 11 const chat_item = document.querySelectorAll('div.chat_item');
10 12
11 Array.prototype.forEach.call(chat_item, (item) => { 13 Array.prototype.forEach.call(chat_item, item => {
12 let count = 0; 14 let count = 0;
13 const reddot = item.querySelector('i.web_wechat_reddot_middle'); 15 const reddot = item.querySelector('i.web_wechat_reddot_middle');
14 const avatarImage = item.querySelector('img.img'); 16 const avatarImage = item.querySelector('img.img');
15 17
16 if (reddot) { 18 if (reddot) {
17 count = Ferdi.safeParseInt(reddot.innerText); 19 count = Ferdi.safeParseInt(reddot.textContent);
18 } 20 }
19 21
20 if (avatarImage && avatarImage.getAttribute('src').search('webwxgeticon') != -1) { 22 if (
23 avatarImage &&
24 avatarImage.getAttribute('src').search('webwxgeticon') != -1
25 ) {
21 directCount += count; 26 directCount += count;
22 } else { 27 } else {
23 indirectCount += count; 28 indirectCount += count;
@@ -25,7 +30,7 @@ module.exports = (Ferdi) => {
25 }); 30 });
26 31
27 Ferdi.setBadge(directCount, indirectCount); 32 Ferdi.setBadge(directCount, indirectCount);
28 } 33 };
29 34
30 Ferdi.loop(getMessages); 35 Ferdi.loop(getMessages);
31 36
diff --git a/recipes/weekplan/webview.js b/recipes/weekplan/webview.js
index f08859d..535ab9b 100644
--- a/recipes/weekplan/webview.js
+++ b/recipes/weekplan/webview.js
@@ -1,7 +1,7 @@
1module.exports = Ferdi => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 const events = document.querySelectorAll(".today")[0].getElementsByClassName('list')[0].getElementsByClassName('task-list')[0].getElementsByClassName('event-section')[0].getElementsByClassName('droppable')[0].children[0].childElementCount 3 const events = document.querySelectorAll(".today")[0].querySelectorAll('.list')[0].querySelectorAll('.task-list')[0].querySelectorAll('.event-section')[0].querySelectorAll('.droppable')[0].children[0].childElementCount
4 const tasks = document.querySelectorAll(".today")[0].getElementsByClassName('list')[0].getElementsByClassName('task-list')[0].getElementsByClassName('task-section')[0].getElementsByClassName('droppable')[0].children[0].childElementCount 4 const tasks = document.querySelectorAll(".today")[0].querySelectorAll('.list')[0].querySelectorAll('.task-list')[0].querySelectorAll('.task-section')[0].querySelectorAll('.droppable')[0].children[0].childElementCount
5 5
6 Ferdi.setBadge(events + tasks); 6 Ferdi.setBadge(events + tasks);
7 }; 7 };
diff --git a/recipes/whatsapp/webview.js b/recipes/whatsapp/webview.js
index dea7b6a..a908637 100644
--- a/recipes/whatsapp/webview.js
+++ b/recipes/whatsapp/webview.js
@@ -7,15 +7,14 @@ module.exports = (Ferdi, settings) => {
7 let count = 0; 7 let count = 0;
8 let indirectCount = 0; 8 let indirectCount = 0;
9 9
10 const parentChatElem = Array.from(document.querySelectorAll('div[aria-label]')) 10 const parentChatElem = [...document.querySelectorAll('div[aria-label]')]
11 .sort((a, b) => (a.offsetHeight < b.offsetHeight) ? 1 : -1)[0]; 11 .sort((a, b) => (a.offsetHeight < b.offsetHeight) ? 1 : -1)[0];
12 if (!parentChatElem) { 12 if (!parentChatElem) {
13 return; 13 return;
14 } 14 }
15 15
16 const unreadSpans = parentChatElem.querySelectorAll('span[aria-label]'); 16 const unreadSpans = parentChatElem.querySelectorAll('span[aria-label]');
17 for (let i = 0; i < unreadSpans.length; i++) { 17 for (const unreadElem of unreadSpans) {
18 const unreadElem = unreadSpans[i];
19 const countValue = Ferdi.safeParseInt(unreadElem.textContent); 18 const countValue = Ferdi.safeParseInt(unreadElem.textContent);
20 if (countValue > 0) { 19 if (countValue > 0) {
21 if (!unreadElem.parentNode.previousSibling || unreadElem.parentNode.previousSibling.querySelectorAll('[data-icon=muted]').length === 0) { 20 if (!unreadElem.parentNode.previousSibling || unreadElem.parentNode.previousSibling.querySelectorAll('[data-icon=muted]').length === 0) {
diff --git a/recipes/whereby/webview.js b/recipes/whereby/webview.js
index 52d6d7b..eb751a5 100644
--- a/recipes/whereby/webview.js
+++ b/recipes/whereby/webview.js
@@ -7,8 +7,8 @@ module.exports = Ferdi => {
7 const elements = document.querySelectorAll('.CxUIE, .unread'); 7 const elements = document.querySelectorAll('.CxUIE, .unread');
8 let count = 0; 8 let count = 0;
9 9
10 for (let i = 0; i < elements.length; i += 1) { 10 for (const element of elements) {
11 if (elements[i].querySelectorAll('*[data-icon="muted"]').length === 0) { 11 if (element.querySelectorAll('*[data-icon="muted"]').length === 0) {
12 count += 1; 12 count += 1;
13 } 13 }
14 } 14 }
diff --git a/recipes/wire/webview.js b/recipes/wire/webview.js
index 55720da..cdb5058 100644
--- a/recipes/wire/webview.js
+++ b/recipes/wire/webview.js
@@ -1,20 +1,25 @@
1module.exports = (Ferdi) => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 let direct = 0; 3 let direct = 0;
4 let indirect = 0; 4 let indirect = 0;
5 5
6 // Count how many people/groups have texted you 6 // Count how many people/groups have texted you
7 const conversationElems = document.querySelectorAll('[data-uie-name="conversation-folder-badge"]'); 7 const conversationElems = document.querySelectorAll(
8 '[data-uie-name="conversation-folder-badge"]',
9 );
8 if (conversationElems) { 10 if (conversationElems) {
9 for (const conversationElem of conversationElems) { 11 for (const conversationElem of conversationElems) {
10 direct += Ferdi.safeParseInt(conversationElem.innerText); 12 direct += Ferdi.safeParseInt(conversationElem.textContent);
11 } 13 }
12 } 14 }
13 15
14 // Count unread pending user requests 16 // Count unread pending user requests
15 const pendingElem = document.querySelector('[data-uie-name="item-pending-requests"]'); 17 const pendingElem = document.querySelector(
18 '[data-uie-name="item-pending-requests"]',
19 );
16 if (pendingElem) { 20 if (pendingElem) {
17 const matches = pendingElem.innerText.match(/^([1-9][0-9]*)/); 21 const matches =
22 pendingElem.textContent && pendingElem.textContent.match(/^([1-9]\d*)/);
18 if (matches && matches.length > 1) { 23 if (matches && matches.length > 1) {
19 indirect += Ferdi.safeParseInt(matches[1]); 24 indirect += Ferdi.safeParseInt(matches[1]);
20 } 25 }
@@ -22,13 +27,13 @@ module.exports = (Ferdi) => {
22 27
23 // Alternative would be to count all messages (unread conversation count + pending) from the header 28 // Alternative would be to count all messages (unread conversation count + pending) from the header
24 // const titleElem = document.querySelector('head title'); 29 // const titleElem = document.querySelector('head title');
25 // const matches = titleElem.innerText.match(/^\(([1-9][0-9]*)\)/); 30 // const matches = titleElem.textContent.match(/^\(([1-9][0-9]*)\)/);
26 // if (matches) { 31 // if (matches) {
27 // direct = matches[1]; 32 // direct = matches[1];
28 // } 33 // }
29 34
30 Ferdi.setBadge(direct, indirect); 35 Ferdi.setBadge(direct, indirect);
31 } 36 };
32 37
33 Ferdi.loop(getMessages); 38 Ferdi.loop(getMessages);
34}; 39};
diff --git a/recipes/workplace/webview.js b/recipes/workplace/webview.js
index efa5e2a..90c6c27 100644
--- a/recipes/workplace/webview.js
+++ b/recipes/workplace/webview.js
@@ -1,6 +1,8 @@
1const _path = _interopRequireDefault(require('path')); 1const _path = _interopRequireDefault(require('path'));
2 2
3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3function _interopRequireDefault(obj) {
4 return obj && obj.__esModule ? obj : { default: obj };
5}
4 6
5module.exports = Ferdi => { 7module.exports = Ferdi => {
6 const getMessages = () => { 8 const getMessages = () => {
@@ -10,7 +12,7 @@ module.exports = Ferdi => {
10 const notifications = document.querySelector('#notifications span span'); 12 const notifications = document.querySelector('#notifications span span');
11 13
12 if (notifications) { 14 if (notifications) {
13 indirect = Ferdi.safeParseInt(notifications.innerText); 15 indirect = Ferdi.safeParseInt(notifications.textContent);
14 } 16 }
15 17
16 if (chatsElement) { 18 if (chatsElement) {
@@ -18,10 +20,12 @@ module.exports = Ferdi => {
18 const chatMessages = chatsElement.querySelector('span'); 20 const chatMessages = chatsElement.querySelector('span');
19 21
20 if (chatMessages) { 22 if (chatMessages) {
21 direct = Ferdi.safeParseInt(chatMessages.innerText); 23 direct = Ferdi.safeParseInt(chatMessages.textContent);
22 } 24 }
23 } else { 25 } else {
24 direct = document.querySelectorAll('[data-pagelet="WorkGalahadChannel"] .uiList [role="gridcell"] [role="button"] .oxk9n0fw').length; 26 direct = document.querySelectorAll(
27 '[data-pagelet="WorkGalahadChannel"] .uiList [role="gridcell"] [role="button"] .oxk9n0fw',
28 ).length;
25 } 29 }
26 } 30 }
27 31
@@ -33,18 +37,21 @@ module.exports = Ferdi => {
33 Ferdi.injectCSS(_path.default.join(__dirname, 'workplace.css')); 37 Ferdi.injectCSS(_path.default.join(__dirname, 'workplace.css'));
34 38
35 localStorage._cs_desktopNotifsEnabled = JSON.stringify({ 39 localStorage._cs_desktopNotifsEnabled = JSON.stringify({
36 __t: new Date().getTime(), 40 __t: Date.now(),
37 __v: true, 41 __v: true,
38 }); 42 });
39 43
40 if (typeof Ferdi.onNotify === 'function') { 44 if (typeof Ferdi.onNotify === 'function') {
41 Ferdi.onNotify(notification => { 45 Ferdi.onNotify(notification => {
42 if (typeof notification.title !== 'string') { 46 if (typeof notification.title !== 'string') {
43 notification.title = ((notification.title.props || {}).content || [])[0] || 'Work Chat'; 47 notification.title =
48 ((notification.title.props || {}).content || [])[0] || 'Work Chat';
44 } 49 }
45 50
46 if (typeof notification.options.body !== 'string') { 51 if (typeof notification.options.body !== 'string') {
47 notification.options.body = (((notification.options.body || {}).props || {}).content || [])[0] || ''; 52 notification.options.body =
53 (((notification.options.body || {}).props || {}).content || [])[0] ||
54 '';
48 } 55 }
49 56
50 return notification; 57 return notification;
diff --git a/recipes/wrike/webview.js b/recipes/wrike/webview.js
index e09407d..93d5d53 100644
--- a/recipes/wrike/webview.js
+++ b/recipes/wrike/webview.js
@@ -1,13 +1,15 @@
1module.exports = (Ferdi) => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const 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(
5 '.ws-navigation-button__indicator.ws-navigation-button-indicator',
6 );
5 if (element) { 7 if (element) {
6 directCount = Ferdi.safeParseInt(element.innerText); 8 directCount = Ferdi.safeParseInt(element.textContent);
7 } 9 }
8 10
9 Ferdi.setBadge(directCount); 11 Ferdi.setBadge(directCount);
10 } 12 };
11 13
12 Ferdi.loop(getMessages); 14 Ferdi.loop(getMessages);
13}; 15};
diff --git a/recipes/xing/webview.js b/recipes/xing/webview.js
index 9effe95..75038bf 100644
--- a/recipes/xing/webview.js
+++ b/recipes/xing/webview.js
@@ -1,6 +1,6 @@
1module.exports = Ferdi => { 1module.exports = Ferdi => {
2 function getUnreadConversations() { 2 function getUnreadConversations() {
3 Ferdi.setBadge(document.querySelector('#unread-conversations').innerHTML); 3 Ferdi.setBadge(document.querySelector('#unread-conversations').textContent);
4 } 4 }
5 5
6 Ferdi.loop(getUnreadConversations); 6 Ferdi.loop(getUnreadConversations);
diff --git a/recipes/yammer/webview.js b/recipes/yammer/webview.js
index d3a94da..6bfd971 100644
--- a/recipes/yammer/webview.js
+++ b/recipes/yammer/webview.js
@@ -2,15 +2,21 @@ module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 let directMessages = 0; 3 let directMessages = 0;
4 let indirectMessages = 0; 4 let indirectMessages = 0;
5 const notificationElement = document.querySelector('.yj-notifications-indicator-count'); 5 const notificationElement = document.querySelector(
6 const newMessagesElement = document.querySelector('.yj-thread-list--new-messages-notice:not(.is-hidden) .yj-thread-list--new-message-text'); 6 '.yj-notifications-indicator-count',
7 );
8 const newMessagesElement = document.querySelector(
9 '.yj-thread-list--new-messages-notice:not(.is-hidden) .yj-thread-list--new-message-text',
10 );
7 11
8 if (notificationElement) { 12 if (notificationElement) {
9 directMessages = Ferdi.safeParseInt(notificationElement.innerHTML); 13 directMessages = Ferdi.safeParseInt(notificationElement.textContent);
10 } 14 }
11 15
12 if (newMessagesElement) { 16 if (newMessagesElement) {
13 indirectMessages = Ferdi.safeParseInt(newMessagesElement.innerHTML.match(/\d+/)[0]); 17 indirectMessages = Ferdi.safeParseInt(
18 newMessagesElement.textContent.match(/\d+/)[0],
19 );
14 } 20 }
15 21
16 Ferdi.setBadge(directMessages, indirectMessages); 22 Ferdi.setBadge(directMessages, indirectMessages);
diff --git a/recipes/yandex-mail/webview.js b/recipes/yandex-mail/webview.js
index 7a937a7..fff4602 100644
--- a/recipes/yandex-mail/webview.js
+++ b/recipes/yandex-mail/webview.js
@@ -2,8 +2,8 @@ module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 let count = 0; 3 let count = 0;
4 4
5 if (document.getElementsByClassName('mail-LabelList-Item_count').length > 1) { 5 if (document.querySelectorAll('.mail-LabelList-Item_count').length > 1) {
6 count = Ferdi.safeParseInt(document.getElementsByClassName('mail-LabelList-Item_count')[1].textContent); 6 count = Ferdi.safeParseInt(document.querySelectorAll('.mail-LabelList-Item_count')[1].textContent);
7 } 7 }
8 8
9 Ferdi.setBadge(count); 9 Ferdi.setBadge(count);
diff --git a/recipes/youtrack/index.js b/recipes/youtrack/index.js
index fbb0bb0..16a8178 100644
--- a/recipes/youtrack/index.js
+++ b/recipes/youtrack/index.js
@@ -1,2 +1 @@
1module.exports = Ferdi => class youtrack extends Ferdi { module.exports = Ferdi => class youtrack extends Ferdi {};
2};
diff --git a/recipes/zalo/webview.js b/recipes/zalo/webview.js
index a79e29b..9ccc93b 100644
--- a/recipes/zalo/webview.js
+++ b/recipes/zalo/webview.js
@@ -1,6 +1,6 @@
1module.exports = Ferdi => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 const notificationBadge = document.getElementsByClassName('tab-red-dot').length; 3 const notificationBadge = document.querySelectorAll('.tab-red-dot').length;
4 Ferdi.setBadge(notificationBadge); 4 Ferdi.setBadge(notificationBadge);
5 }; 5 };
6 6
diff --git a/recipes/zendesk/webview.js b/recipes/zendesk/webview.js
index b781121..0b448b7 100644
--- a/recipes/zendesk/webview.js
+++ b/recipes/zendesk/webview.js
@@ -1,13 +1,17 @@
1const _path = _interopRequireDefault(require('path')); 1const _path = _interopRequireDefault(require('path'));
2 2
3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3function _interopRequireDefault(obj) {
4 return obj && obj.__esModule ? obj : { default: obj };
5}
4 6
5module.exports = Ferdi => { 7module.exports = Ferdi => {
6 const getMessages = () => { 8 const getMessages = () => {
7 let count = 0; 9 let count = 0;
8 const element = document.querySelector('.dashboard-top-panel .indicators .stats-group .cell-value'); 10 const element = document.querySelector(
11 '.dashboard-top-panel .indicators .stats-group .cell-value',
12 );
9 if (element) { 13 if (element) {
10 count = Ferdi.safeParseInt(element.innerHTML); 14 count = Ferdi.safeParseInt(element.textContent);
11 } 15 }
12 16
13 Ferdi.setBadge(count); 17 Ferdi.setBadge(count);
diff --git a/recipes/zulip/index.js b/recipes/zulip/index.js
index 5854600..8bad3cf 100644
--- a/recipes/zulip/index.js
+++ b/recipes/zulip/index.js
@@ -12,8 +12,8 @@ module.exports = Ferdi => class Zulip extends Ferdi {
12 const data = await resp.json(); 12 const data = await resp.json();
13 13
14 return Object.hasOwnProperty.call(data, 'realm_uri'); 14 return Object.hasOwnProperty.call(data, 'realm_uri');
15 } catch (err) { 15 } catch (error) {
16 console.error(err); 16 console.error(error);
17 } 17 }
18 18
19 return false; 19 return false;
diff --git a/recipes/zulip/webview.js b/recipes/zulip/webview.js
index 3de6c90..e9c13c0 100644
--- a/recipes/zulip/webview.js
+++ b/recipes/zulip/webview.js
@@ -1,6 +1,10 @@
1module.exports = (Ferdi) => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 const allMessages = Math.round(document.querySelectorAll('#global_filters .top_left_all_messages .count .value')[0].innerText); 3 const allMessages = Math.round(
4 document.querySelectorAll(
5 '#global_filters .top_left_all_messages .count .value',
6 )[0].textContent,
7 );
4 Ferdi.setBadge(allMessages); 8 Ferdi.setBadge(allMessages);
5 }; 9 };
6 10