-
Notifications
You must be signed in to change notification settings - Fork 0
/
webview.js
24 lines (18 loc) · 901 Bytes
/
webview.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"use strict";
module.exports = Franz => {
const getMessages = function getMessages() {
let directMessages = 0;
let indirectMessages = 0;
//const notificationElement = document.querySelector(".yj-nav-menu--primary-actions-inbox-link .unread-count");
const notificationElement = document.querySelector(".yj-notifications-indicator-count");
const newMessagesElement = document.querySelector(".yj-thread-list--new-messages-notice:not(.is-hidden) .yj-thread-list--new-message-text");
if (notificationElement && notificationElement.innerHTML.length) {
directMessages = parseInt(notificationElement.innerHTML, 10);
}
if (newMessagesElement && newMessagesElement.innerHTML.length) {
indirectMessages = parseInt(newMessagesElement.innerHTML.match(/\d+/)[0], 10);
}
Franz.setBadge(directMessages, indirectMessages);
};
Franz.loop(getMessages);
};