修复哔哩哔哩和快手评论区及回复后互动

This commit is contained in:
2026-11-28 22:49:13 +08:00
parent 48dcc6f20e
commit 681c0678b5
17 changed files with 460 additions and 225 deletions
+2 -2
View File
@@ -13,8 +13,8 @@ android {
applicationId = "com.jieliu.app"
minSdk = 26
targetSdk = 35
versionCode = 48
versionName = "0.1.47"
versionCode = 49
versionName = "0.1.48"
}
compileOptions {
@@ -472,6 +472,7 @@ class MainActivity : Activity() {
val repliesHint = label("", 14).also { comments.addView(it) }
comments.addField("确认回复后点赞", likeOnSuccess)
comments.addField("确认回复后收藏", favoriteOnSuccess)
val engagementHint = label("", 14).also { comments.addView(it) }
val library = card("内容库")
val libraryHint = label("", 14).also { library.addView(it) }
library.addView(libraries.editor)
@@ -479,6 +480,9 @@ class MainActivity : Activity() {
fun updatePlatformCopy(spec: PlatformSpec) {
val unit = spec.contentUnit
limitCaption.text = "单次任务${unit}上限"
engagementHint.text = if (spec.id == "bilibili" || spec.id == "kuaishou") {
"人工确认后,继续任务时会先核对原${unit},再补做已开启的互动。"
} else "回复确认发送后才会执行已开启的点赞或收藏。"
val showBilibiliScope = spec.id == "bilibili" && mode.selectedItemPosition == modes.indexOf(ReplyMode.TEMPLATES)
val videoComment = showBilibiliScope && bilibiliScopes.getOrNull(bilibiliScope.selectedItemPosition) == BilibiliCommentScope.VIDEO_COMMENT
bilibiliScopeFields.visibility = if (showBilibiliScope) View.VISIBLE else View.GONE
@@ -4,6 +4,7 @@ import com.jieliu.app.data.PhotoLibrary
import com.jieliu.app.task.BilibiliCommentScope
import com.jieliu.app.task.PendingComment
import com.jieliu.app.task.TemplatePhoto
import java.util.concurrent.CancellationException
internal class BilibiliAdapter(
spec: PlatformSpec,
@@ -13,7 +14,7 @@ internal class BilibiliAdapter(
private val diagnostic: (String) -> Unit,
) : PlatformAdapter {
private val navigation = BilibiliVideoNavigation(spec, ui)
private val comments = BilibiliComments(ui, navigation)
private val comments = BilibiliComments(ui, navigation, diagnostic)
private val replies = BilibiliReplies(ui, comments, photos, diagnostic)
private var openVideo: VideoContext? = null
@@ -99,30 +100,25 @@ internal class BilibiliAdapter(
BilibiliCommentScope.VIDEO_COMMENT -> replies.confirmTopLevel(video, text, photos, armedAt)
}
/** 回复确认后点击视频页操作栏的点赞和/或收藏。B 站暴露稳定资源 ID,可直接按 ID 查找。 */
override fun engage(video: VideoContext, like: Boolean, favorite: Boolean): EngagementResult {
if (!like && !favorite) return EngagementResult()
fun only(enabled: Boolean, action: EngagementAction) = if (enabled) action else EngagementAction.SKIPPED
val failed = EngagementResult(only(like, EngagementAction.FAILED), only(favorite, EngagementAction.FAILED))
return try {
ui.inspect { page ->
diagnostic("B站互动诊断 节点=${page.nodes.size} complete=${page.complete} " +
"frame_like=${page.visibleByViewId(LIKE_VIEW_ID).size} frame_fav=${page.visibleByViewId(FAVORITE_VIEW_ID).size} " +
"含赞=${page.nodes.count { "赞" in it.description || "赞" in it.text }}")
}
override fun engage(video: VideoContext, like: Boolean, favorite: Boolean): EngagementResult =
EngagementResult(
only(like, engageActionButton(ui, { page -> page.engageButton(LIKE_VIEW_ID, likeLabel) },
likePendingPrefix, engagementDonePrefix, "点赞", diagnostic)),
only(favorite, engageActionButton(ui, { page -> page.engageButton(FAVORITE_VIEW_ID, favoriteLabel) },
favoritePendingPrefix, engagementDonePrefix, "收藏", diagnostic)),
like = if (like) engageVideoAction(video, "frame_like", "点赞") else EngagementAction.SKIPPED,
favorite = if (favorite) engageVideoAction(video, "frame_fav", "收藏") else EngagementAction.SKIPPED,
)
} catch (_: Exception) {
failed
}
}
private fun UiPage.engageButton(viewId: String, label: Regex): UiNode? =
visibleByViewId(viewId).filter { it.enabled && label.matches(it.description) }.maxByOrNull { it.bounds.height() }
private fun engageVideoAction(video: VideoContext, viewId: String, action: String): EngagementAction = try {
engageActionButton(ui, { page ->
if (!navigation.matchesVideo(page, video)) return@engageActionButton null
page.visibleByViewId(viewId).singleOrNull {
it.enabled && page.bounds.contains(it.bounds) && BilibiliLabels.videoAction(it.description, action)
}
}, action, "已$action", action, diagnostic)
} catch (error: CancellationException) {
throw error
} catch (error: Exception) {
diagnostic("哔哩哔哩${action}失败 ${error.message.orEmpty()}")
EngagementAction.FAILED
}
override fun closeComments() {
if (replies.hasUnsettledEditor()) throw PlatformException("哔哩哔哩评论编辑框仍打开,请核对草稿后继续")
@@ -130,15 +126,4 @@ internal class BilibiliAdapter(
comments.close()
openVideo = null
}
private companion object {
// 视频页操作栏的点赞与收藏,描述形如「点赞,626个点赞」,已操作时加「已」前缀。
const val LIKE_VIEW_ID = "frame_like"
const val FAVORITE_VIEW_ID = "frame_fav"
val likeLabel = Regex("^已?点赞[,,]")
val favoriteLabel = Regex("^已?收藏[,,]")
const val likePendingPrefix = "点赞"
const val favoritePendingPrefix = "收藏"
const val engagementDonePrefix = "已"
}
}
@@ -8,6 +8,7 @@ import java.security.MessageDigest
internal class BilibiliComments(
private val ui: AccessibleUi,
private val navigation: BilibiliVideoNavigation,
private val diagnostic: (String) -> Unit = {},
) {
internal data class Row(
val target: CommentTarget,
@@ -53,8 +54,11 @@ internal class BilibiliComments(
override fun close() = list.close()
}
private data class MainTransition(val window: Int, val tab: UiNodeSource) : Closeable {
override fun close() = tab.close()
private data class MainTransition(val window: Int, val tab: UiNodeSource, val player: UiNodeSource) : Closeable {
override fun close() {
tab.close()
player.close()
}
}
private data class SortTransition(
@@ -82,7 +86,8 @@ internal class BilibiliComments(
if (!navigation.matchesVideo(page, video) || page.hasEditor()) return@inspect null
val tabs = page.videoTabs() ?: return@inspect null
val tab = tabs.second
val anchor = MainTransition(page.windowId, tab.retainSource())
val player = navigation.playerAnchor(page, video) ?: return@inspect null
val anchor = MainTransition(page.windowId, tab.retainSource(), player.retainSource())
try {
if (page.commentList() != null || navigation.commentEntry(page, video)?.let { ui.click(it) } == true) {
anchor
@@ -100,7 +105,10 @@ internal class BilibiliComments(
ui.inspect { page ->
if (page.windowId != proof.window || page.hasEditor()) return@inspect null
val tab = page.videoTabs()?.second ?: return@inspect null
if (!tab.hasSource(proof.tab)) return@inspect null
// Selecting the native comments tab can recreate its accessibility nodes.
if (!tab.hasSource(proof.tab) && (!tab.selected ||
navigation.playerAnchor(page, video)?.hasSource(proof.player) != true)
) return@inspect null
val list = page.commentList()?.takeIf { page.detailHeader() == null } ?: return@inspect null
MainScope(video, page.windowId, list.retainSource(), tab.retainSource(),
page.topLevelContainer(list)?.retainSource())
@@ -313,12 +321,20 @@ internal class BilibiliComments(
val opened = readOriginal(target) { _, row -> row.threadEntry?.let { ui.click(it) } == true } == true
if (!opened) return false
var movedToRoot = 0
thread = ui.await(9_000) {
ui.inspect { page ->
if (page.detailHeader() == null || page.hasEditor()) return@inspect null
var sawHeading = false
var sawList = false
var sawCompleteList = false
var sawOriginalBelowFirst = false
fun readOpenedThread(): ThreadScope? = ui.inspect { page ->
sawHeading = sawHeading || page.hasDetailHeading()
if (page.hasEditor()) return@inspect null
val list = page.detailList() ?: return@inspect null
val original = page.threadRows(list, scope.video.key, target)?.original
sawList = true
sawCompleteList = sawCompleteList || page.complete
val rows = page.parsedRows(list, scope.video.key)
val original = rows.firstOrNull()?.takeIf { it.target == target }
if (original == null) {
sawOriginalBelowFirst = sawOriginalBelowFirst || rows.any { it.target == target }
// 原评论常在滚动后才进视图,多滚几次再等。
val backward = AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD
if (movedToRoot < 3 && list.supports(backward)) {
@@ -329,11 +345,38 @@ internal class BilibiliComments(
}
ThreadScope(original.target, page.windowId, list.retainSource())
}
thread = ui.await(2_500, ::readOpenedThread)
if (thread == null && !sawHeading && !sawList) {
ui.inspect { page ->
val entry = threadEntryOnMain(page, scope, target) ?: return@inspect
val x = entry.bounds.exactCenterX()
val y = entry.bounds.exactCenterY()
val dispatched = ui.touch(x, y, x, y, 85)
diagnostic("哔哩哔哩评论详情入口触屏重试=$dispatched")
}
}
if (thread == null) thread = ui.await(6_500, ::readOpenedThread)
if (thread == null) {
diagnostic("哔哩哔哩评论详情诊断 标题=$sawHeading 列表=$sawList 完整列表=$sawCompleteList " +
"原评论位于非首行=$sawOriginalBelowFirst 向前滚动尝试=$movedToRoot")
if (!sawHeading && !sawList && ui.inspect { threadEntryOnMain(it, scope, target) != null } == true) {
return false
}
throw PlatformException("未能核对哔哩哔哩的原评论和回复详情")
}
if (thread == null) throw PlatformException("未能核对哔哩哔哩的原评论和回复详情")
return true
}
private fun threadEntryOnMain(page: UiPage, scope: MainScope, target: CommentTarget): UiNode? {
if (!page.complete || page.hasDetailHeading()) return null
val tab = page.videoTabs()?.second ?: return null
if (!tab.selected || !tab.hasSource(scope.tab)) return null
val list = mainList(page, scope) ?: return null
return page.rows(list, scope.video.key).singleOrNull { it.target == target }?.threadEntry
?.takeIf { page.bounds.contains(it.bounds) && list.bounds.contains(it.bounds) }
}
fun leaveThread(allowIntroduction: Boolean = false) {
val scope = main ?: return
val opened = thread ?: return
@@ -452,6 +495,8 @@ internal class BilibiliComments(
it.resourceId in setOf("title", "desc", "comment_title") && it.labels() == listOf("评论详情") }
}
private fun UiPage.hasDetailHeading(): Boolean = nodes.any { it.labels() == listOf("评论详情") }
private fun UiPage.detailList(): UiNode? {
BilibiliComposeComments.detail(this)?.let { return it.list }
val header = detailHeader() ?: return null
@@ -24,6 +24,11 @@ internal object BilibiliLabels {
fun detailReplyTotal(label: String): Int? = detailTotal.matchEntire(label)?.groupValues?.get(1)?.toIntOrNull()
?: replyCount(label) ?: label.toIntOrNull()?.takeIf { it >= 0 }
fun videoAction(label: String, action: String): Boolean {
val parts = label.split(',', ',', limit = 2)
return parts.size == 2 && parts[1].isNotBlank() && (parts[0] == action || parts[0] == "已$action")
}
fun replyPrompt(label: String, author: String): Boolean {
if (author.isBlank()) return false
return listOf("回复 @", "回复@", "回复 ", "回复").any { prefix ->
@@ -70,6 +70,13 @@ internal class BilibiliVideoNavigation(
playerMatches(page, expected.title, binding.author)
}
/** Native player area that can prove continuity while the selected tab hides title and uploader. */
fun playerAnchor(page: UiPage, expected: VideoContext): UiNode? {
val binding = opened ?: return null
if (expected != binding.video || page.windowId != binding.windowId) return null
return playerTabs(page)?.let { playerArea(page, it) }
}
/** Read a comment tab only from a verified video detail page and its paired intro/comment strip. */
fun commentEntry(page: UiPage, expected: VideoContext): UiNode? {
if (!matchesVideo(page, expected)) return null
@@ -358,22 +365,26 @@ internal class BilibiliVideoNavigation(
detailField(page, "author_name", tabs.strip.bounds.bottom, author) != null
}
private fun hasPlayer(page: UiPage, tabs: PlayerTabs): Boolean {
private fun hasPlayer(page: UiPage, tabs: PlayerTabs): Boolean = playerArea(page, tabs) != null
private fun playerArea(page: UiPage, tabs: PlayerTabs): UiNode? {
val area = page.nodes.singleOrNull {
it.resourceId == "video_area" && it.bounds.width() >= page.bounds.width() * .80 &&
it.bounds.height() >= page.bounds.height() * .12 && it.bounds.top < tabs.strip.bounds.top
} ?: return false
} ?: return null
val container = page.nodes.singleOrNull {
it.resourceId == "video_container" && it.isDescendantOf(area) &&
it.bounds.width() >= area.bounds.width() * .80 && area.bounds.contains(it.bounds)
} ?: return false
if (area.bounds.bottom <= tabs.strip.bounds.bottom) return true
return page.nodes.count {
} ?: return null
if (area.bounds.bottom <= tabs.strip.bounds.bottom) return area
return area.takeIf {
page.nodes.count {
it.resourceId == "control_container" && it.isDescendantOf(container) &&
it.bounds.width() >= area.bounds.width() * .80 && it.bounds.height() >= page.bounds.height() * .12 &&
it.bounds.bottom <= tabs.strip.bounds.bottom && it.bounds.top >= area.bounds.top
} == 1
}
}
private fun detailField(page: UiPage, id: String, minTop: Int, expected: String): UiNode? {
fun matches(node: UiNode): Boolean = node.bounds.bottom > minTop &&
@@ -3,6 +3,7 @@ package com.jieliu.app.platform
import com.jieliu.app.data.PhotoLibrary
import com.jieliu.app.task.PendingComment
import com.jieliu.app.task.TemplatePhoto
import java.util.concurrent.CancellationException
internal class KuaishouAdapter(
spec: PlatformSpec,
@@ -11,7 +12,7 @@ internal class KuaishouAdapter(
private val diagnostic: (String) -> Unit,
) : PlatformAdapter {
private val navigation = KuaishouNavigation(spec, ui)
private val comments = KuaishouComments(ui, navigation::matchesContent, navigation::openCommentPanel)
private val comments = KuaishouComments(ui, navigation::bindCommentWork)
private val replies = KuaishouReplies(ui, comments, photos, diagnostic)
private var openWork: VideoContext? = null
@@ -71,26 +72,20 @@ internal class KuaishouAdapter(
return replies.confirm(target, author, pending.text, pending.photos, armedAt)
}
/** 回复确认后点击作品页右侧的点赞和/或收藏。快手暴露稳定资源 ID,可直接按 ID 查找。 */
override fun engage(video: VideoContext, like: Boolean, favorite: Boolean): EngagementResult {
if (!like && !favorite) return EngagementResult()
fun only(enabled: Boolean, action: EngagementAction) = if (enabled) action else EngagementAction.SKIPPED
val failed = EngagementResult(only(like, EngagementAction.FAILED), only(favorite, EngagementAction.FAILED))
fun run(enabled: Boolean, action: KuaishouEngagementControl): EngagementAction {
if (!enabled) return EngagementAction.SKIPPED
return try {
// 评论区收起时 openWork 已清空,这里不再用它校验;按钮定位与状态翻转即是把关。
EngagementResult(
only(like, engageActionButton(ui, { page -> page.engageButton(LIKE_VIEW_ID, likeLabel) },
likePendingPrefix, engagementDonePrefix, "点赞", diagnostic)),
only(favorite, engageActionButton(ui, { page -> page.engageButton(FAVORITE_VIEW_ID, favoriteLabel) },
favoritePendingPrefix, engagementDonePrefix, "收藏", diagnostic)),
)
engageActionButton(ui, { page -> navigation.engagementButton(page, video, action) },
action.pendingPrefix, action.donePrefix, action.label, diagnostic)
} catch (cancelled: CancellationException) {
throw cancelled
} catch (_: Exception) {
failed
EngagementAction.FAILED
}
}
private fun UiPage.engageButton(viewId: String, label: Regex): UiNode? =
visibleByViewId(viewId).filter { it.enabled && label.matches(it.description) }.maxByOrNull { it.bounds.height() }
return EngagementResult(run(like, KuaishouEngagementControl.LIKE), run(favorite, KuaishouEngagementControl.FAVORITE))
}
override fun closeComments() {
if (replies.hasUnsettledEditor()) throw PlatformException("请核对快手中打开的回复草稿后继续")
@@ -98,15 +93,4 @@ internal class KuaishouAdapter(
comments.close()
openWork = null
}
private companion object {
// 作品页右侧的点赞与收藏,描述形如「未点赞,点赞4311」,已操作时前缀变「已」。
const val LIKE_VIEW_ID = "like_button"
const val FAVORITE_VIEW_ID = "collect_button"
val likeLabel = Regex("^未?点赞[,,]")
val favoriteLabel = Regex("^未?收藏[,,]")
const val likePendingPrefix = "未点赞"
const val favoritePendingPrefix = "未收藏"
const val engagementDonePrefix = "已"
}
}
@@ -7,10 +7,9 @@ import java.security.MessageDigest
internal class KuaishouComments(
private val ui: AccessibleUi,
private val matchesContent: (UiPage, VideoContext) -> Boolean,
private val openCommentPanel: (UiPage, VideoContext) -> Boolean,
private val bindWork: (UiPage, VideoContext, Boolean) -> UiNodeSource?,
) {
internal data class Panel(val root: UiNode, val list: UiNode?, val close: UiNode, val full: UiNode?, val empty: Boolean)
internal data class Panel(val host: UiNode, val list: UiNode?, val close: UiNode, val full: UiNode?, val empty: Boolean)
internal data class Row(
val target: CommentTarget,
@@ -27,13 +26,23 @@ internal class KuaishouComments(
private data class Item(val wrapper: UiNode, val kind: Kind, val row: Row?, val expand: UiNode?)
private enum class Kind { ORIGINAL, NESTED, MORE, FOLD, END, UNKNOWN }
private class Opening(val window: Int, val work: UiNodeSource) : Closeable {
override fun close() = work.close()
}
private class Session(
val video: VideoContext,
val window: Int,
val root: UiNodeSource,
val work: UiNodeSource,
val host: UiNodeSource,
) : Closeable {
override fun close() = root.close()
override fun close() {
work.close()
host.close()
}
}
private data class OpenPanel(val session: Session, val targets: List<CommentTarget>)
private var active: Session? = null
@@ -42,38 +51,63 @@ internal class KuaishouComments(
fun open(video: VideoContext): List<CommentTarget> {
check(active == null) { "请先退出上一个快手评论区" }
ui.pace()
val origin = ui.inspect { page ->
if (!matchesContent(page, video) || page.hasKuaishouCommentDraft()) return@inspect null
page.windowId.takeIf { readPanel(page) != null || openCommentPanel(page, video) }
} ?: throw PlatformException("未能核对当前快手作品及其评论入口")
active = ui.await(7_000) {
val opening = ui.await(4_000) {
ui.inspect { page ->
if (!page.complete || page.windowId != origin) return@inspect null
readPanel(page)?.let { Session(video, page.windowId, it.root.retainSource()) }
if (page.hasKuaishouCommentDraft()) return@inspect null
bindWork(page, video, readPanel(page) != null)?.let { Opening(page.windowId, it) }
}
} ?: throw PlatformException("未能核对当前快手作品及其评论入口")
val opened = opening.use { source ->
var editorBacks = 0
var lastBackAt = 0L
ui.await(7_000) {
ui.inspect { page ->
if (!page.complete || page.windowId != source.window) return@inspect null
val work = page.kuaishouWorkCard()?.takeIf { it.hasSource(source.work) } ?: return@inspect null
val panel = readPanel(page) ?: return@inspect null
if (page.hasKuaishouCommentDraft()) {
// 零条评论会自动打开首评框。返回可能先收键盘,确认空白后最多再返回一次。
if (panel.empty && editorBacks < 2 &&
(editorBacks == 0 || System.nanoTime() - lastBackAt >= EDITOR_BACK_INTERVAL_NS) &&
page.hasEmptyKuaishouFirstCommentEditor()
) {
editorBacks++
ui.back()
lastBackAt = System.nanoTime()
}
return@inspect null
}
val targets = replyTargets(page, panel, video.key)
OpenPanel(Session(video, source.window, work.retainSource(), panel.host.retainSource()), targets)
}
}
} ?: throw PlatformException("未能读取当前快手作品的评论区")
return scan()
active = opened.session
return opened.targets
}
fun scan(): List<CommentTarget> = ui.await(3_000) {
fun scan(): List<CommentTarget> = ui.await(5_000) {
ui.inspect { page ->
val session = active ?: return@inspect null
val panel = panel(page) ?: return@inspect null
if (page.hasKuaishouCommentDraft()) return@inspect null
originalRows(page, panel, session.video.key).filter { it.reply != null && !it.own }.map(Row::target)
replyTargets(page, panel, session.video.key)
}
} ?: throw PlatformException("快手评论区已变化")
fun scroll(): Boolean {
ui.pace()
val before = ui.inspect { page ->
val panel = panel(page)?.takeUnless(Panel::empty) ?: return@inspect null
val before = ui.await(4_000) {
ui.inspect { page ->
val panel = panel(page) ?: return@inspect null
if (page.hasKuaishouCommentDraft()) return@inspect null
val list = panel.list?.takeIf { it.scrollable && it.bounds.height() >= page.bounds.height() / 7 }
?: return@inspect null
val list = panel.list?.takeIf { !panel.empty && it.scrollable && it.bounds.height() >= page.bounds.height() / 7 }
?: return@inspect emptyList()
val positions = positions(page, list)
positions.takeIf { it.isNotEmpty() && ui.scrollUpInside(list.bounds) }
} ?: return false
if (positions.isEmpty()) return@inspect null
positions.takeIf { ui.scrollUpInside(list.bounds) } ?: emptyList()
}
}?.takeIf { it.isNotEmpty() } ?: return false
return ui.await(2_500) {
ui.inspect { page ->
val list = panel(page)?.list ?: return@inspect null
@@ -85,10 +119,12 @@ internal class KuaishouComments(
fun expandReceiptPanel(): Boolean {
ui.pace()
val opened = ui.inspect { page ->
val panel = panel(page) ?: return@inspect false
if (page.hasKuaishouCommentDraft()) return@inspect false
val opened = ui.await(4_000) {
ui.inspect { page ->
val panel = panel(page) ?: return@inspect null
if (page.hasKuaishouCommentDraft()) return@inspect null
panel.full?.let { ui.click(it) } ?: true
}
} == true
return opened && ui.await(3_500) {
ui.inspect { page ->
@@ -119,15 +155,18 @@ internal class KuaishouComments(
fun close() {
val session = active ?: return
ui.pace()
val closed = ui.inspect { page ->
if (page.hasKuaishouCommentDraft()) return@inspect false
if (readPanel(page) == null) return@inspect true
val panel = panel(page) ?: return@inspect false
ui.click(panel.close)
val closed = ui.await(4_000) {
ui.inspect { page ->
if (!session.matchesWork(page) || page.hasKuaishouCommentDraft()) return@inspect null
if (!page.hasCommentPanel()) return@inspect true
val panel = panel(page) ?: return@inspect null
true.takeIf { ui.click(panel.close) }
}
} == true
// 只需确认评论面板已关;再核对作品会因作者/文案识别脆弱而误判。
if (!closed || ui.await(4_000) {
ui.inspect { page -> true.takeIf { readPanel(page) == null } }
ui.inspect { page ->
true.takeIf { session.matchesWork(page) && !page.hasCommentPanel() && !page.hasKuaishouCommentDraft() }
}
} != true
) throw PlatformException("关闭快手评论区后未能核对同一作品")
active = null
@@ -136,10 +175,16 @@ internal class KuaishouComments(
fun panel(page: UiPage): Panel? {
val session = active ?: return null
if (page.windowId != session.window || !page.complete) return null
return readPanel(page)?.takeIf { it.root.hasSource(session.root) }
if (!session.matchesWork(page)) return null
// 展开及列表刷新可重建内部面板,作品卡片和外层宿主必须仍是同一原生节点。
return readPanel(page)?.takeIf { it.host.hasSource(session.host) }
}
private fun Session.matchesWork(page: UiPage): Boolean = page.complete && page.windowId == window &&
page.kuaishouWorkCard()?.hasSource(work) == true
private fun UiPage.hasCommentPanel(): Boolean = nodes.any { it.resourceId == "tabs_panel_container" }
fun <T> readThread(key: String, author: String, action: (UiPage, Panel, Thread) -> T): T? =
ui.inspect { page ->
val session = active ?: return@inspect null
@@ -151,8 +196,8 @@ internal class KuaishouComments(
}
fun ensureThread(key: String, author: String): Boolean {
val before = readThread(key, author) { _, panel, thread ->
thread.complete to (panel.full != null)
val before = ui.await(3_500) {
readThread(key, author) { _, panel, thread -> thread.complete to (panel.full != null) }
} ?: return false
if (before.first) return true
if (before.second) {
@@ -183,21 +228,22 @@ internal class KuaishouComments(
val styles = page.nodes.singleOrNull { it.resourceId == "tabs_panel_style" && it.directParent() === root }
?: return null
val close = page.nodes.singleOrNull {
it.resourceId == "tabs_panel_close" && it.labels() == listOf("关闭评论区") && it.clickable &&
it.isDescendantOf(styles) && styles.bounds.contains(it.bounds)
it.resourceId == "tabs_panel_close" && it.labels() == listOf("关闭评论区") && it.clickable && it.enabled &&
it.isDescendantOf(styles) && container.bounds.contains(it.bounds)
} ?: return null
val full = page.nodes.singleOrNull {
it.resourceId == "tabs_panel_full" && it.labels() == listOf("展开评论区") && it.clickable &&
it.directParent() === close.directParent() && styles.bounds.contains(it.bounds)
it.enabled && it.directParent() === close.directParent() && container.bounds.contains(it.bounds)
}
val heading = page.nodes.singleOrNull {
it.resourceId == "tab_text" && it.selected && commentCount.matches(it.text) &&
it.isDescendantOf(styles) && styles.bounds.contains(it.bounds)
it.isDescendantOf(styles) && container.bounds.contains(it.bounds)
} ?: return null
val empty = heading.text in setOf("0条评论", "评论0")
// 全屏切换后上层容器的坐标可能还停在半屏位置,以可操作控件与列表坐标交叉核对。
val frame = page.nodes.singleOrNull {
it.resourceId == "slide_play_comment_frame" && it.isDescendantOf(root) &&
it.bounds.top >= styles.bounds.bottom && root.bounds.contains(it.bounds)
it.bounds.top >= maxOf(close.bounds.bottom, heading.bounds.bottom) && container.bounds.contains(it.bounds)
} ?: return null
val list = page.nodes.singleOrNull {
it.resourceId == "recycler_view" && it.className == "androidx.recyclerview.widget.RecyclerView" &&
@@ -205,9 +251,13 @@ internal class KuaishouComments(
it.bounds.width() >= frame.bounds.width() * .9
}
if (!empty && list == null) return null
return Panel(root, list, close, full, empty)
return Panel(container, list, close, full, empty)
}
private fun replyTargets(page: UiPage, panel: Panel, key: String): List<CommentTarget> =
if (panel.empty) emptyList() else originalRows(page, panel, key)
.filter { it.reply != null && !it.own }.map(Row::target)
private fun originalRows(page: UiPage, panel: Panel, key: String): List<Row> =
visibleItems(page, panel, key).filter { it.kind == Kind.ORIGINAL }.mapNotNull(Item::row)
@@ -334,6 +384,7 @@ internal class KuaishouComments(
.joinToString("") { "%02x".format(it) }
private companion object {
const val EDITOR_BACK_INTERVAL_NS = 1_000_000_000L
val commentCount = Regex("(?:\\d+(?:\\.\\d+)?万?条评论|评论\\d+(?:\\.\\d+)?万?)")
val moreReplies = Regex("展开[1-9]\\d*条回复")
val timeIds = setOf("comment_created_time_and_loc", "comment_caption_meta_info")
@@ -13,7 +13,7 @@ internal class KuaishouNavigation(private val spec: PlatformSpec, private val ui
val identity: Pair<String, String> get() = author to date
}
private data class Player(val kind: Kind, val author: String, val date: String, val caption: String,
val comment: UiNode, val back: UiNode) {
val card: UiNode, val comment: UiNode, val back: UiNode) {
fun matches(card: Card): Boolean = author == card.author && date == card.date
}
private data class Work(val context: VideoContext, val kind: Kind, val window: Int)
@@ -72,14 +72,27 @@ internal class KuaishouNavigation(private val spec: PlatformSpec, private val ui
return openNext(if (work.kind == Kind.IMAGE) Kind.VIDEO else Kind.IMAGE)
}
fun matchesContent(page: UiPage, expected: VideoContext): Boolean {
val work = active?.takeIf { it.context == expected && it.window == page.windowId } ?: return false
val player = page.player() ?: return false
return player.kind == work.kind && player.context() == expected
fun matchesContent(page: UiPage, expected: VideoContext): Boolean = checkedPlayer(page, expected) != null
private fun checkedPlayer(page: UiPage, expected: VideoContext): Player? {
val work = active?.takeIf { it.context == expected && it.window == page.windowId } ?: return null
return page.player()?.takeIf { it.kind == work.kind && it.context() == expected }
}
fun openCommentPanel(page: UiPage, expected: VideoContext): Boolean =
matchesContent(page, expected) && page.player()?.comment?.let { ui.click(it) } == true
fun bindCommentWork(page: UiPage, expected: VideoContext, panelOpen: Boolean): UiNodeSource? {
val player = checkedPlayer(page, expected) ?: return null
if (!panelOpen && !ui.click(player.comment)) return null
return player.card.retainSource()
}
fun engagementButton(page: UiPage, expected: VideoContext, action: KuaishouEngagementControl): UiNode? {
if (page.hasKuaishouCommentDraft() || page.nodes.any { it.resourceId == "tabs_panel_close" }) return null
val player = checkedPlayer(page, expected) ?: return null
return page.nodes.singleOrNull { node ->
node.resourceId == action.viewId && node.isDescendantOf(player.card) &&
node.kuaishouAction() && player.card.bounds.contains(node.bounds) && action.matches(node.description)
}
}
private fun openSearch() {
repeat(6) {
@@ -286,10 +299,7 @@ internal class KuaishouNavigation(private val spec: PlatformSpec, private val ui
private fun UiPage.player(): Player? {
if (!complete) return null
val pager = nodes.singleOrNull { it.resourceId == "nasa_groot_view_pager" &&
it.bounds.width() >= bounds.width() * .85 } ?: return null
val card = nodes.singleOrNull { it.directParent() === pager && it.resourceId == "root" &&
it.bounds.width() >= pager.bounds.width() * .85 } ?: return null
val card = kuaishouWorkCard() ?: return null
val image = card.description == "查看图片详情" || nodes.any { it.directParent() === card &&
it.resourceId == "autoplay_cover_view_page_style" }
val video = nodes.any { it.directParent() === card && it.resourceId == "player" }
@@ -305,7 +315,7 @@ internal class KuaishouNavigation(private val spec: PlatformSpec, private val ui
it.kuaishouAction() && it.description.startsWith("评论") } ?: return null
val back = nodes.singleOrNull { it.resourceId == "photo_detail_back_btn" && it.kuaishouAction() &&
it.bounds.left < x(.16f) && it.bounds.bottom < y(.16f) } ?: return null
return Player(if (image) Kind.IMAGE else Kind.VIDEO, author, date, caption, comment, back)
return Player(if (image) Kind.IMAGE else Kind.VIDEO, author, date, caption, card, comment, back)
}
private fun Player.context(): VideoContext {
@@ -316,4 +326,22 @@ internal class KuaishouNavigation(private val spec: PlatformSpec, private val ui
}
}
internal fun UiPage.kuaishouWorkCard(): UiNode? {
val pager = nodes.singleOrNull { it.resourceId == "nasa_groot_view_pager" &&
it.bounds.width() >= bounds.width() * .85 } ?: return null
return nodes.singleOrNull { it.directParent() === pager && it.resourceId == "root" &&
it.bounds.width() >= pager.bounds.width() * .85 }
}
internal enum class KuaishouEngagementControl(val viewId: String, val label: String) {
LIKE("like_button", "点赞"),
FAVORITE("collect_button", "收藏");
val pendingPrefix = "未$label"
val donePrefix = "已$label"
private val description = Regex("(?:$pendingPrefix|$donePrefix)[,,]$label(?:\\d+(?:\\.\\d+)?[万亿]?)?")
fun matches(value: String): Boolean = description.matches(value)
}
private fun UiNode.kuaishouAction(): Boolean = enabled && clickable && !editable
@@ -229,12 +229,7 @@ internal class KuaishouReplies(
}
private fun readEditor(page: UiPage, target: CommentTarget): Editor? {
if (!page.complete) return null
val container = page.nodes.singleOrNull {
it.resourceId == "editor_animation_frame" && page.bounds.contains(it.bounds) &&
generateSequence(it.directParent(), UiNode::directParent).take(6)
.any { ancestor -> ancestor.resourceId == "comment_editor_container" }
} ?: return null
val container = page.kuaishouEditorContainer() ?: return null
val members = page.nodes.filter { it.isDescendantOf(container) && container.bounds.contains(it.bounds) }
val input = members.singleOrNull {
it.resourceId == "editor" && it.className == "android.widget.EditText" && it.editable &&
@@ -260,7 +255,7 @@ internal class KuaishouReplies(
private fun readDraftImages(members: List<UiNode>, input: UiNode): List<DraftImage>? {
val grids = members.filter { it.resourceId == "multi_picture_recycler_view" }
if (grids.isEmpty()) {
return emptyList<DraftImage>().takeIf { members.none { it.resourceId in attachmentNodes } }
return emptyList<DraftImage>().takeIf { members.none { it.resourceId in kuaishouDraftAttachmentIds } }
}
val grid = grids.singleOrNull()?.takeIf {
it.className == "androidx.recyclerview.widget.RecyclerView" && it.bounds.bottom <= input.bounds.top &&
@@ -409,10 +404,38 @@ internal class KuaishouReplies(
const val RECEIPT_REWIND_SCREENS = 4
const val RECEIPT_SCREENS = 13
val relativeTime = Regex("([1-9]\\d?)\\s*(秒|分钟)前(?:\\s+\\S+)?")
val attachmentNodes = setOf("preview_image_layout", "preview_image", "preview_close", "comment_image")
}
}
private fun UiPage.kuaishouEditorContainer(): UiNode? {
if (!complete) return null
return nodes.singleOrNull {
it.resourceId == "editor_animation_frame" && bounds.contains(it.bounds) &&
generateSequence(it.directParent(), UiNode::directParent).take(6)
.any { ancestor -> ancestor.resourceId == "comment_editor_container" }
}
}
internal fun UiPage.hasEmptyKuaishouFirstCommentEditor(): Boolean {
val container = kuaishouEditorContainer() ?: return false
val members = nodes.filter { it.isDescendantOf(container) && container.bounds.contains(it.bounds) }
val input = members.singleOrNull {
it.resourceId == "editor" && it.className == "android.widget.EditText" && it.editable && it.focused &&
it.directParent()?.resourceId == "edit_container" &&
it.hint.ifBlank { if (it.showingHint) it.text else "" } == "快来抢首评吧"
} ?: return false
val send = members.singleOrNull {
it.resourceId == "finish_button" && it.className == "android.widget.Button" &&
it.labels() == listOf("发送") && it.directParent()?.resourceId == "finish_button_wrapper"
} ?: return false
return !send.enabled && members.none { it.resourceId in kuaishouDraftAttachmentIds } &&
input.isStillBlankAndFocused()
}
private val kuaishouDraftAttachmentIds = setOf(
"multi_picture_recycler_view", "preview_image_layout", "preview_image", "preview_close", "comment_image",
)
internal fun UiPage.hasKuaishouCommentDraft(): Boolean = nodes.any { node ->
node.resourceId == "editor_animation_frame" ||
(node.resourceId == "finish_button" && node.enabled && node.labels() == listOf("发送") &&
@@ -31,9 +31,8 @@ data class EngagementResult(
)
/**
* 点击一次操作栏按钮并等待状态前缀翻到 donePrefix。
* 找不到按钮、触屏未派发、状态未翻转都算失败;已是目标状态返回 SKIPPED,不重复点击以免误取消。
* 按钮由 [find] 在每次重试时重新定位,返回的节点只取其描述与坐标,不跨快照持有节点引用。
* 确认按钮仍属于当前内容,并在待操作状态下最多尝试一次点击。
* 手势回调可能超时,尝试点击后只读回按钮状态,避免延迟更新时再次点击取消操作。
*/
internal fun engageActionButton(
ui: AccessibleUi,
@@ -43,57 +42,32 @@ internal fun engageActionButton(
name: String,
diagnostic: (String) -> Unit,
): EngagementAction {
var clicked = false
repeat(2) {
ui.pace()
val button = ui.inspect(find)
val button = ui.await(3_000) {
ui.inspect { page -> find(page)?.let { it.description to it.bounds } }
}
if (button == null) {
diagnostic("${name}未找到按钮")
return@repeat
return EngagementAction.FAILED
}
if (button.description.startsWith(donePrefix)) {
diagnostic("${name}已是目标状态 ${button.description}")
return if (clicked) EngagementAction.DONE else EngagementAction.SKIPPED
}
if (!button.description.startsWith(pendingPrefix)) {
diagnostic("${name}状态无法识别 ${button.description}")
val (description, bounds) = button
if (description.startsWith(donePrefix)) {
diagnostic("${name}已是目标状态 $description")
return EngagementAction.SKIPPED
}
// 这类按钮的无障碍 ACTION_CLICK 常被系统接受却不触发业务逻辑,一律用真实触屏。
val x = button.bounds.exactCenterX()
val y = button.bounds.exactCenterY()
if (!description.startsWith(pendingPrefix)) {
diagnostic("${name}状态无法识别 $description")
return EngagementAction.FAILED
}
val x = bounds.exactCenterX()
val y = bounds.exactCenterY()
val dispatched = ui.touch(x, y, x, y, 85)
diagnostic("${name}触屏($x,$y)=$dispatched")
if (!dispatched) return@repeat
clicked = true
// 小红书等平台的状态翻转有延迟,核对窗口放宽。
val flipped = ui.await(5_000) {
ui.inspect { page ->
val current = find(page)
if (current == null) null else true.takeIf {
!current.description.startsWith(pendingPrefix) && current.description.startsWith(donePrefix)
}
}
}
diagnostic("${name}核对=${flipped == true}")
if (flipped == true) return EngagementAction.DONE
// 部分平台(如小红书)只认无障碍 ACTION_CLICK,触屏打偏时补一次。
val acted = ui.inspect { page -> find(page)?.act(android.view.accessibility.AccessibilityNodeInfo.ACTION_CLICK) }
diagnostic("${name}ACTION_CLICK=$acted")
if (acted == true) {
val flippedByAction = ui.await(5_000) {
ui.inspect { page ->
val current = find(page)
if (current == null) null else true.takeIf {
!current.description.startsWith(pendingPrefix) && current.description.startsWith(donePrefix)
}
}
}
diagnostic("${name}核对2=${flippedByAction == true}")
if (flippedByAction == true) return EngagementAction.DONE
}
}
return EngagementAction.FAILED
ui.inspect { page -> true.takeIf { find(page)?.description?.startsWith(donePrefix) == true } }
} == true
diagnostic("${name}核对=$flipped")
return if (flipped) EngagementAction.DONE else EngagementAction.FAILED
}
class PlatformException(message: String, cause: Throwable? = null) : RuntimeException(message, cause)
@@ -42,6 +42,14 @@ internal class TaskRunner(
checkpoint = next
}
var launched = false
fun launchPlatform() {
if (launched) return
status("正在打开目标应用")
platform.launch()
launched = true
}
try {
if (recheckPending) {
val receiptsBefore = checkpoint.receipts.size
@@ -50,7 +58,6 @@ internal class TaskRunner(
persist(checkpoint.recordReply(Outcome.SENT))
store.appendLog("自动核对回复成功,已确认发送")
engagementFor(checkpoint, receiptsBefore)?.let { (like, favorite) ->
platform.closeComments()
engageContent("已核对的$contentUnit", VideoContext(pending.videoKey, pending.title), like, favorite)
}
} else {
@@ -65,15 +72,30 @@ internal class TaskRunner(
if (engagement.like || engagement.favorite) {
status("正在补做${contentUnit}的点赞收藏")
store.appendLog("补做人工确认回复的点赞收藏")
// 人工确认时平台仍停在该内容上,直接原地互动;重新搜索定位在小红书/B 站上并不可靠。
val video = VideoContext(engagement.videoKey, engagement.title)
val onScreen = try {
platform.currentVideo().key == engagement.videoKey
platform.currentVideo().takeIf { it.key == engagement.videoKey }
} catch (error: CancellationException) {
throw error
} catch (_: Exception) {
false
null
}
if (onScreen) {
platform.closeComments()
val video = onScreen ?: if ((bilibili || plan.platformId == "kuaishou") &&
engagement.contentTypeName.isNotBlank()
) {
try {
launchPlatform()
status("正在重新定位待互动的$contentUnit")
locateVideo(platform.search(engagement.contentTypeName), checkpoint, engagement.videoKey)
} catch (error: CancellationException) {
throw error
} catch (_: PlatformException) {
null
} catch (_: IllegalStateException) {
null
}
} else null
requireRunning(cancelled)
if (video != null) {
engageContent("已确认的$contentUnit", video, engagement.like, engagement.favorite)
} else {
store.appendLog("补做互动时已不在原${contentUnit},未执行点赞收藏", warning = true)
@@ -85,8 +107,7 @@ internal class TaskRunner(
val quota = if (mode == ReplyMode.TEMPLATES) " · 每个${contentUnit}最多 ${plan.repliesPerVideo} 条${if (videoComment) "评论" else "回复"}" else ""
val modeLabel = if (bilibili && mode == ReplyMode.TEMPLATES) plan.bilibiliCommentScope.label else mode.label
store.appendLog("开始任务 · $modeLabel · ${plan.limit} 个$contentUnit$quota")
status("正在打开目标应用")
platform.launch()
if (!checkpoint.complete) launchPlatform()
var activeTypeId: String? = null
var video: VideoContext? = null
while (!checkpoint.complete) {
@@ -159,8 +180,10 @@ internal class TaskRunner(
store.appendLog("第 $number 条$contentUnit$summary")
}
val engage = engagementFor(checkpoint, receiptsBefore)
if (openPanel && (!checkpoint.complete || engage != null)) platform.closeComments()
engage?.let { (like, favorite) -> engageContent("第 $number 条$contentUnit", candidate, like, favorite) }
if (openPanel && !checkpoint.complete) platform.closeComments()
engage?.let { (like, favorite) ->
engageContent("第 $number 条$contentUnit", candidate, like, favorite, closePanel = openPanel && checkpoint.complete)
}
}
store.appendLog("任务完成 · 处理 ${checkpoint.receipts.size} 条 · 确认发送 ${checkpoint.sentCount} 条")
} catch (error: Exception) {
@@ -305,9 +328,13 @@ internal class TaskRunner(
}
/** 回复确认后对内容点赞和/或收藏。失败只记录日志,不中断任务。 */
private fun engageContent(prefix: String, video: VideoContext, like: Boolean, favorite: Boolean) {
private fun engageContent(prefix: String, video: VideoContext, like: Boolean, favorite: Boolean, closePanel: Boolean = true) {
val result = try {
requireRunning(cancelled)
if (closePanel) platform.closeComments()
platform.engage(video, like, favorite)
} catch (error: CancellationException) {
throw error
} catch (_: Exception) {
EngagementResult(
like = if (like) EngagementAction.FAILED else EngagementAction.SKIPPED,
@@ -22,6 +22,15 @@ class BilibiliLabelsTest {
assertNull(BilibiliLabels.replyCount("展开更多评论"))
}
@Test fun recognizesVideoActionWithItsFullDescription() {
assertTrue(BilibiliLabels.videoAction("点赞,626个点赞", "点赞"))
assertTrue(BilibiliLabels.videoAction("收藏,1267个收藏", "收藏"))
assertTrue(BilibiliLabels.videoAction("已点赞,627个点赞", "点赞"))
assertTrue(BilibiliLabels.videoAction("已收藏,1268个收藏", "收藏"))
assertFalse(BilibiliLabels.videoAction("已关注,UP主", "点赞"))
assertFalse(BilibiliLabels.videoAction("点赞,", "点赞"))
}
@Test fun recognizesRotatingTopLevelPlaceholdersAndRejectsOtherEditors() {
assertTrue(BilibiliComposeComments.isTopLevelPrompt("万水千山总是情,评论两句行不行"))
assertTrue(BilibiliComposeComments.isTopLevelPrompt("轻轻敲醒沉睡的心灵,让我看看你的点评"))
@@ -0,0 +1,23 @@
package com.jieliu.app.platform
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
class KuaishouEngagementTest {
@Test fun acceptsLikeLabelsBeforeAndAfterTheStateChanges() {
val control = KuaishouEngagementControl.LIKE
assertTrue(control.matches("未点赞,点赞4311"))
assertTrue(control.matches("已点赞,点赞2.3万"))
assertFalse(control.matches("未点赞,"))
assertFalse(control.matches("未点赞,收藏1"))
}
@Test fun acceptsFavoriteLabelsWithAnOmittedOrDisplayedCount() {
val control = KuaishouEngagementControl.FAVORITE
assertTrue(control.matches("未收藏,收藏"))
assertTrue(control.matches("已收藏,收藏1"))
assertFalse(control.matches("已收藏"))
assertFalse(control.matches("已关注,收藏1"))
}
}
@@ -610,6 +610,57 @@ class TaskRunnerTest {
assertNull(store.checkpoint.pendingEngagement)
}
@Test fun pendingEngagementRelocatesTheExactBilibiliAndKuaishouContent() {
for (platformId in listOf("bilibili", "kuaishou")) {
val plan = plan(firstType).copy(platformId = platformId, likeOnSuccess = true)
val store = RecordingStore(TaskCheckpoint("relocate-$platformId", plan).copy(
receipts = listOf(Receipt("video-1", Outcome.USER_CONFIRMED)),
pendingEngagement = PendingEngagement("video-1", "样片", firstType.name, like = true, favorite = false),
))
val platform = FakePlatform(store)
execute(store, platform)
assertEquals(listOf(firstType.name), platform.searches)
assertEquals(1, platform.launches)
assertEquals(listOf(Triple("video-1", true, false)), platform.engagements)
assertTrue(platform.openedVideos.isEmpty())
assertEquals(0, platform.publishCalls)
assertTrue(store.checkpoint.complete)
}
}
@Test fun pendingEngagementDoesNotTouchAnUnrelatedSearchResult() {
val plan = plan(firstType).copy(platformId = "kuaishou", favoriteOnSuccess = true)
val store = RecordingStore(TaskCheckpoint("unmatched-engagement", plan).copy(
receipts = listOf(Receipt("missing-work", Outcome.USER_CONFIRMED)),
pendingEngagement = PendingEngagement("missing-work", "原作品", firstType.name, like = false, favorite = true),
))
val platform = FakePlatform(store)
execute(store, platform)
assertEquals(listOf(firstType.name), platform.searches)
assertTrue(platform.engagements.isEmpty())
assertTrue(store.logs.any { "未执行点赞收藏" in it })
assertTrue(store.checkpoint.complete)
}
@Test fun finalCommentCloseFailureKeepsTheConfirmedReceipt() {
val plan = plan(firstType).copy(platformId = "bilibili", favoriteOnSuccess = true)
val store = RecordingStore(TaskCheckpoint("close-failure", plan))
val platform = FakePlatform(store, listOf(listOf(target("match", "API 充值怎么付?")))).apply {
closeThrows = true
}
execute(store, platform)
assertEquals(listOf(Outcome.SENT), store.checkpoint.receipts.map { it.outcome })
assertTrue(platform.engagements.isEmpty())
assertTrue(store.logs.any { "收藏失败" in it })
assertTrue(store.logs.any { "任务完成" in it })
}
private fun execute(store: RecordingStore, platform: FakePlatform, recheckPending: Boolean = false) {
val initial = store.checkpoint
TaskRunner(store, initial.plan, platform, { false }) {}.run(initial, recheckPending = recheckPending)
@@ -655,6 +706,7 @@ class TaskRunnerTest {
val engagements = mutableListOf<Triple<String, Boolean, Boolean>>()
var engageOutcome = EngagementResult(EngagementAction.DONE, EngagementAction.DONE)
var engageThrows = false
var closeThrows = false
var closesComments = 0
val unidentifiableVideos = mutableSetOf<String>()
val unavailable = mutableSetOf<String>()
@@ -765,6 +817,7 @@ class TaskRunnerTest {
override fun closeComments() {
closesComments++
if (closeThrows) throw PlatformException("评论区未关闭")
}
private fun showVideo(title: String): VideoContext {
+4 -1
View File
@@ -450,7 +450,7 @@
<div><dt><label for="favorite-on-success">确认回复后收藏</label></dt><dd><select id="favorite-on-success" class="control settings-input"><option>关闭</option><option>开启</option></select></dd></div>
</dl>
<p class="hint" id="reply-scope-hint">达到回复上限或找不到更多匹配评论时,进入下一个视频。</p>
<p class="hint" id="engage-hint">仅在该视频的回复已确认发送后点赞和收藏,失败只记录日志。</p>
<p class="hint" id="engage-hint">回复确认发送后才会执行已开启的点赞或收藏。</p>
</div>
<div class="card" id="content-library">
<h3>内容库</h3>
@@ -774,6 +774,9 @@
byId("content-limit-label").textContent = `单次任务${unit}上限`;
byId("reply-limit-label").textContent = `每条${unit}${videoComment ? "评论发布" : "回复"}上限`;
byId("reply-scope-hint").textContent = `达到${operation}上限或找不到更多匹配评论时,进入下一个${unit}。`;
byId("engage-hint").textContent = ["bilibili", "kuaishou"].includes(platformPicker.value)
? `人工确认后,继续任务时会先核对原${unit},再补做已开启的互动。`
: "回复确认发送后才会执行已开启的点赞或收藏。";
byId("content-scope-hint").textContent = platformPicker.value === "kuaishou"
? "按内容类型搜索,轮流处理「图片」和「视频」中的作品。每个关键词可配置多条话术。"
: `按内容类型搜索${unit},按关键词匹配评论。每个关键词可配置多条话术。`;
+11 -1
View File
@@ -1,6 +1,16 @@
# 拾见开发进度
最近更新于 2026-11-28 22:23(UTC+8)。以下按开发轮次倒序记录。
最近更新于 2026-11-28 22:48(UTC+8)。以下按开发轮次倒序记录。
## 2026-11-28 · 拾见 0.1.48 哔哩哔哩和快手评论区恢复
- 哔哩哔哩切换到评论标签后,如果原生标签节点重建,同窗口内先核对切换前绑定的原视频播放器,再接续评论列表。点开回复入口后若仍停在原列表,只有重新核对同一列表和原评论才会触屏补试一次。回复详情仍按原评论身份核对。
- 快手评论区展开时,以实际关闭按钮、评论标题和列表的位置核对布局,并用同一作品、窗口和评论宿主处理节点重建。零评论作品自动弹出首评框时,确认原生首评提示、空输入、发送禁用且无附件后才退出空框,继续处理后续作品。真实草稿、定向回复框和含附件的编辑框均保留。
- 哔哩哔哩和快手分别按各自开启的点赞、收藏开关执行,支持原生按钮带计数的标签,查找按钮时重新核对原内容。共用按钮逻辑只尝试一次触屏,再读取状态,避免手势回调超时后重复操作。人工确认后继续任务时,可按已保存的内容类型重新搜索,并用原内容标识校验待互动对象。
- 浏览器预览已同步人工确认后的说明。离线 Chrome 在 1440×975 和 390×880 下通过两个平台的说明切换,配置、内容库和图片绑定回归均通过。[界面预览](ui-preview.html)
- vivo Android 12 真机复验通过。哔哩哔哩 9.21.0 在 2 个视频打开并核对 3 个原评论线程,关闭后回到同一视频。快手 14.10.40.51486 核对 4 个作品,图文与视频共滚动 9 次并展开全屏评论,零评论视频正常关闭首评框并继续。已核对快手配置页的两个开关与说明文本,恢复手机网络和无障碍设置,设置、检查点及运行日志的校验值一致。
- 最终调试 APK 离线构建成功,通过 v2 签名,装机 APK 与本地 SHA-256 一致。91 项 JVM 单元测试通过,Lint 为 0 个错误、5 个既有警告。哔哩哔哩与快手各 9 组离线回放通过,覆盖节点重建、评论线程校验、图片回执和错误页面拒绝等场景。
- 待验证项为两平台使用新版本公开发送回复,以及点赞和收藏的平台状态变化。本轮真机验证覆盖浏览、评论区、原评论线程与互动按钮读取,回复回执和互动条件另以归档快照及单元测试验证。
## 2026-11-28 · 拾见 0.1.47 回复确认后点赞收藏