diff options
author | 2021-10-05 17:04:09 +0200 | |
---|---|---|
committer | 2021-10-05 17:04:09 +0200 | |
commit | d3841b766f9d37d557646003899f67525c5f755f (patch) | |
tree | 1bcab990c94f2b05678b7a83ffebe08298500f0b /recipes/wechat/webview.js | |
parent | chore: repo maintenance (#732) (diff) | |
download | ferdium-recipes-d3841b766f9d37d557646003899f67525c5f755f.tar.gz ferdium-recipes-d3841b766f9d37d557646003899f67525c5f755f.tar.zst ferdium-recipes-d3841b766f9d37d557646003899f67525c5f755f.zip |
chore: add eslint-plugin-unicorn (#733)
Diffstat (limited to 'recipes/wechat/webview.js')
-rw-r--r-- | recipes/wechat/webview.js | 17 |
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 @@ | |||
1 | const _path = _interopRequireDefault(require('path')); | 1 | const _path = _interopRequireDefault(require('path')); |
2 | 2 | ||
3 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | 3 | function _interopRequireDefault(obj) { |
4 | return obj && obj.__esModule ? obj : { default: obj }; | ||
5 | } | ||
4 | 6 | ||
5 | module.exports = (Ferdi) => { | 7 | module.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 | ||