aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/feedly/webview.js
blob: b4887bc78ff23a8062bd5c2f4efe279523f3c688 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
module.exports = Ferdium => {
  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` : Ferdium.safeParseInt(textContent);
    }

    Ferdium.setBadge(counter);
  };

  Ferdium.loop(getMessages);
};