diff options
Diffstat (limited to 'uncompressed/wechat/webview.js')
-rw-r--r-- | uncompressed/wechat/webview.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/uncompressed/wechat/webview.js b/uncompressed/wechat/webview.js new file mode 100644 index 0000000..8b81a33 --- /dev/null +++ b/uncompressed/wechat/webview.js | |||
@@ -0,0 +1,34 @@ | |||
1 | 'use strict'; | ||
2 | |||
3 | const path = require('path'); | ||
4 | |||
5 | module.exports = (Franz, options) => { | ||
6 | function getMessages() { | ||
7 | let directCount = 0; | ||
8 | let indirectCount = 0; | ||
9 | let chat_item = document.querySelectorAll('div.chat_item'); | ||
10 | |||
11 | Array.prototype.forEach.call(chat_item, function (item) { | ||
12 | let count = 0; | ||
13 | let reddot = item.querySelector("i.web_wechat_reddot_middle"); | ||
14 | let avatarImage = item.querySelector("img.img"); | ||
15 | |||
16 | if (reddot && reddot.innerText) { | ||
17 | count = parseInt(reddot.innerText); | ||
18 | } | ||
19 | |||
20 | if (avatarImage && avatarImage.getAttribute("src").search("webwxgeticon") != -1) { | ||
21 | directCount += count; | ||
22 | } else { | ||
23 | indirectCount += count; | ||
24 | } | ||
25 | }); | ||
26 | |||
27 | Franz.setBadge(directCount, indirectCount); | ||
28 | } | ||
29 | |||
30 | Franz.injectCSS(path.join(__dirname, 'service.css')); | ||
31 | |||
32 | Franz.loop(getMessages); | ||
33 | }; | ||
34 | //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlY2hhdC93ZWJ2aWV3LmpzIl0sIm5hbWVzIjpbInBhdGgiLCJyZXF1aXJlIiwibW9kdWxlIiwiZXhwb3J0cyIsIkZyYW56Iiwib3B0aW9ucyIsImdldE1lc3NhZ2VzIiwiZGlyZWN0Q291bnQiLCJpbmRpcmVjdENvdW50IiwiY2hhdF9pdGVtIiwiZG9jdW1lbnQiLCJxdWVyeVNlbGVjdG9yQWxsIiwiQXJyYXkiLCJwcm90b3R5cGUiLCJm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