aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/disqus/webview.js
blob: a79f5e7c45df2550c14af6dadbb440c22b9080f3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module.exports = Ferdi => {
  const getInnerInt = selector => {
    const element = document.querySelector(selector);
    return element && Ferdi.safeParseInt(element.innerText);
  };

  const getMessages = () => {
    const direct = (
      getInnerInt("header div[data-role='unread-notification-count']") ||
      getInnerInt('a.has-notifs div.notif-count') ||
      0
    );

    Ferdi.setBadge(direct);
  };

  Ferdi.loop(getMessages);
};