aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/hey/webview.js
blob: d0b885a514c589d76dc2962e9d764e5f654daeea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
module.exports = Ferdium => {
  const getMessages = () => {
    if (document.location.href == 'https://app.hey.com/') {
      let screener = 0;
      let unread = 0;

      if (document.querySelectorAll('.btn--icon-screener').length > 0) {
        let text = document.querySelectorAll('.btn--icon-screener')[0]
          .textContent;
        if (text) {
          const parsedText = Ferdium.safeParseInt(/\d+/.exec(text));
          screener = parsedText[0];
        }
      }

      let postings = document.querySelectorAll('.posting');

      if (postings.length > 0) {
        for (const p of postings) {
          if (
            p.nodeName == 'ARTICLE' &&
            p.dataset.seen !== 'true'
          ) {
            unread++;
          }
        }
      }

      Ferdium.setBadge(unread, screener);
    }
  };

  Ferdium.loop(getMessages);
};