aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/chatra/webview.js
blob: be4822fc908fb3afa4c7f0628bbfcd78ab38d65f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
function _interopRequireDefault(obj) {
  return obj && obj.__esModule ? obj : { default: obj };
}

const _path = _interopRequireDefault(require('path'));

module.exports = Ferdium => {
  const getMessages = () => {
    // get new conversations in My Queue
    const myQueue = $(
      '.super-nav a.super-nav__item.js-from-super-to-nav[href^="/chat/box:my"] .count',
    )
      .not('.count--gray')
      .text();

    // get all missed conversations
    const missed = $(
      '.super-nav a.super-nav__item.js-from-super-to-nav[href^="/chat/box:missed"] .count',
    ).text();

    // set Ferdium badge
    // myQueue => New conversations in My Queue
    // missed => All missed conversations
    Ferdium.setBadge(myQueue, missed);
  };

  Ferdium.loop(getMessages);

  Ferdium.injectCSS(_path.default.join(__dirname, 'service.css'));
};