aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/proton-mail/webview.js
blob: 455a0c473c1d885e6516e320db47a8977686f646 (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)
    for (const counterElement of document.querySelectorAll('.navigation-counter-item')) {
      const unreadCounter = Ferdi.safeParseInt(counterElement.textContent);
      unreadCount = Math.max(unreadCount, unreadCounter);
    }

    Ferdi.setBadge(unreadCount);
  };

  Ferdi.loop(getMessages);
};