aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/glowing-bear/webview.js
blob: b20796fc5e502ab0ca876ed4f8f1d6b8bb773005 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module.exports = Ferdium => {
  const getMessages = () => {
    const indirectElements = document.querySelectorAll('.badge:not(.danger)');
    const direct = document.querySelectorAll('.badge.danger').length - 1;
    let indirect = -1;
    for (const indirectElement of indirectElements) {
      if (
        indirectElement.textContent &&
        indirectElement.textContent.length > 0
      ) {
        indirect++;
      }
    }
    Ferdium.setBadge(direct, indirect);
  };

  Ferdium.loop(getMessages);
};