aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/schildichat/webview.js
blob: bd7eef874348a9dcee969ba1a65e070a5c0cca5b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
module.exports = Ferdium => {
  function getMessages() {
    const directMatches = document.querySelector('title').textContent
      .match('(?<=\\[)\\d+(?=])');
    Ferdium.setBadge(
      Ferdium.safeParseInt(directMatches !== null ? directMatches[0] : 0),
      document.querySelector('.mx_SpaceTreeLevel')
        .querySelectorAll('.mx_NotificationBadge_dot')
        .length
    );
  }

  Ferdium.loop(getMessages);
};