diff options
author | 2021-10-05 17:04:09 +0200 | |
---|---|---|
committer | 2021-10-05 17:04:09 +0200 | |
commit | d3841b766f9d37d557646003899f67525c5f755f (patch) | |
tree | 1bcab990c94f2b05678b7a83ffebe08298500f0b /recipes/steamchat/webview.js | |
parent | chore: repo maintenance (#732) (diff) | |
download | ferdium-recipes-d3841b766f9d37d557646003899f67525c5f755f.tar.gz ferdium-recipes-d3841b766f9d37d557646003899f67525c5f755f.tar.zst ferdium-recipes-d3841b766f9d37d557646003899f67525c5f755f.zip |
chore: add eslint-plugin-unicorn (#733)
Diffstat (limited to 'recipes/steamchat/webview.js')
-rw-r--r-- | recipes/steamchat/webview.js | 33 |
1 files changed, 21 insertions, 12 deletions
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 | }; |