aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/wechat/webview.js
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/wechat/webview.js')
-rw-r--r--recipes/wechat/webview.js17
1 files changed, 11 insertions, 6 deletions
diff --git a/recipes/wechat/webview.js b/recipes/wechat/webview.js
index d75bd72..e7de1f1 100644
--- a/recipes/wechat/webview.js
+++ b/recipes/wechat/webview.js
@@ -1,23 +1,28 @@
1const _path = _interopRequireDefault(require('path')); 1const _path = _interopRequireDefault(require('path'));
2 2
3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3function _interopRequireDefault(obj) {
4 return obj && obj.__esModule ? obj : { default: obj };
5}
4 6
5module.exports = (Ferdi) => { 7module.exports = Ferdi => {
6 const getMessages = () => { 8 const getMessages = () => {
7 let directCount = 0; 9 let directCount = 0;
8 let indirectCount = 0; 10 let indirectCount = 0;
9 const chat_item = document.querySelectorAll('div.chat_item'); 11 const chat_item = document.querySelectorAll('div.chat_item');
10 12
11 Array.prototype.forEach.call(chat_item, (item) => { 13 Array.prototype.forEach.call(chat_item, item => {
12 let count = 0; 14 let count = 0;
13 const reddot = item.querySelector('i.web_wechat_reddot_middle'); 15 const reddot = item.querySelector('i.web_wechat_reddot_middle');
14 const avatarImage = item.querySelector('img.img'); 16 const avatarImage = item.querySelector('img.img');
15 17
16 if (reddot) { 18 if (reddot) {
17 count = Ferdi.safeParseInt(reddot.innerText); 19 count = Ferdi.safeParseInt(reddot.textContent);
18 } 20 }
19 21
20 if (avatarImage && avatarImage.getAttribute('src').search('webwxgeticon') != -1) { 22 if (
23 avatarImage &&
24 avatarImage.getAttribute('src').search('webwxgeticon') != -1
25 ) {
21 directCount += count; 26 directCount += count;
22 } else { 27 } else {
23 indirectCount += count; 28 indirectCount += count;
@@ -25,7 +30,7 @@ module.exports = (Ferdi) => {
25 }); 30 });
26 31
27 Ferdi.setBadge(directCount, indirectCount); 32 Ferdi.setBadge(directCount, indirectCount);
28 } 33 };
29 34
30 Ferdi.loop(getMessages); 35 Ferdi.loop(getMessages);
31 36