aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/todoist/webview.js
blob: 27b77ade06601e34b03885a3e3c7a87ddb13c617 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module.exports = Ferdium => {
  function getTasks() {
    let todayCount = 0;
    let inboxCount = 0;
    const todayElement = document.querySelector('#filter_today .item_counter');
    const inboxElement = document.querySelector('#filter_inbox .item_counter');

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

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

    Ferdium.setBadge(inboxCount, todayCount);
  }

  Ferdium.loop(getTasks);
};