diff options
author | Markus Hatvan <markus_hatvan@aon.at> | 2021-10-05 17:04:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-05 17:04:09 +0200 |
commit | d3841b766f9d37d557646003899f67525c5f755f (patch) | |
tree | 1bcab990c94f2b05678b7a83ffebe08298500f0b /recipes/hey/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/hey/webview.js')
-rw-r--r-- | recipes/hey/webview.js | 28 |
1 files changed, 17 insertions, 11 deletions
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 @@ | |||
1 | module.exports = (Ferdi) => { | 1 | module.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 | }; |