aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/xmpp/webview.js
blob: dec648c5d5c22dab6aa4a8e47bdd35b47ab79bf0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
module.exports = (Ferdi) => {
  function getMessages() {
    let direct = 0;
    for (const indicator of document.querySelectorAll('.msgs-indicator')) {
      direct += Ferdi.safeParseInt(indicator.textContent)
    }

    direct = direct / 2 // as the messages are provided in 2 different locations..
    Ferdi.setBadge(direct);
  }

  Ferdi.loop(getMessages);
};