aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/proton-mail/webview.js
blob: 89e5dab0831a38cdc83e416c2ab32ebfab26e877 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
module.exports = Ferdi => {
  const getMessages = () => {
    let unreadCount = 0;
    // Loop over all displayed counters and take the highest one (from the "All Mail" folder)
    document.querySelectorAll('.navigation-counter-item').forEach(counterElement => {
      const unreadCounter = Ferdi.safeParseInt(counterElement.textContent);
      unreadCount = Math.max(unreadCount, unreadCounter);
    });

    Ferdi.setBadge(unreadCount);
  };

  Ferdi.loop(getMessages);
};