aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/stackoverflow-chat/webview.js
blob: 415760044e91faf6db2505244505dabdb42c38dc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
var _path = _interopRequireDefault(require('path'));

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

module.exports = Ferdi => {
  const getMessages = () => {
    const unreadSpan = document.querySelector(
      'span.flag-count.message-count.unread-count',
    );
    let directCount = 0;
    if (unreadSpan) {
      directCount = Ferdi.safeParseInt(unreadSpan.textContent);
    }
    Ferdi.setBadge(directCount);
  };
  Ferdi.loop(getMessages);

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