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

    if (newsDOM && (newsDOM.includes('K') || newsDOM.includes('+'))) {
      counter = `${newsDOM.slice(0, Math.max(0, newsDOM.indexOf('K')))}000`;
    }

    Ferdi.setBadge(counter);
  };

  Ferdi.loop(getMessages);
};