Skip to content

Commit

Permalink
fix: comment copy on play v3.19.1+ and v7.77.0+ (#1537)
Browse files Browse the repository at this point in the history
fix #1460
  • Loading branch information
Aiden2014 authored Nov 12, 2024
1 parent 845ceff commit 88bb21c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 41 deletions.
46 changes: 12 additions & 34 deletions app/src/main/java/me/iacn/biliroaming/BiliBiliPackage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ class BiliBiliPackage constructor(private val mClassLoader: ClassLoader, mContex

fun comment3Copy() = mHookInfo.comment3Copy.method.orNull

fun comment3ViewIndex() = mHookInfo.comment3Copy.comment3ViewIndex

fun responseDataField() = runCatchingOrNull {
rxGeneralResponseClass?.getDeclaredField("data")?.name
} ?: "_data"
Expand Down Expand Up @@ -1309,7 +1311,7 @@ class BiliBiliPackage constructor(private val mClassLoader: ClassLoader, mContex
setExpandLinesIndex,
-1,
1,
"VL",
null,
-1,
null,
null,
Expand Down Expand Up @@ -1458,42 +1460,18 @@ class BiliBiliPackage constructor(private val mClassLoader: ClassLoader, mContex
}
}
comment3Copy = comment3Copy {
val clipBoardCopyMethod =
"com.bilibili.droid.ClipboardHelper".from(classloader)
?.getDeclaredMethod("copy", Context::class.java, String::class.java)?.let {
dexHelper.encodeMethodIndex(it)
} ?: return@comment3Copy
val commentExtensionsKtClass =
"com.bilibili.app.comment3.utils.CommentExtensionsKt".from(classloader)?.let {
dexHelper.encodeClassIndex(it)
} ?: return@comment3Copy
dexHelper.findMethodInvoked(
clipBoardCopyMethod,
-1,
2,
"ZLL",
commentExtensionsKtClass,
null,
null,
null,
true
).firstOrNull()?.let {
dexHelper.findMethodInvoked(
it,
-1,
3,
"ZLLL",
-1,
null,
null,
null,
true
).firstOrNull()?.let {
dexHelper.decodeMethodIndex(it)
classesList.filter {
it.startsWith("com.bilibili.app.comment3.ui.holder.handle.CommentContentRichTextHandler")
}.map { it.on(classloader) }.flatMap { c ->
c.declaredMethods.filter {
(it.isPrivate && it.parameterCount == 6 && it.parameterTypes[5] == View::class.java) ||
(it.isPrivate && it.parameterCount == 3 && it.parameterTypes[2] == View::class.java)
}
}?.let {
}.firstOrNull()?.let {
Log.d(it.declaringClass.name + it.name)
class_ = class_ { name = it.declaringClass.name }
method = method { name = it.name }
comment3ViewIndex = it.parameterCount - 1
}
}
dexHelper.findMethodUsingString(
Expand Down
15 changes: 8 additions & 7 deletions app/src/main/java/me/iacn/biliroaming/hook/CopyHook.kt
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,15 @@ class CopyHook(classLoader: ClassLoader) : BaseHook(classLoader) {

instance.comment3CopyClass?.let { c ->
instance.comment3Copy()?.let { m ->
c.replaceAllMethods(m) { param ->
if (!enhanceLongClickCopy) return@replaceAllMethods true

val view = param.args[2] as View
view.getFirstFieldByExactTypeOrNull<CharSequence>()?.also { text ->
showCopyDialog(view.context, text, param)
instance.comment3ViewIndex().let { i ->
c.replaceAllMethods(m) { param ->
if (!enhanceLongClickCopy) return@replaceAllMethods true
val view = param.args[i] as View
view.getFirstFieldByExactTypeOrNull<CharSequence>()?.also { text ->
showCopyDialog(view.context, text, param)
}
return@replaceAllMethods true
}
return@replaceAllMethods true
}
}
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/proto/me/iacn/biliroaming/configs.proto
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ message CardClickProcessor {
message Comment3Copy {
optional Class class = 1;
optional Method method = 2;
optional int32 comment3ViewIndex = 3;
}

message HookInfo {
Expand Down

0 comments on commit 88bb21c

Please sign in to comment.