diff --git a/app/src/main/java/me/iacn/biliroaming/hook/PegasusHook.kt b/app/src/main/java/me/iacn/biliroaming/hook/PegasusHook.kt index 365786d62c..820eaccead 100644 --- a/app/src/main/java/me/iacn/biliroaming/hook/PegasusHook.kt +++ b/app/src/main/java/me/iacn/biliroaming/hook/PegasusHook.kt @@ -514,6 +514,28 @@ class PegasusHook(classLoader: ClassLoader) : BaseHook(classLoader) { param.result.callMethod("ensureListIsMutable") param.result.callMethodAs>("getListList").filter() } + // v8.17.0+ + instance.viewMossClass?.hookAfterMethod("executeView", instance.viewReqClass) { param -> + param.result ?: return@hookAfterMethod + if (removeRelatePromote && removeRelateOnlyAv && removeRelateNothing) { + param.result.callMethod("clearRelates") + param.result.callMethod("clearPagination") + return@hookAfterMethod + } + param.result.callMethod("ensureRelatesIsMutable") + param.result.callMethodAs>("getRelatesList").filter() + } + instance.viewMossClass?.hookAfterMethod( + "executeRelatesFeed", + "com.bapis.bilibili.app.view.v1.RelatesFeedReq" + ) { param -> + param.result ?: return@hookAfterMethod + param.result.callMethod("ensureListIsMutable") + param.result.callMethodAs>("getListList").filter() + } + + + instance.viewUniteMossClass?.run { hookAfterMethod("view", instance.viewUniteReqClass) { param -> param.result ?: return@hookAfterMethod @@ -543,6 +565,35 @@ class PegasusHook(classLoader: ClassLoader) : BaseHook(classLoader) { callMethodAs>("getRelatesList").filterUnite() } } + // v8.17.0+ + hookAfterMethod("executeView", instance.viewUniteReqClass) { param -> + param.result ?: return@hookAfterMethod + param.result.callMethod("getTab")?.run { + callMethod("ensureTabModuleIsMutable") + callMethodAs>("getTabModuleList").map { originalTabModules -> + if (!originalTabModules.callMethodAs("hasIntroduction")) return@map + originalTabModules.callMethodAs("getIntroduction").run { + callMethod("ensureModulesIsMutable") + callMethodAs>("getModulesList").map { module -> + if (!module.callMethodAs("hasRelates")) return@map + module.callMethodAs("getRelates").run { + callMethod("ensureCardsIsMutable") + callMethodAs>("getCardsList").filterUnite() + } + } + } + } + } + } + hookAfterMethod( + "executeRelatesFeed", + "com.bapis.bilibili.app.viewunite.v1.RelatesFeedReq" + ) { param -> + param.result?.run { + callMethod("ensureRelatesIsMutable") + callMethodAs>("getRelatesList").filterUnite() + } + } } instance.cardClickProcessorClass?.declaredMethods @@ -588,6 +639,8 @@ class PegasusHook(classLoader: ClassLoader) : BaseHook(classLoader) { param.result = null } + + fun MutableList.filterPopular() = removeIf { when (it.callMethod("getItemCase")?.toString()) { "SMALL_COVER_V5" -> { @@ -625,7 +678,6 @@ class PegasusHook(classLoader: ClassLoader) : BaseHook(classLoader) { param.args[0].setObjectField("lastParam_", popularDataVersion) param.args[0].setLongField("idx_", popularDataCount) } - instance.popularClass?.hookAfterMethod( "index", "com.bapis.bilibili.app.show.popular.v1.PopularResultReq" @@ -635,5 +687,32 @@ class PegasusHook(classLoader: ClassLoader) : BaseHook(classLoader) { param.result.callMethod("ensureItemsIsMutable") param.result.callMethodAs>("getItemsList").filterPopular() } + + // v8.17.0+ + instance.popularClass?.hookBeforeMethod( + "executeIndex", + "com.bapis.bilibili.app.show.popular.v1.PopularResultReq" + ) { param -> + param.args ?: return@hookBeforeMethod + + val idx = param.args[0].getLongFieldOrNull("idx_") + if (idx == null || idx == 0L) { + popularDataCount = 0 + popularDataVersion = "" + return@hookBeforeMethod + } + + param.args[0].setObjectField("lastParam_", popularDataVersion) + param.args[0].setLongField("idx_", popularDataCount) + } + instance.popularClass?.hookAfterMethod( + "executeIndex", + "com.bapis.bilibili.app.show.popular.v1.PopularResultReq" + ) { param -> + param.result ?: return@hookAfterMethod + + param.result.callMethod("ensureItemsIsMutable") + param.result.callMethodAs>("getItemsList").filterPopular() + } } }