aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/skiff-mail/webview.js
blob: 272614590536a24380f9a053dd35d2f68a6c6370 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function _interopRequireDefault(obj) {
  return obj && obj.__esModule ? obj : { default: obj };
}

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

module.exports = Ferdium => {
  const getMessages = () => {
    const element = document.querySelector('div[href="/mail/inbox"]');
    const matches = element.textContent.match(/\d+/);
    const unreadCount = Ferdium.safeParseInt(matches ? matches[0] : 0);
    Ferdium.setBadge(unreadCount);
  };
  Ferdium.loop(getMessages);

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