aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/github/webview.js
blob: 47d4a130002b51464ea2df972841f6391f9c49a4 (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
module.exports = Ferdi => {
  const getMessages = () => {
    const directCountElement = document.querySelector(
      '.filter-list.js-notification-inboxes .count',
    );
    let directCount = 0;
    if (directCountElement) {
      directCount = Ferdi.safeParseInt(directCountElement.innerHTML);
    }

    const indirectCountElement = document.querySelector(
      '[class*="mail-status unread"]',
    );
    let indirectCount = 0;
    if (indirectCountElement) {
      indirectCount = 1;
    }

    Ferdi.setBadge(directCount, indirectCount);
  };

  Ferdi.loop(getMessages);
};