aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/feedly/webview.js
blob: c1108ffce18601b54de62f2e5a1b919c84debe2b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
module.exports = Ferdi => {
  const getMessages = () => {
    const newsDOM = document.querySelectorAll(
      "div[title='All'] > .LeftnavListRow__count",
    );

    let counter = 0;

    if (newsDOM && newsDOM.length > 0) {
      const textContent = newsDOM[0].textContent;

      counter = textContent.includes('K') || textContent.includes('+') ? `${textContent.slice(0, Math.max(0, textContent.indexOf('K')))}000` : Ferdi.safeParseInt(textContent);
    }

    Ferdi.setBadge(counter);
  };

  Ferdi.loop(getMessages);
};