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

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

    for (const element of elements) {
      if (element !== null) {
        count += Ferdi.safeParseInt(element.textContent);
      }
    }

    Ferdi.setBadge(count);
  };

  Ferdi.loop(getNotifications);
};