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

  Ferdi.loop(getMessages);
};