aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/todoist/webview.js
blob: 0dc53a9945a82131e82ab5922680acc19286c4d4 (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
30
31
32
function _interopRequireDefault(obj) {
  return obj && obj.__esModule ? obj : { default: obj };
}

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

module.exports = Ferdium => {
  function getTasks() {
    let todayCount = 0;
    let inboxCount = 0;
    const todayElement = document.querySelector(
      '#filter_today div div a + span div span',
    );
    const inboxElement = document.querySelector(
      '#filter_inbox div div a + span div span',
    );

    if (todayElement) {
      todayCount = Ferdium.safeParseInt(todayElement.textContent);
    }

    if (inboxElement) {
      inboxCount = Ferdium.safeParseInt(inboxElement.textContent);
    }

    Ferdium.setBadge(inboxCount, todayCount);
  }

  Ferdium.loop(getTasks);

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