aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/hey/webview.js
blob: d3227af3fd27854f43a70dd7f3fc977948898804 (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
module.exports = (Ferdi) => {
  const getMessages = function getMessages() {
    if (document.location.href == "https://app.hey.com/") {
      let screener = 0;
      let unread = 0;

      if (document.getElementsByClassName('btn--icon-screener').length > 0) {
        let text = document.getElementsByClassName('btn--icon-screener')[0].innerText;

        screener = Ferdi.safeParseInt(/[0-9]+/.exec(text)[0]);
      }

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

      if (postings.length > 0) {
        Array.from(postings).forEach(p => {
          if (p.nodeName == "ARTICLE" && p.getAttribute("data-seen") !== "true") {
            unread++;
          }
        });
      }

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

  Ferdi.loop(getMessages);
}