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

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

    if (countEls.length > 0) {
      for (const el of countEls) {
        incompleteCount += Ferdi.safeParseInt(el.textContent);
      }
    }

    Ferdi.setBadge(incompleteCount);
  }

  Ferdi.loop(getTasks);
};