aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/guilded/webview.js
blob: 69c3bcb466894dd91c0734f921fc23364cf807f6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
module.exports = Ferdi => {
  const getMessages = () => {
    let unread = 0;
    const notificationBadge = document.querySelectorAll(
      '.NavSelectorItem-unread-badge',
    )[0];
    if (notificationBadge != undefined) {
      const innerBadge =
        notificationBadge.querySelectorAll('.BadgeV2-count')[0];
      unread = Ferdi.safeParseInt(innerBadge.textContent);
    }
    Ferdi.setBadge(unread);
  };

  Ferdi.loop(getMessages);
};