Skip to content
Open
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[versions]
morphe-patcher = "1.3.3"
#noinspection GradleDependency
morphe-patches-library = "1.2.0" # built against morphe-patcher 1.3.3
smali = "b6365a84f4"
gson = "2.13.2"

[libraries]
gson = { module = "com.google.code.gson:gson", version.ref = "gson" }
morphe-patcher = { module = "app.morphe:morphe-patcher", version.ref = "morphe-patcher" }
morphe-patches-library = { module = "app.morphe:morphe-patches-library", version.ref = "morphe-patches-library" }
1 change: 1 addition & 0 deletions patches/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ kotlin {
dependencies {
// Used by JsonGenerator.
implementation(libs.gson)
implementation(libs.morphe.patches.library)
}

tasks {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package app.docbt.patched_up.kleinanzeigen.ads
import app.morphe.patcher.Fingerprint

// Liberty init method: initializes the ad/analytics SDK (Liberty SDK).
// "KEY_LIBERTY_REFRESH_INTERVAL" is a stable string inside the init method
// across versions: 2026.9.0 (KaLibertyConfig.initLiberty) and 2026.12.0 (liberty_config/a.c).
// The classDef.type.contains("/Liberty;") approach broke in 2026.12.0 due to obfuscation.
// "https://prebid-server.rubiconproject.com/openrtb2/auction" is a stable string inside the setup method
// across versions. Restricting to `returnType == "V"` (void) ensures we target the main
// initializer execution method rather than a configuration factory or getter.
internal object LibertyInitFingerprint : Fingerprint(
strings = listOf("KEY_LIBERTY_REFRESH_INTERVAL"),
strings = listOf("https://prebid-server.rubiconproject.com/openrtb2/auction"),
custom = { method, _ -> method.returnType == "V" },
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ private val COMPAT = Compatibility(
packageName = "com.ebay.kleinanzeigen",
appIconColor = 0x2EAD33,
targets = listOf(
AppTarget(version = "2026.16.1"),
AppTarget(version = "2026.14.2"),
AppTarget(version = "2026.14.0"),
AppTarget(version = "2026.47.1"),
),
)

Expand All @@ -24,8 +22,9 @@ val hideAdsPatch = bytecodePatch(
compatibleWith(COMPAT)

execute {
// Liberty init method initializes the ad/analytics SDK.
// Returning early before execution prevents all ads and analytics from loading.
// Liberty setup method initializes ad/analytics SDKs.
// Inserting a return-void instruction at index 0 exits the method early before any SDKs are configured,
// preventing all ads and analytics from loading.
LibertyInitFingerprint.method.addInstruction(0, "return-void")
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package app.docbt.patched_up.kleinanzeigen.hidepur

import app.morphe.patcher.Fingerprint
import app.morphe.patches.all.misc.resources.ResourceType
import app.morphe.patches.all.misc.resources.resourceLiteral

// setupSections (2026.9.0) / q (2026.12.0) in SettingsAndHelpFragment:
// parameter p7 = showAdFreeSubscription (bool). The single IF_EQZ p7 controls
// whether the Pur section container is VISIBLE or GONE.
// SettingsAndHelpFragment is never obfuscated — stable across versions.
internal object SetupSectionsPurFingerprint : Fingerprint(
custom = { method, classDef ->
classDef.type == "Lebk/ui/preferences/settings/settings_and_help/SettingsAndHelpFragment;" &&
!method.name.startsWith("access\$") &&
method.parameterTypes.count { it == "Z" } >= 5 &&
method.parameterTypes.any { it == "Ljava/lang/String;" }
},
// Anchors on both Pur title and subtitle resource IDs to reliably locate
// the settings list builder method across R8 refactoring passes.
internal object HidePurEligibilityFingerprint : Fingerprint(
filters = listOf(
resourceLiteral(ResourceType.STRING, "ka_gbl_pur"),
resourceLiteral(ResourceType.STRING, "ka_settings_v2_top_ad_free_subscription_pur_subtitle"),
),
)
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package app.docbt.patched_up.kleinanzeigen.hidepur

import app.morphe.patcher.extensions.InstructionExtensions
import app.morphe.patcher.extensions.InstructionExtensions.addInstructions
import app.morphe.patcher.patch.AppTarget
import app.morphe.patcher.patch.Compatibility
import app.morphe.patcher.patch.bytecodePatch
import app.morphe.patches.all.misc.resources.resourceMappingPatch
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction

Expand All @@ -12,9 +13,7 @@ private val COMPAT = Compatibility(
packageName = "com.ebay.kleinanzeigen",
appIconColor = 0x2EAD33,
targets = listOf(
AppTarget(version = "2026.16.1"),
AppTarget(version = "2026.14.2"),
AppTarget(version = "2026.14.0"),
AppTarget(version = "2026.47.1"),
),
)

Expand All @@ -24,24 +23,27 @@ val hidePurPatch = bytecodePatch(
description = "Hides the Pur ad-free subscription option from the settings menu.",
) {
compatibleWith(COMPAT)
dependsOn(resourceMappingPatch)

execute {
with(InstructionExtensions) {
// setupSections() (2026.9.0) / q() (2026.12.0) in SettingsAndHelpFragment:
// p7 = showAdFreeSubscription. The single IF_EQZ p7 sends to GONE when false,
// VISIBLE when true. Forcing vReg = 0 before IF_EQZ always hides the Pur entry.
val method = SetupSectionsPurFingerprint.method
var ifEqzIndex = -1
var showAdFreeReg = -1
for ((i, instr) in method.implementation!!.instructions.withIndex()) {
if (instr.opcode == Opcode.IF_EQZ) {
ifEqzIndex = i
showAdFreeReg = (instr as OneRegisterInstruction).registerA
break
}
HidePurEligibilityFingerprint.let {
val method = it.method
val instructions = method.implementation!!.instructions.toList()
val literalIndex = it.instructionMatches[0].index

// The Pur row is only appended inside `if (eligible) { list.add(...) }`.
// Walk backward from the ka_gbl_pur reference to find that specific
// gate, not forward from the top of the method.
val branchIndex = (literalIndex downTo 0).first { i ->
instructions[i].opcode == Opcode.IF_EQZ || instructions[i].opcode == Opcode.IF_NEZ
}
check(ifEqzIndex != -1) { "IF_EQZ not found in setupSections/q" }
method.addInstruction(ifEqzIndex, "const/4 v$showAdFreeReg, 0x0")
val gateReg = (instructions[branchIndex] as OneRegisterInstruction).registerA

// Force the gate to always take the "ineligible" branch, regardless of
// whether the compiler emitted IF_EQZ or IF_NEZ for this check.
val forceValue = if (instructions[branchIndex].opcode == Opcode.IF_EQZ) "0x0" else "0x1"

method.addInstructions(branchIndex, "const/4 v$gateReg, $forceValue")
}
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,89 @@
package app.docbt.patched_up.kleinanzeigen.sharetracking

import app.morphe.patcher.Fingerprint
import app.morphe.patcher.patch.PatchException
import com.android.tools.smali.dexlib2.iface.ClassDef
import com.android.tools.smali.dexlib2.iface.Method
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.reference.StringReference

// e.h() — builds the VIP ad share URL, switches utm_source by target app.
// "sharesheet" is the stable default source string (used for generic share sheet).
internal object ShareUrlBuilderFingerprint : Fingerprint(
strings = listOf("sharesheet"),
custom = { _, classDef -> classDef.type == "Lebk/ui/vip/compose/content/e;" },
// Anchor strings: appear together in the share-target switch statement.
// Using several co-occurring strings instead of just "sharesheet" avoids
// false-positive matches against unrelated code elsewhere in the merged
// multi-dex APK that might also contain the word "sharesheet" on its own.
private val ANCHOR_STRINGS = setOf(
"sharesheet",
"com.whatsapp",
"com.pinterest",
"com.facebook.orca",
)

// e.i(url, source) — appends UTM params to a URL and returns the result.
// Called by h() for ad sharing and directly for store sharing.
// Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
// Identified by: same class as h(), returns String, takes exactly 2 String parameters.
// True if any method in this class references all of ANCHOR_STRINGS
// (not necessarily the same method — they live in different switch
// branches of the same method in practice, but we don't rely on that).
private fun ClassDef.containsAnchorStrings(): Boolean {
val remaining = ANCHOR_STRINGS.toMutableSet()
for (method in methods) {
val instructions = method.implementation?.instructions ?: continue
for (instruction in instructions) {
val ref = (instruction as? ReferenceInstruction)?.reference as? StringReference ?: continue
remaining.remove(ref.string)
}
if (remaining.isEmpty()) return true
}
return remaining.isEmpty()
}

// True if this method references a UTM query parameter string used when
// appending tracking parameters to shared URLs.
// R8 can merge unrelated (String, String) -> String methods (such as URL
// builders for other features) into the same class, so checking for the UTM
// string isolates the method that builds share URLs with tracking parameters.
private fun Method.containsUtmString(): Boolean {
val instructions = implementation?.instructions ?: return false
return instructions.any { instruction ->
val ref = (instruction as? ReferenceInstruction)?.reference as? StringReference
ref?.string?.contains("utm_source=") == true
}
}

// Checks whether a method has the expected (String, String) -> String shape.
private fun Method.hasRightShape(): Boolean =
returnType == "Ljava/lang/String;" &&
parameterTypes.size == 2 &&
parameterTypes.all { it.toString() == "Ljava/lang/String;" }

// Matches the method that appends UTM parameters to a share URL and returns
// the resulting URL string.
// Because R8 may merge the class into an unrelated namespace (such as OkHttp)
// and rename classes or methods across versions, names and packages are not
// hardcoded. Instead:
// 1. Identify the containing class via ANCHOR_STRINGS.
// 2. Collect methods in that class with the right signature that also
// reference "utm_source=".
// 3. Require an unambiguous single match so R8-merged helpers with the same
// shape do not cause false positives or silent mis-patching.
internal object ShareUrlParamBuilderFingerprint : Fingerprint(
custom = { method, classDef ->
classDef.type == "Lebk/ui/vip/compose/content/e;" &&
method.returnType == "Ljava/lang/String;" &&
method.parameterTypes.size == 2 &&
method.parameterTypes.all { it.toString() == "Ljava/lang/String;" }
custom = { targetMethod, classDef ->
if (!targetMethod.hasRightShape() || !classDef.containsAnchorStrings()) {
false
} else {
val matches = classDef.methods.filter { method ->
method.hasRightShape() && method.containsUtmString()
}

// Fail loudly if 0 or more than 1 matching method exists in this class
// so a missing target or an added helper method is never patched silently.
if (matches.size != 1) {
throw PatchException(
"Expected exactly 1 UTM builder matching (String, String) -> String in " +
"${classDef.type}, but found ${matches.size}" +
if (matches.isEmpty()) "." else ": ${matches.joinToString { it.name }}."
)
}

// Compare by value, not identity
targetMethod == matches.first()
}
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ private val COMPAT = Compatibility(
packageName = "com.ebay.kleinanzeigen",
appIconColor = 0x2EAD33,
targets = listOf(
AppTarget(version = "2026.16.1"),
AppTarget(version = "2026.14.2"),
AppTarget(version = "2026.14.0"),
AppTarget(version = "2026.47.1"),
),
)

Expand All @@ -24,10 +22,10 @@ val removeTrackingParamsPatch = bytecodePatch(
compatibleWith(COMPAT)

execute {
// e.i(url, source) appends UTM params to the URL and returns it.
// method(url, source) appends UTM params to the URL and returns it.
// Returning p0 (the first argument = the original URL) immediately
// skips the UTM construction entirely.
// This covers both ad sharing (called from e.h()) and store sharing (direct call).
// This covers both ad sharing and store sharing (direct call).
ShareUrlParamBuilderFingerprint.method.addInstruction(0, "return-object p0")
}
}
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ pluginManagement {
}

plugins {
id("app.morphe.patches") version "1.2.0"
id("app.morphe.patches") version "1.3.0"
}
2 changes: 1 addition & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"googleNews": "5.163.0.947799485",
"kleinanzeigen": "2026.16.1"
"kleinanzeigen": "2026.47.1"
}