Skip to content

Commit

Permalink
微信列表自动点击未读聊天
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyJiangWJ committed Sep 24, 2020
1 parent 4bc51f2 commit 2e0b8a0
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions unit/自动点击微信列表未读数据.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
let sRequire = require('../lib/SingletonRequirer')(runtime, this)
let automator = sRequire('Automator')
let widgetUtils = sRequire('WidgetUtils')
let logUtils = sRequire('LogUtils')

let bottomWidget = widgetUtils.widgetGetById('com.tencent.mm:id/czl')
let bottomHeight = device.height - 160
if (bottomWidget) {
bottomHeight = bottomWidget.bounds().top
}

function checkAndClick() {
let target = widgetUtils.widgetGetById('com.tencent.mm:id/ga3')
if (target && target.bounds().top < bottomHeight) {
automator.clickCenter(target)
sleep(1000)
automator.back()
return true
} else {
return false
}
}

function getUnreadInfo() {
let target = widgetUtils.widgetGetById('android:id/text1')
if (target) {
let content = target.desc() || target.text()
let regex = /微信.*(\d+)/
if (regex.test(content)) {
let unreadCount = parseInt(regex.exec(content)[1])
logUtils.debugInfo(['未读数据: {}', unreadCount])
return unreadCount
} else {
logUtils.warnInfo(['未匹配到未读数据: {}', content])
}
}
logUtils.debugInfo(['未找到未读数据'])
return 0
}

while (getUnreadInfo() > 0) {
while(checkAndClick()) {
sleep(500)
}
automator.scrollDown()
}

0 comments on commit 2e0b8a0

Please sign in to comment.