feat: block tracking

This commit is contained in:
PalmDevs 2025-10-13 14:32:12 +07:00 • committed by cocobo1
parent 4e9116f3f9
commit 3c0204af03
3 changed files with 76 additions and 0 deletions

View file

@ -14,6 +14,21 @@ import cocobo1.pupu.xposed.modules.appearance.ThemesModule
import cocobo1.pupu.xposed.modules.bridge.AdditionalBridgeMethodsModule
import cocobo1.pupu.xposed.modules.bridge.BridgeModule
object HookStateHolder {
/**
* Whether all hooks are completed, and we are ready to load the JS bundle.
*/
val readyDeferred = CompletableDeferred<Unit>()
/**
* Whether we have successfully received a [Context] yet.
* Sometimes the app process is recreated and Xposed hooks way too late for us to get [Context] from [ContextWrapper.attachBaseContext].
* But since Xposed hooks before [Activity.onCreate], we can still get it from there and still initialize properly.
*/
@Volatile
var gotContext = false
}
class Main : Module(), IXposedHookLoadPackage, IXposedHookZygoteInit {
private var hooked = false
private val modules = mutableListOf(
@ -22,6 +37,8 @@ class Main : Module(), IXposedHookLoadPackage, IXposedHookZygoteInit {
AdditionalBridgeMethodsModule(),
UpdaterModule(),
FixResourcesModule(),
BlockDeepLinksTrackingModule(),
BlockCrashReportingModule(),
LogBoxModule(),
FontsModule(),
ThemesModule(),

View file

@ -0,0 +1,34 @@
package io.github.revenge.xposed.modules.no_track
import android.content.Context
import de.robv.android.xposed.callbacks.XC_LoadPackage
import io.github.revenge.xposed.Module
import io.github.revenge.xposed.Utils.Log
/**
* Hooks Discord's crash reporting to disable Sentry initialization.
* While Discord doesn't have Sentry auto-initialization on by default, we still hook the content provider just to be safe.
*/
class BlockCrashReportingModule : Module() {
override fun onLoad(packageParam: XC_LoadPackage.LoadPackageParam) = with(packageParam) {
val crashReportingClass = classLoader.safeLoadClass("com.discord.crash_reporting.CrashReporting")
crashReportingClass?.hookMethod(
"init", Context::class.java, String::class.java
) {
before {
Log.i("Blocked CrashReporting initialization")
result = null
}
}
val sentryInitProviderClass = classLoader.safeLoadClass("io.sentry.android.core.SentryInitProvider")
sentryInitProviderClass?.hookMethod("onCreate") {
before {
Log.i("Blocked SentryInitProvider initialization")
result = true
}
}
return@with
}
}

View file

@ -0,0 +1,25 @@
package io.github.revenge.xposed.modules.no_track
import android.content.Context
import de.robv.android.xposed.callbacks.XC_LoadPackage
import io.github.revenge.xposed.Module
import io.github.revenge.xposed.Utils.Log
/**
* Hooks Discord's deep links tracking to disable AppsFlyer initialization.
*/
class BlockDeepLinksTrackingModule : Module() {
override fun onLoad(packageParam: XC_LoadPackage.LoadPackageParam) = with(packageParam) {
val deepLinksClass = classLoader.safeLoadClass("com.discord.deep_link.DeepLinks")
deepLinksClass?.hookMethod(
"init", Context::class.java
) {
before {
Log.i("Blocked DeepLinks tracking initialization")
result = null
}
}
return@with
}
}