aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/github/webview.js
blob: 1023975f8c334ad5f0d1b704f9065ad3548b394a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
module.exports = Ferdium => {
  const getMessages = () => {
    const directCountElement = document.querySelector(
      '.filter-list.js-notification-inboxes .count',
    );
    const directCount = directCountElement
      ? Ferdium.safeParseInt(directCountElement.textContent)
      : 0;
    const indirectCount = document.querySelector(
      '[class*="mail-status unread"]:not([hidden])',
    ) ? 1 : 0;
    Ferdium.setBadge(directCount, indirectCount);
  };

  Ferdium.loop(getMessages);
};