This commit is contained in:
HolographicHat 2024-08-08 23:02:18 +08:00
parent add41e1e1c
commit a9bc60d84a
No known key found for this signature in database
GPG Key ID: 12C8B5B85E5CE5C3
6 changed files with 44 additions and 33 deletions

View File

@ -1,17 +1,18 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'org.jetbrains.kotlin.plugin.serialization'
}
android {
namespace 'hat.holo.token'
compileSdk 33
compileSdk 34
defaultConfig {
applicationId "hat.holo.token"
minSdk 28
targetSdk 33
targetSdk 34
versionCode 1
versionName "1.0"
vectorDrawables {
@ -42,6 +43,9 @@ android {
}
kotlinOptions {
jvmTarget = '1.8'
freeCompilerArgs += [
"-Xcontext-receivers"
]
}
buildFeatures {
compose true
@ -58,17 +62,18 @@ android {
dependencies {
implementation "androidx.core:core-ktx:1.9.0"
implementation "androidx.appcompat:appcompat:1.5.1"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.5.1"
implementation "androidx.compose.ui:ui:1.3.1"
implementation "androidx.compose.material:material:1.3.1"
implementation "androidx.activity:activity-compose:1.6.1"
implementation "androidx.core:core-ktx:1.13.0"
implementation "androidx.appcompat:appcompat:1.6.1"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.7.0"
implementation "androidx.compose.ui:ui:1.6.6"
implementation "androidx.compose.material:material:1.6.6"
implementation "androidx.activity:activity-compose:1.9.0"
implementation "androidx.constraintlayout:constraintlayout-compose:1.0.1"
implementation "com.google.accompanist:accompanist-systemuicontroller:0.27.1"
implementation "com.google.code.gson:gson:2.10"
implementation "com.squareup.okhttp3:okhttp:5.0.0-alpha.2"
implementation "com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.2"
implementation "com.google.accompanist:accompanist-systemuicontroller:0.34.0"
implementation "com.squareup.okhttp3:okhttp:5.0.0-alpha.14"
implementation "com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.14"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1"
compileOnly files("libs/api-82.jar")
}

View File

@ -52,27 +52,18 @@ class ModuleMain : IXposedHookLoadPackage, IXposedHookZygoteInit {
appendToClassPath(app.applicationContext)
}
})
val u = loadClass("com.mihoyo.hyperion.user_profile.UserProfileFragment")
val rng = loadClass("rn.g") // FragmentUserProfileBinding.java
findAndHookMethod(u, "onViewCreated", android.view.View::class.java, android.os.Bundle::class.java, object : XC_MethodHook() {
val fragmentKlass = loadClass("com.mihoyo.hyperion.user_profile.UserProfileFragment")
findAndHookMethod(fragmentKlass, "onViewCreated", android.view.View::class.java, android.os.Bundle::class.java, object : XC_MethodHook() {
override fun afterHookedMethod(p: MethodHookParam) {
val getBinding = u.getDeclaredMethod("getBinding")
getBinding.isAccessible = true
val bindingInstance = getBinding.invoke(p.thisObject)
val getLinearLayout = rng.getDeclaredField("b")
getLinearLayout.isAccessible = true
val linearLayout = getLinearLayout.get(bindingInstance) as LinearLayout
val fragmentBinding = p.thisObject.invokeMethod<Any>("getBinding")
val linearLayout = fragmentBinding.visitField<LinearLayout>("b")
val ctx = linearLayout.context
val getScanButton = rng.getDeclaredField("w")
getScanButton.isAccessible = true
val scanButton = getScanButton.get(bindingInstance) as ImageView
val tokenBtn = ImageView(ctx)
tokenBtn.id = XResources.getFakeResId("getTokenIv")
tokenBtn.setImageDrawable(Res.iconToken)
val size = Dimension.convertDpToPixel(32f, ctx).roundToInt()
tokenBtn.layoutParams = ViewGroup.LayoutParams(size, size)
tokenBtn.setPadding(10, 6, 0, 6)
tokenBtn.setPadding(20, 6, 0, 6)
tokenBtn.scaleType = ImageView.ScaleType.FIT_XY
tokenBtn.setOnClickListener {
if (AccountManager.isLogin) {
@ -91,7 +82,7 @@ class ModuleMain : IXposedHookLoadPackage, IXposedHookZygoteInit {
AppUtils.showToast("未登录")
}
}
val scanButton = fragmentBinding.visitField<ImageView>("w")
linearLayout.addView(tokenBtn, linearLayout.indexOfChild(scanButton) + 1)
for (i in 0 until linearLayout.childCount) {
val view = linearLayout.getChildAt(i)

View File

@ -5,3 +5,17 @@ import java.lang.reflect.AccessibleObject
fun <T : AccessibleObject> T.setAccess() = apply {
isAccessible = true
}
@Suppress("UNCHECKED_CAST")
fun <R> Any.invokeMethod(methodName: String, vararg args: Any?) : R {
val method = this.javaClass.getDeclaredMethod(methodName)
method.isAccessible = true
return method.invoke(this, *args) as R
}
@Suppress("UNCHECKED_CAST")
fun <T> Any.visitField(fieldName: String) : T {
val field = this.javaClass.getDeclaredField(fieldName)
field.isAccessible = true
return field.get(this) as T
}

File diff suppressed because one or more lines are too long

View File

@ -1,10 +1,11 @@
buildscript {
ext {
compose_ui_version = '1.3.1'
compose_ui_version = '1.5.12'
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.3.0' apply false
id 'com.android.library' version '7.3.0' apply false
id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
id 'com.android.application' version '8.3.2' apply false
id 'com.android.library' version '8.3.2' apply false
id 'org.jetbrains.kotlin.android' version '1.9.23' apply false
id 'org.jetbrains.kotlin.plugin.serialization' version '1.9.23' apply false
}

View File

@ -1,6 +1,6 @@
#Fri Nov 18 22:27:22 CST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME