-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- clean urls before opening - add analytics kill
- Loading branch information
1 parent
f5ab49f
commit 0fe1708
Showing
6 changed files
with
112 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
app/src/main/java/io/github/cloudburst/messengerex/Utils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.github.cloudburst.messengerex | ||
|
||
import android.content.pm.ApplicationInfo | ||
import android.net.Uri | ||
|
||
fun getApkPath(apkinfo: ApplicationInfo): String = apkinfo.splitSourceDirs?.firstOrNull { | ||
it.contains("split_d_longtail_raw_v9") | ||
} ?: apkinfo.sourceDir | ||
|
||
fun removeTrackingUrl(uri: Uri): Uri { | ||
var url = uri | ||
if (url.host == "l.facebook.com" && url.path == "/l.php") { | ||
url = Uri.parse(url.getQueryParameter("u")) | ||
} | ||
val builder = url.buildUpon() | ||
builder.clearQuery() | ||
val cleanQuery = url.queryParameterNames | ||
.filterNot { it.equals("fbclid", ignoreCase = true) } | ||
.filterNot { it.startsWith("utm_", ignoreCase = true) } | ||
.filterNot {it.equals("si", ignoreCase = true)} | ||
.map { it to url.getQueryParameter(it) } | ||
cleanQuery.forEach { (key, value) -> | ||
builder.appendQueryParameter(key, value) | ||
} | ||
return builder.build() | ||
} |
35 changes: 35 additions & 0 deletions
35
app/src/main/java/io/github/cloudburst/messengerex/patches/Analytics.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package io.github.cloudburst.messengerex.patches | ||
|
||
import android.util.Log | ||
import de.robv.android.xposed.XC_MethodHook | ||
import de.robv.android.xposed.XposedBridge | ||
|
||
val loggerServices = listOf( | ||
"AlarmBasedUploadService", | ||
"GooglePlayUploadService", | ||
"LollipopUploadService" | ||
) | ||
|
||
fun removeService(cl: ClassLoader, className: String) { | ||
val clazz = cl.loadClass("com.facebook.analytics2.logger.${className}") | ||
val method = clazz.declaredMethods.firstOrNull { | ||
it.name == "onStartCommand" && it.returnType == Int::class.javaPrimitiveType | ||
} ?: return | ||
XposedBridge.hookMethod(method, object : XC_MethodHook() { | ||
override fun beforeHookedMethod(param: MethodHookParam?) { | ||
param?.result = 2 | ||
} | ||
}) | ||
Log.d(TAG, "Removed service $className") | ||
} | ||
|
||
|
||
fun removeServices(cl: ClassLoader) { | ||
loggerServices.forEach { | ||
try { | ||
removeService(cl, it) | ||
} catch (e: Exception) { | ||
XposedBridge.log("Failed to remove service $it. Reason: ${e.message}") | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
app/src/main/java/io/github/cloudburst/messengerex/patches/Inbox.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package io.github.cloudburst.messengerex.patches | ||
|
||
import android.util.Log | ||
import de.robv.android.xposed.XC_MethodReplacement | ||
import de.robv.android.xposed.XposedBridge | ||
import org.luckypray.dexkit.DexKitBridge | ||
import java.lang.reflect.Modifier | ||
|
||
fun removeAds(cl: ClassLoader, bridge: DexKitBridge) { | ||
try { | ||
val classData = bridge.findClass { | ||
searchPackages("com.facebook.messaging.business.inboxads.plugins.inboxads.itemsupplier") | ||
matcher { | ||
className("com.facebook.messaging.business.inboxads.plugins.inboxads.itemsupplier.InboxAdsItemSupplierImplementation") | ||
} | ||
}.first() | ||
|
||
val method = bridge.findMethod { | ||
searchInClass(listOf(classData)) | ||
matcher { | ||
returnType("void") | ||
usingStrings("ads_load_begin", "inbox_ads_fetch_start") | ||
modifiers(Modifier.PUBLIC or Modifier.STATIC) | ||
} | ||
}.first() | ||
|
||
Log.i(TAG, "Found method: $method") | ||
XposedBridge.hookMethod(method.getMethodInstance(cl), XC_MethodReplacement.DO_NOTHING) | ||
} catch (e: Exception) { | ||
Log.e(TAG, "Failed to remove ads", e) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
app/src/main/java/io/github/cloudburst/messengerex/patches/Patches.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package io.github.cloudburst.messengerex.patches | ||
|
||
const val TAG = "MessengerExPatches" |