aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/chatwork/webview.js
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/chatwork/webview.js')
-rw-r--r--recipes/chatwork/webview.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/recipes/chatwork/webview.js b/recipes/chatwork/webview.js
new file mode 100644
index 0000000..48a3fbf
--- /dev/null
+++ b/recipes/chatwork/webview.js
@@ -0,0 +1,38 @@
1'use strict';
2
3module.exports = (Franz, options) => {
4 function getMessages() {
5 let groupCount = 0;
6 let individualCount = 0;
7 let directCount = 0;
8 let indirectCount = 0;
9 let roomInfoContainer = document.querySelectorAll('li.sc-dnqmqq');
10 Array.prototype.forEach.call(roomInfoContainer, function (room) {
11 let count = 0;
12 let unreadBadge = room.querySelector("span.sc-kAzzGY");
13 let unreadBadgeHasMention = room.querySelector("li._unreadBadge.sc-cSHVUG");
14
15 if (unreadBadge && unreadBadge.innerText) {
16 count = parseInt(unreadBadge.innerText);
17 }
18
19 if (0 < count) {
20 if (room.querySelector("img.sc-gqjmRU").getAttribute('src').indexOf('avatar') < 0) {
21 groupCount += count;
22
23 if (unreadBadgeHasMention) {
24 directCount++;
25 } else {
26 indirectCount++;
27 }
28 } else {
29 individualCount += count;
30 directCount++;
31 }
32 }
33 });
34 Franz.setBadge(directCount, indirectCount);
35 }
36
37 Franz.loop(getMessages);
38}; \ No newline at end of file