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

  Ferdi.loop(getMessages);
};