From d3841b766f9d37d557646003899f67525c5f755f Mon Sep 17 00:00:00 2001 From: Markus Hatvan Date: Tue, 5 Oct 2021 17:04:09 +0200 Subject: chore: add eslint-plugin-unicorn (#733) --- recipes/chatwork/webview.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'recipes/chatwork/webview.js') 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 @@ -module.exports = (Ferdi) => { +module.exports = Ferdi => { const getMessages = () => { let directCount = 0; let indirectCount = 0; const roomInfoContainer = document.querySelectorAll('li.sc-dnqmqq'); - Array.prototype.forEach.call(roomInfoContainer, (room) => { + Array.prototype.forEach.call(roomInfoContainer, room => { let count = 0; const unreadBadge = room.querySelector('span.sc-kAzzGY'); - const unreadBadgeHasMention = room.querySelector('li._unreadBadge.sc-cSHVUG'); + const unreadBadgeHasMention = room.querySelector( + 'li._unreadBadge.sc-cSHVUG', + ); - if (unreadBadge && unreadBadge.innerText) { - count = Ferdi.safeParseInt(unreadBadge.innerText); + if (unreadBadge && unreadBadge.textContent) { + count = Ferdi.safeParseInt(unreadBadge.textContent); } if (count > 0) { - if (room.querySelector('img.sc-gqjmRU').getAttribute('src').indexOf('avatar') < 0) { + if ( + !room + .querySelector('img.sc-gqjmRU') + .getAttribute('src') + .includes('avatar') + ) { if (unreadBadgeHasMention) { directCount++; } else { @@ -25,7 +32,7 @@ module.exports = (Ferdi) => { } }); Ferdi.setBadge(directCount, indirectCount); - } + }; Ferdi.loop(getMessages); }; -- cgit v1.2.3-70-g09d2