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/wire/webview.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'recipes/wire/webview.js') 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 @@ -module.exports = (Ferdi) => { +module.exports = Ferdi => { const getMessages = () => { let direct = 0; let indirect = 0; // Count how many people/groups have texted you - const conversationElems = document.querySelectorAll('[data-uie-name="conversation-folder-badge"]'); + const conversationElems = document.querySelectorAll( + '[data-uie-name="conversation-folder-badge"]', + ); if (conversationElems) { for (const conversationElem of conversationElems) { - direct += Ferdi.safeParseInt(conversationElem.innerText); + direct += Ferdi.safeParseInt(conversationElem.textContent); } } // Count unread pending user requests - const pendingElem = document.querySelector('[data-uie-name="item-pending-requests"]'); + const pendingElem = document.querySelector( + '[data-uie-name="item-pending-requests"]', + ); if (pendingElem) { - const matches = pendingElem.innerText.match(/^([1-9][0-9]*)/); + const matches = + pendingElem.textContent && pendingElem.textContent.match(/^([1-9]\d*)/); if (matches && matches.length > 1) { indirect += Ferdi.safeParseInt(matches[1]); } @@ -22,13 +27,13 @@ module.exports = (Ferdi) => { // Alternative would be to count all messages (unread conversation count + pending) from the header // const titleElem = document.querySelector('head title'); - // const matches = titleElem.innerText.match(/^\(([1-9][0-9]*)\)/); + // const matches = titleElem.textContent.match(/^\(([1-9][0-9]*)\)/); // if (matches) { // direct = matches[1]; // } Ferdi.setBadge(direct, indirect); - } + }; Ferdi.loop(getMessages); }; -- cgit v1.2.3-54-g00ecf