forked from koma-private/recipe-chatwork
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebview.js
41 lines (36 loc) · 1.2 KB
/
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
'use strict';
module.exports = (Franz, options) => {
function getMessages() {
let groupCount = 0;
let individualCount = 0;
let directCount = 0;
let indirectCount = 0;
let roomInfoContainer = document.querySelectorAll('div#RoomList > ul > li');
Array.prototype.forEach.call(roomInfoContainer, function (room) {
let count = 0;
let unreadBadge = room.querySelector('li._unreadBadge > span');
let unreadBadgeHasMention = false;
if (unreadBadge) {
unreadBadgeHasMention = window.getComputedStyle(room.querySelector('li._unreadBadge'), ':after').getPropertyValue('background-color') != 'rgba(0, 0, 0, 0)';
}
if (unreadBadge && unreadBadge.innerText) {
count = parseInt(unreadBadge.innerText);
}
if (0 < count) {
if (room.querySelector("img").getAttribute('src').indexOf('avatar') < 0) {
groupCount += count;
if (unreadBadgeHasMention) {
directCount++;
} else {
indirectCount++;
}
} else {
individualCount += count;
directCount++;
}
}
});
Franz.setBadge(directCount, indirectCount);
}
Franz.loop(getMessages);
}