aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/hubstaff/webview.js
blob: 8527a4d9856301186387bfbd3c8c35910c26fa27 (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
25
26
27
28
29
function _interopRequireDefault(obj) {
  return obj && obj.__esModule ? obj : { default: obj };
}

const _path = _interopRequireDefault(require('path'));

module.exports = Ferdium => {
  // TODO: If your hubstaff service has unread messages, uncomment these lines to implement the logic for updating the badges
  const getMessages = () => {
    // TODO: Insert your notification-finding code here
    let directMessages = 0;
    let indirectMessages = 0;
    const notificationContainers = document.querySelectorAll(
      '.notifications-number',
    );
    if (notificationContainers) {
      directMessages = Ferdium.safeParseInt(
        notificationContainers[0].textContent,
      );
      indirectMessages = Ferdium.safeParseInt(
        notificationContainers[1].textContent,
      );
    }
    Ferdium.setBadge(directMessages, indirectMessages);
  };
  Ferdium.loop(getMessages);

  Ferdium.injectCSS(_path.default.join(__dirname, 'service.css'));
};