aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/anydo/webview.js
blob: cdb7e4f15078a8a4fc0525bf6d88d0250c69c8bf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module.exports = (Ferdi) => {
  function getTasks() {
    let incompleteCount = 0;

    const countEls = document.querySelectorAll('.AppSidebarListsItems__itemContainer__sizeContainer:not([hidden]) > .AppSidebarListsItems__itemContainer__size');

    if (countEls.length) {
      Array.from(countEls).forEach((el) => {
        incompleteCount += parseInt(el.innerHTML, 10);
      });
    }

    Ferdi.setBadge(incompleteCount);
  }

  Ferdi.loop(getTasks);
};