aboutsummaryrefslogtreecommitdiffstats
path: root/uncompressed/chatwork/webview.js
diff options
context:
space:
mode:
authorLibravatar vantezzen <hello@vantezzen.io>2019-09-28 12:10:25 +0200
committerLibravatar vantezzen <hello@vantezzen.io>2019-09-28 12:10:25 +0200
commit728d339739b63e9bb59e457e4a84fe9a65b93fc9 (patch)
treea0fc6180ea26fa9ef397458e8eb6491031d6437d /uncompressed/chatwork/webview.js
parentAdd list of recipes (diff)
downloadferdium-recipes-728d339739b63e9bb59e457e4a84fe9a65b93fc9.tar.gz
ferdium-recipes-728d339739b63e9bb59e457e4a84fe9a65b93fc9.tar.zst
ferdium-recipes-728d339739b63e9bb59e457e4a84fe9a65b93fc9.zip
Add uncompressed recipes
Diffstat (limited to 'uncompressed/chatwork/webview.js')
-rw-r--r--uncompressed/chatwork/webview.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/uncompressed/chatwork/webview.js b/uncompressed/chatwork/webview.js
new file mode 100644
index 0000000..48a3fbf
--- /dev/null
+++ b/uncompressed/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