aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/skiff-mail/webview.js
blob: 522b0626626ad25870d2a17abeb60d8d5a27e1a2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
const _path = _interopRequireDefault(require('path'));

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

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'));
};