aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/stackoverflow-chat/webview.js
blob: cf487b567f32629d6f2e9c2e153b7a63eb66cce2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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.innerText);
    }
    Ferdi.setBadge(directCount);
  };
  Ferdi.loop(getMessages);

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