aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/slite/webview.js
blob: 6e0fa468c255ab2820478c9dce48a142af14a34f (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
"use strict";

var _path = _interopRequireDefault(require("path"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

module.exports = Ferdi => {
  const getMessages = function getMessages() {
    let direct = 0;

    const notificationButton = document.querySelector(
      "#app button[data-test-id='notificationsCount'"
    );

    if (notificationButton) {
      const notificationCount = parseInt(notificationButton.innerText);
      direct = isNaN(notificationCount) ? 0 : notificationCount;
    }

    Ferdi.setBadge(direct);
  };

  Ferdi.loop(getMessages);
};