aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/disqus/webview.js
blob: 6e10e29317d7f29871488b8382ad3560c77edc1a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const _path = _interopRequireDefault(require('path'));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

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);
};