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

  Ferdium.loop(getMessages);
};