From 1fe18d4cbfc6b3f56712a46af559fd3d6e171445 Mon Sep 17 00:00:00 2001 From: LoveSy Date: Sun, 12 Apr 2020 03:48:12 +0800 Subject: [PATCH] Fix jump url --- .../biliroaming/hook/BangumiSeasonHook.kt | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/me/iacn/biliroaming/hook/BangumiSeasonHook.kt b/app/src/main/java/me/iacn/biliroaming/hook/BangumiSeasonHook.kt index 09a6f17269..cb383e2736 100644 --- a/app/src/main/java/me/iacn/biliroaming/hook/BangumiSeasonHook.kt +++ b/app/src/main/java/me/iacn/biliroaming/hook/BangumiSeasonHook.kt @@ -2,7 +2,7 @@ package me.iacn.biliroaming.hook import android.util.ArrayMap import de.robv.android.xposed.XC_MethodHook -import de.robv.android.xposed.XposedBridge +import de.robv.android.xposed.XposedBridge.hookAllConstructors import de.robv.android.xposed.XposedHelpers.* import me.iacn.biliroaming.BiliBiliPackage.Companion.instance import me.iacn.biliroaming.Constant.TYPE_EPISODE_ID @@ -29,7 +29,7 @@ class BangumiSeasonHook(classLoader: ClassLoader?) : BaseHook(classLoader!!) { Log.d("startHook: BangumiSeason") val paramsMapClass = findClass("com.bilibili.bangumi.data.page.detail." + "BangumiDetailApiService\$UniformSeasonParamsMap", mClassLoader) - XposedBridge.hookAllConstructors(paramsMapClass, object : XC_MethodHook() { + hookAllConstructors(paramsMapClass, object : XC_MethodHook() { @Throws(Throwable::class) override fun afterHookedMethod(param: MethodHookParam) { val paramMap: Map = param.thisObject as Map @@ -44,7 +44,7 @@ class BangumiSeasonHook(classLoader: ClassLoader?) : BaseHook(classLoader!!) { val responseClass = findClass(instance!!.retrofitResponse(), mClassLoader) - XposedBridge.hookAllConstructors(responseClass, object : XC_MethodHook() { + hookAllConstructors(responseClass, object : XC_MethodHook() { @Throws(Throwable::class) override fun beforeHookedMethod(param: MethodHookParam) { val url = getUrl(param.args[0]) @@ -61,6 +61,22 @@ class BangumiSeasonHook(classLoader: ClassLoader?) : BaseHook(classLoader!!) { } } }) + + try { + val urlHook = object : XC_MethodHook() { + @Throws(Throwable::class) + override fun afterHookedMethod(param: MethodHookParam) { + val redirectUrl = getObjectField(param.thisObject, "redirectUrl") as String + if (redirectUrl.isEmpty()) return + param.result = callMethod(param.thisObject, "getUrl", redirectUrl) + } + } + findAndHookMethod("com.bilibili.bplus.followingcard.api.entity.cardBean.VideoCard", + mClassLoader, "getJumpUrl", urlHook) + findAndHookMethod("com.bilibili.bplus.followingcard.api.entity.cardBean.VideoCard", + mClassLoader, "getCommentJumpUrl", urlHook) + } catch (e: Throwable) { + } } private fun fixBangumi(body: Any) {