aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/jira/webview.js
blob: aca65be5a73e932d1d11084c97e4bb8fa4e356fc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
module.exports = (Franz) => {
  const getMessages = function getMessages() {
    // get unread messages
    const element = document.querySelector('#atlassian-navigation-notification-count span');
    let count = element ? element.innerText : 0;
    count = parseInt(count, 10);

    // set Franz badge
    Franz.setBadge(count);
  };

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