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

  Ferdi.loop(getMessages);
};