Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from yujincheng08:master #199

Merged
merged 6 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 15 additions & 36 deletions app/src/main/java/me/iacn/biliroaming/BiliBiliPackage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class BiliBiliPackage constructor(private val mClassLoader: ClassLoader, mContex
?: "tv.danmaku.bili.MainActivityV2" from mClassLoader
}
val mainActivityClass by Weak { "tv.danmaku.bili.MainActivityV2" from mClassLoader }
val gripperBootExpClass by Weak { "com.bilibili.gripper.exp.a\$a" from mClassLoader }
val homeUserCenterClass by Weak { if (mHookInfo.settings.homeUserCenterCount == 1) mHookInfo.settings.homeUserCenterList.first().class_ from mClassLoader else null }
val menuGroupItemClass by Weak { mHookInfo.settings.menuGroupItem from mClassLoader }
val drawerLayoutClass by Weak { mHookInfo.drawer.layout from mClassLoader }
Expand Down Expand Up @@ -246,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 @@ -577,10 +580,10 @@ class BiliBiliPackage constructor(private val mClassLoader: ClassLoader, mContex
}
biliAccounts = biliAccounts {
val biliAccountsClass = dexHelper.findMethodUsingString(
"refresh token error",
"logout with account exception",
false,
-1,
0,
1,
null,
-1,
null,
Expand Down Expand Up @@ -1308,7 +1311,7 @@ class BiliBiliPackage constructor(private val mClassLoader: ClassLoader, mContex
setExpandLinesIndex,
-1,
1,
"VL",
null,
-1,
null,
null,
Expand Down Expand Up @@ -1457,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
1 change: 1 addition & 0 deletions app/src/main/java/me/iacn/biliroaming/XposedInit.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class XposedInit : IXposedHookLoadPackage, IXposedHookZygoteInit {
if (BuildConfig.DEBUG) {
startHook(SSLHook(lpparam.classLoader))
}
startHook(KillDelayBootHook(lpparam.classLoader))
startHook(HintHook(lpparam.classLoader))
startHook(BangumiSeasonHook(lpparam.classLoader))
startHook(BangumiPlayUrlHook(lpparam.classLoader))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,10 @@ class BangumiSeasonHook(classLoader: ClassLoader) : BaseHook(classLoader) {
val navList = v.callMethodAs<List<Any>>("getNavList")
.map { SearchNav.parseFrom(it.callMethodAs<ByteArray>("toByteArray")) }
.toMutableList()
// fix crash when searching sensitive words
if (navList.size == 0) {
return
}
val currentArea = runCatchingOrNull {
XposedInit.country.get(5L, TimeUnit.SECONDS)
}
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
7 changes: 7 additions & 0 deletions app/src/main/java/me/iacn/biliroaming/hook/JsonHook.kt
Original file line number Diff line number Diff line change
Expand Up @@ -471,9 +471,14 @@ class JsonHook(classLoader: ClassLoader) : BaseHook(classLoader) {
var hasKoreaTW = false
tab.forEach {
when (it.getObjectFieldAs<String>("uri")) {
"bilibili://pgc/bangumi_v2",
"bilibili://pgc/home" -> hasBangumiCN = true

"bilibili://following/home_activity_tab/6544" -> hasBangumiTW = true

"bilibili://pgc/cinema_v2",
"bilibili://pgc/home?home_flow_type=2" -> hasMovieCN = true

"bilibili://following/home_activity_tab/168644" -> hasMovieTW = true
"bilibili://following/home_activity_tab/163541" -> hasKoreaHK = true
"bilibili://following/home_activity_tab/95636" -> hasKoreaTW = true
Expand Down Expand Up @@ -556,10 +561,12 @@ class JsonHook(classLoader: ClassLoader) : BaseHook(classLoader) {
"bilibili://pegasus/hottopic"
-> purifytabset.contains("hottopic")

"bilibili://pgc/bangumi_v2",
"bilibili://pgc/home",
"bilibili://following/home_activity_tab/6544"
-> purifytabset.contains("bangumi")

"bilibili://pgc/cinema_v2",
"bilibili://pgc/home?home_flow_type=2",
"bilibili://following/home_activity_tab/168644"
-> purifytabset.contains("movie")
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/java/me/iacn/biliroaming/hook/KillDelayBootHook.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package me.iacn.biliroaming.hook

import me.iacn.biliroaming.BiliBiliPackage.Companion.instance
import me.iacn.biliroaming.utils.hookAfterMethod

class KillDelayBootHook(classLoader: ClassLoader) : BaseHook(classLoader) {
override fun startHook() {
instance.gripperBootExpClass?.hookAfterMethod("getDelayMillis") { param ->
param.result = -1L
}
}
}
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
2 changes: 1 addition & 1 deletion app/src/main/res/values-zh-rTW/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<item>直播</item>
<item>推薦</item>
<item>熱門</item>
<item>番劇</item>
<item>番劇(動畫)</item>
<item>影視</item>
<item>韓綜</item>
<item>其它</item>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<item>直播</item>
<item>推荐</item>
<item>热门</item>
<item>番剧</item>
<item>番剧(动画)</item>
<item>影视</item>
<item>韩综</item>
<item>其它</item>
Expand Down
8 changes: 4 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[versions]
protobuf = "4.27.2"
coroutine = "1.8.1"
kotlin = "2.0.0"
protobuf = "4.28.3"
coroutine = "1.9.0"
kotlin = "2.0.21"

[plugins]
kotlin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
agp-app = { id = "com.android.application", version = "8.5.1" }
agp-app = { id = "com.android.application", version = "8.7.2" }
protobuf = { id = "com.google.protobuf", version = "0.9.4" }
lsplugin-jgit = { id = "org.lsposed.lsplugin.jgit", version = "1.1" }
lsplugin-resopt = { id = "org.lsposed.lsplugin.resopt", version = "1.6" }
Expand Down
Loading