aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/facebook/webview.js
blob: 17ab01182b5eb42e4070a10907578f1d1cc02c2c (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
module.exports = (Franz) => {
  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 && parseInt(element.innerHTML, 10)) {
        count += parseInt(element.innerHTML, 10);
      }
    });

    Franz.setBadge(count);
  };

  // check for new messages every second and update Franz badge
  Franz.loop(getNotifications);
};