aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/chatwork/webview.js
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/chatwork/webview.js')
-rw-r--r--recipes/chatwork/webview.js21
1 files changed, 14 insertions, 7 deletions
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};