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

module.exports = Ferdi => {
  const getMessages = function 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);
};