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

  Ferdi.loop(getMessages);
};