aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/proton-mail/webview.js
blob: dc3499ac3071eaf88561332332c52eb3422df1fc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
module.exports = Ferdium => {
  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 = Ferdium.safeParseInt(counterElement.textContent);
      unreadCount = Math.max(unreadCount, unreadCounter);
    }

    Ferdium.setBadge(unreadCount);
  };

  Ferdium.loop(getMessages);
};