aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/facebook/webview.js
blob: 43de14909758146623fc92831a6fc6526a6d5783 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module.exports = (Ferdi) => {
  const getNotifications = function getNotifications() {
    let count = 0;

    const elements = [
      document.getElementById('requestsCountValue'),
      // document.getElementById('mercurymessagesCountValue'),
      document.getElementById('notificationsCountValue'),
      document.querySelector('.k4urcfbm.qnrpqo6b.qt6c0cv9.jxrgncrl.jb3vyjys.taijpn5t.datstx6m.pq6dq46d.ljqsnud1.bp9cbjyn'),
    ];

    elements.forEach((element) => {
      if (element !== null) {
        count += Ferdi.safeParseInt(element.innerHTML);
      }
    });

    Ferdi.setBadge(count);
  };

  Ferdi.loop(getNotifications);
};