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

module.exports = (Franz, options) => {
  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 Franz badge
    // myQueue => New conversations in My Queue
    // missed => All missed conversations
    Franz.setBadge(myQueue, missed);
  };

  // check for new messages every second and update Franz badge
  Franz.loop(getMessages);
};