aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/thelounge/webview.js
blob: e993264f0bcb97b73eb9c931704858f3997af3e0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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++;
    }
    console.log(direct, indirect);
    Ferdi.setBadge(direct, indirect);
  };

  Ferdi.loop(getMessages);
};