From 678645723a6a35eb30ea8f37cd1a929dc24b1523 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sun, 11 Jan 2026 23:10:26 +0700 Subject: [PATCH 01/55] refactor(nunl): HideAdsPatch --- .../revanced/patches/nunl/ads/Fingerprints.kt | 60 ++++++++++--------- .../revanced/patches/nunl/ads/HideAdsPatch.kt | 17 +++--- 2 files changed, 41 insertions(+), 36 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/nunl/ads/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/nunl/ads/Fingerprints.kt index 109b973e0..b6bc5fc33 100644 --- a/patches/src/main/kotlin/app/revanced/patches/nunl/ads/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/nunl/ads/Fingerprints.kt @@ -1,44 +1,50 @@ package app.revanced.patches.nunl.ads -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.accessFlags +import app.revanced.patcher.definingClass +import app.revanced.patcher.firstMethodComposite +import app.revanced.patcher.instructions +import app.revanced.patcher.invoke +import app.revanced.patcher.name +import app.revanced.patcher.parameterTypes +import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode -internal val jwPlayerConfigFingerprint = fingerprint { +internal val BytecodePatchContext.jwPlayerConfigMethod by gettingFirstMutableMethodDeclaratively { accessFlags(AccessFlags.PUBLIC) - custom { methodDef, classDef -> - classDef.type == "Lcom/jwplayer/pub/api/configuration/PlayerConfig${'$'}Builder;" && methodDef.name == "advertisingConfig" - } + definingClass($$"Lcom/jwplayer/pub/api/configuration/PlayerConfig$Builder;") + name("advertisingConfig") } -internal val screenMapperFingerprint = fingerprint { +internal val screenMapperMethodMatch = firstMethodComposite { accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) - returns("Lnl/nu/android/bff/domain/models/screen/ScreenEntity;") - parameters("Lnl/nu/performance/api/client/objects/Screen;") + returnType("Lnl/nu/android/bff/domain/models/screen/ScreenEntity;") + parameterTypes("Lnl/nu/performance/api/client/objects/Screen;") - opcodes( - Opcode.MOVE_RESULT_OBJECT, - Opcode.IF_EQZ, - Opcode.CHECK_CAST + definingClass("Lnl/nu/android/bff/data/mappers/ScreenMapper;") + name("map") + + instructions( + Opcode.MOVE_RESULT_OBJECT(), + Opcode.IF_EQZ(), + Opcode.CHECK_CAST(), ) - - custom { methodDef, classDef -> - classDef.type == "Lnl/nu/android/bff/data/mappers/ScreenMapper;" && methodDef.name == "map" - } } -internal val nextPageRepositoryImplFingerprint = fingerprint { +internal val nextPageRepositoryImplMethodMatch = firstMethodComposite { accessFlags(AccessFlags.PRIVATE, AccessFlags.FINAL) - returns("Lnl/nu/android/bff/domain/models/Page;") - parameters("Lnl/nu/performance/api/client/PacResponse;", "Ljava/lang/String;") + returnType("Lnl/nu/android/bff/domain/models/Page;") + parameterTypes("Lnl/nu/performance/api/client/PacResponse;", "Ljava/lang/String;") - opcodes( - Opcode.MOVE_RESULT_OBJECT, - Opcode.IF_EQZ, - Opcode.CHECK_CAST + definingClass("Lnl/nu/android/bff/data/repositories/NextPageRepositoryImpl;") + name("mapToPage") + + instructions( + Opcode.MOVE_RESULT_OBJECT(), + Opcode.IF_EQZ(), + Opcode.CHECK_CAST(), ) - - custom { methodDef, classDef -> - classDef.type == "Lnl/nu/android/bff/data/repositories/NextPageRepositoryImpl;" && methodDef.name == "mapToPage" - } } diff --git a/patches/src/main/kotlin/app/revanced/patches/nunl/ads/HideAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/nunl/ads/HideAdsPatch.kt index 8a94c24b8..8efae4fc5 100644 --- a/patches/src/main/kotlin/app/revanced/patches/nunl/ads/HideAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/nunl/ads/HideAdsPatch.kt @@ -3,15 +3,14 @@ package app.revanced.patches.nunl.ads import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.removeInstructions -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.patches.shared.misc.extension.sharedExtensionPatch import app.revanced.util.indexOfFirstInstructionOrThrow import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -@Suppress("unused") -val hideAdsPatch = bytecodePatch( - name = "Hide ads", +@Suppress("ObjectPropertyName") +val `Hide ads` by creatingBytecodePatch( description = "Hide ads and sponsored articles in list pages and remove pre-roll ads on videos.", ) { compatibleWith("nl.sanomamedia.android.nu") @@ -21,14 +20,14 @@ val hideAdsPatch = bytecodePatch( apply { // Disable video pre-roll ads. // Whenever the app tries to define the advertising config for JWPlayer, don't set the advertising config and directly return. - val iputInstructionIndex = jwPlayerConfigFingerprint.method.indexOfFirstInstructionOrThrow(Opcode.IPUT_OBJECT) - jwPlayerConfigFingerprint.method.removeInstructions(iputInstructionIndex, 1) + val iputInstructionIndex = jwPlayerConfigMethod.indexOfFirstInstructionOrThrow(Opcode.IPUT_OBJECT) + jwPlayerConfigMethod.removeInstructions(iputInstructionIndex, 1) // Filter injected content from API calls out of lists. - arrayOf(screenMapperFingerprint, nextPageRepositoryImplFingerprint).forEach { + arrayOf(screenMapperMethodMatch, nextPageRepositoryImplMethodMatch).forEach { match -> // Index of instruction moving result of BlockPage;->getBlocks(...). - val moveGetBlocksResultObjectIndex = it.patternMatch.startIndex - it.method.apply { + val moveGetBlocksResultObjectIndex = match.indices.first() + match.method.apply { val moveInstruction = getInstruction(moveGetBlocksResultObjectIndex) val listRegister = moveInstruction.registerA From 8fbcf002e4441062989fa3ad04a94608c9057ebe Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sun, 11 Jan 2026 23:11:02 +0700 Subject: [PATCH 02/55] refactor(nunl): SpoofCertificatePatch --- .../patches/nunl/firebase/Fingerprints.kt | 26 +++++++++++-------- .../nunl/firebase/SpoofCertificatePatch.kt | 11 ++++---- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/nunl/firebase/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/nunl/firebase/Fingerprints.kt index 490819a4b..287172ff9 100644 --- a/patches/src/main/kotlin/app/revanced/patches/nunl/firebase/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/nunl/firebase/Fingerprints.kt @@ -1,20 +1,24 @@ package app.revanced.patches.nunl.firebase -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.firstMutableMethodDeclaratively +import app.revanced.patcher.accessFlags +import app.revanced.patcher.definingClass +import app.revanced.patcher.name +import app.revanced.patcher.parameterTypes +import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags -internal val getFingerprintHashForPackageFingerprints = arrayOf( +internal val firebaseClasses = arrayOf( "Lcom/google/firebase/installations/remote/FirebaseInstallationServiceClient;", "Lcom/google/firebase/remoteconfig/internal/ConfigFetchHttpClient;", "Lcom/google/firebase/remoteconfig/internal/ConfigRealtimeHttpClient;" -).map { className -> - fingerprint { - accessFlags(AccessFlags.PRIVATE) - parameters() - returns("Ljava/lang/String;") +) - custom { methodDef, classDef -> - classDef.type == className && methodDef.name == "getFingerprintHashForPackage" - } - } +internal fun BytecodePatchContext.getFingerprintHashForPackageMethod(className: String) = firstMutableMethodDeclaratively { + accessFlags(AccessFlags.PRIVATE) + definingClass(className) + name("getFingerprintHashForPackage") + returnType("Ljava/lang/String;") + parameterTypes() } diff --git a/patches/src/main/kotlin/app/revanced/patches/nunl/firebase/SpoofCertificatePatch.kt b/patches/src/main/kotlin/app/revanced/patches/nunl/firebase/SpoofCertificatePatch.kt index 9c0202ee7..1b0118999 100644 --- a/patches/src/main/kotlin/app/revanced/patches/nunl/firebase/SpoofCertificatePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/nunl/firebase/SpoofCertificatePatch.kt @@ -1,18 +1,17 @@ package app.revanced.patches.nunl.firebase -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.util.returnEarly -@Suppress("unused") -val spoofCertificatePatch = bytecodePatch( - name = "Spoof certificate", +@Suppress("unused", "ObjectPropertyName") +val `Spoof certificate` by creatingBytecodePatch( description = "Spoofs the X-Android-Cert header to allow push messages.", ) { compatibleWith("nl.sanomamedia.android.nu") apply { - getFingerprintHashForPackageFingerprints.forEach { fingerprint -> - fingerprint.method.returnEarly("eae41fc018df2731a9b6ae1ac327da44a288667b") + firebaseClasses.forEach { className -> + getFingerprintHashForPackageMethod(className).returnEarly("eae41fc018df2731a9b6ae1ac327da44a288667b") } } } From 52ae07036987b6686c07bb2e93f6187fe0e31e12 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sun, 11 Jan 2026 23:19:22 +0700 Subject: [PATCH 03/55] refactor(openinghours): FixCrashPatch --- .../misc/fix/crash/Fingerprints.kt | 19 +++++++++++-------- .../misc/fix/crash/FixCrashPatch.kt | 16 ++++++++-------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/openinghours/misc/fix/crash/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/openinghours/misc/fix/crash/Fingerprints.kt index 69463c510..0571d613c 100644 --- a/patches/src/main/kotlin/app/revanced/patches/openinghours/misc/fix/crash/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/openinghours/misc/fix/crash/Fingerprints.kt @@ -1,12 +1,15 @@ package app.revanced.patches.openinghours.misc.fix.crash -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.definingClass +import app.revanced.patcher.name +import app.revanced.patcher.parameterTypes +import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType -internal val setPlaceFingerprint = fingerprint { - returns("V") - parameters("Lde/simon/openinghours/models/Place;") - custom { method, _ -> - method.name == "setPlace" && - method.definingClass == "Lde/simon/openinghours/views/custom/PlaceCard;" - } +internal val BytecodePatchContext.setPlaceMethod by gettingFirstMutableMethodDeclaratively { + name("setPlace") + definingClass("Lde/simon/openinghours/views/custom/PlaceCard;") + returnType("V") + parameterTypes("Lde/simon/openinghours/models/Place;") } diff --git a/patches/src/main/kotlin/app/revanced/patches/openinghours/misc/fix/crash/FixCrashPatch.kt b/patches/src/main/kotlin/app/revanced/patches/openinghours/misc/fix/crash/FixCrashPatch.kt index 778a1e110..a33cdfb7f 100644 --- a/patches/src/main/kotlin/app/revanced/patches/openinghours/misc/fix/crash/FixCrashPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/openinghours/misc/fix/crash/FixCrashPatch.kt @@ -1,9 +1,9 @@ package app.revanced.patches.openinghours.misc.fix.crash import app.revanced.patcher.extensions.instructions -import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patcher.extensions.newLabel -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.extensions.replaceInstruction +import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.util.getReference import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21t @@ -11,14 +11,14 @@ import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.Instruction import com.android.tools.smali.dexlib2.iface.reference.MethodReference -@Suppress("unused") -val fixCrashPatch = bytecodePatch( - name = "Fix crash", +@Suppress("unused", "ObjectPropertyName") +val `Fix crash` by creatingBytecodePatch( + description = "Fixes a crash when opening a place.", ) { compatibleWith("de.simon.openinghours"("1.0")) apply { - val indexedInstructions = setPlaceFingerprint.method.instructions.withIndex().toList() + val indexedInstructions = setPlaceMethod.instructions.withIndex().toList() /** * This function replaces all `checkNotNull` instructions in the integer interval @@ -27,7 +27,7 @@ val fixCrashPatch = bytecodePatch( * the value is indeed null, we jump to a newly created label at `endIndex + 1`. */ fun avoidNullPointerException(startIndex: Int, endIndex: Int) { - val continueLabel = setPlaceFingerprint.method.newLabel(endIndex + 1) + val continueLabel = setPlaceMethod.newLabel(endIndex + 1) for (index in startIndex..endIndex) { val instruction = indexedInstructions[index].value @@ -39,7 +39,7 @@ val fixCrashPatch = bytecodePatch( val checkNotNullInstruction = instruction as FiveRegisterInstruction val originalRegister = checkNotNullInstruction.registerC - setPlaceFingerprint.method.replaceInstruction( + setPlaceMethod.replaceInstruction( index, BuilderInstruction21t( Opcode.IF_EQZ, From b6d1f1c62a11ff7b99daa0b4b917e5fa1055dfa5 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sun, 11 Jan 2026 23:29:48 +0700 Subject: [PATCH 04/55] refactor(orfon): RemoveRootDetectionPatch --- .../orfon/detection/root/Fingerprints.kt | 17 ++++++++++------- .../detection/root/RemoveRootDetectionPatch.kt | 12 +++++------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/orfon/detection/root/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/orfon/detection/root/Fingerprints.kt index 525d4f37d..9f4570309 100644 --- a/patches/src/main/kotlin/app/revanced/patches/orfon/detection/root/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/orfon/detection/root/Fingerprints.kt @@ -1,13 +1,16 @@ package app.revanced.patches.orfon.detection.root -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.accessFlags +import app.revanced.patcher.definingClass +import app.revanced.patcher.name +import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags -internal val isDeviceRootedFingeprint = fingerprint { +internal val BytecodePatchContext.isDeviceRootedMethod by gettingFirstMutableMethodDeclaratively { accessFlags(AccessFlags.PUBLIC) - returns("Z") - custom { method, classDef -> - method.name == "isDeviceRooted" && - classDef.endsWith("/RootChecker;") - } + name("isDeviceRooted") + definingClass("/RootChecker;"::endsWith) + returnType("Z") } diff --git a/patches/src/main/kotlin/app/revanced/patches/orfon/detection/root/RemoveRootDetectionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/orfon/detection/root/RemoveRootDetectionPatch.kt index f0dd38df2..e0a6198d8 100644 --- a/patches/src/main/kotlin/app/revanced/patches/orfon/detection/root/RemoveRootDetectionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/orfon/detection/root/RemoveRootDetectionPatch.kt @@ -1,18 +1,16 @@ package app.revanced.patches.orfon.detection.root -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.patches.shared.PATCH_DESCRIPTION_REMOVE_ROOT_DETECTION -import app.revanced.patches.shared.PATCH_NAME_REMOVE_ROOT_DETECTION import app.revanced.util.returnEarly -@Suppress("unused") -val removeRootDetectionPatch = bytecodePatch( - name = PATCH_NAME_REMOVE_ROOT_DETECTION, +@Suppress("unused", "ObjectPropertyName") +val `Remove root detection` by creatingBytecodePatch( description = PATCH_DESCRIPTION_REMOVE_ROOT_DETECTION ) { compatibleWith("com.nousguide.android.orftvthek") apply { - isDeviceRootedFingeprint.method.returnEarly(false) + isDeviceRootedMethod.returnEarly(false) } -} \ No newline at end of file +} From b174421e2b7dddea770c7d88e46393f81f9d38d1 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sun, 11 Jan 2026 23:45:21 +0700 Subject: [PATCH 05/55] refactor(pandora): DisableAudioAdsPatch --- .../pandora/ads/DisableAudioAdsPatch.kt | 12 +++++------ .../patches/pandora/ads/Fingerprints.kt | 21 ++++++++++--------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/pandora/ads/DisableAudioAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/pandora/ads/DisableAudioAdsPatch.kt index d95eaa1f3..8c92c7421 100644 --- a/patches/src/main/kotlin/app/revanced/patches/pandora/ads/DisableAudioAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/pandora/ads/DisableAudioAdsPatch.kt @@ -1,16 +1,16 @@ package app.revanced.patches.pandora.ads -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.util.returnEarly -@Suppress("unused") -val disableAudioAdsPatch = bytecodePatch( - name = "Disable audio ads", +@Suppress("unused", "ObjectPropertyName") +val `Disable Audio Ads` by creatingBytecodePatch( + description = "Disable audio ads" ) { compatibleWith("com.pandora.android") apply { - getIsAdSupportedFingerprint.method.returnEarly(false) - requestAudioAdFingerprint.method.returnEarly() + getIsAdSupportedMethod.returnEarly(false) + requestAudioAdMethod.returnEarly() } } diff --git a/patches/src/main/kotlin/app/revanced/patches/pandora/ads/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/pandora/ads/Fingerprints.kt index e3f432e16..74bf1e780 100644 --- a/patches/src/main/kotlin/app/revanced/patches/pandora/ads/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/pandora/ads/Fingerprints.kt @@ -1,15 +1,16 @@ package app.revanced.patches.pandora.ads -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.definingClass +import app.revanced.patcher.name +import app.revanced.patcher.patch.BytecodePatchContext -internal val getIsAdSupportedFingerprint = fingerprint { - custom { method, classDef -> - method.name == "getIsAdSupported" && classDef.endsWith("UserData;") - } +internal val BytecodePatchContext.getIsAdSupportedMethod by gettingFirstMutableMethodDeclaratively { + name("getIsAdSupported") + definingClass("UserData;") } -internal val requestAudioAdFingerprint = fingerprint { - custom { method, classDef -> - method.name == "requestAudioAdFromAdSDK" && classDef.endsWith("ContentServiceOpsImpl;") - } -} \ No newline at end of file +internal val BytecodePatchContext.requestAudioAdMethod by gettingFirstMutableMethodDeclaratively { + name("requestAudioAdFromAdSDK") + definingClass("ContentServiceOpsImpl;"::endsWith) +} From 043cae5db65b2e1c3ba4f6d63e9c79e074fc89df Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sun, 11 Jan 2026 23:45:28 +0700 Subject: [PATCH 06/55] refactor(pandora): EnableUnlimitedSkipsPatch --- .../pandora/misc/EnableUnlimitedSkipsPatch.kt | 10 +++++----- .../revanced/patches/pandora/misc/Fingerprints.kt | 14 ++++++++------ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/pandora/misc/EnableUnlimitedSkipsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/pandora/misc/EnableUnlimitedSkipsPatch.kt index cfb18c439..98b19c527 100644 --- a/patches/src/main/kotlin/app/revanced/patches/pandora/misc/EnableUnlimitedSkipsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/pandora/misc/EnableUnlimitedSkipsPatch.kt @@ -1,15 +1,15 @@ package app.revanced.patches.pandora.misc -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.util.returnEarly -@Suppress("unused") -val enableUnlimitedSkipsPatch = bytecodePatch( - name = "Enable unlimited skips", +@Suppress("unused", "ObjectPropertyName") +val `Enable Unlimited Skips` by creatingBytecodePatch( + description = "Enable unlimited skips" ) { compatibleWith("com.pandora.android") apply { - skipLimitBehaviorFingerprint.method.returnEarly("unlimited") + skipLimitBehaviorMethod.returnEarly("unlimited") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/pandora/misc/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/pandora/misc/Fingerprints.kt index 2a14e0ed1..06551370d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/pandora/misc/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/pandora/misc/Fingerprints.kt @@ -1,9 +1,11 @@ package app.revanced.patches.pandora.misc -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.definingClass +import app.revanced.patcher.name +import app.revanced.patcher.patch.BytecodePatchContext -internal val skipLimitBehaviorFingerprint = fingerprint { - custom { method, classDef -> - method.name == "getSkipLimitBehavior" && classDef.endsWith("UserData;") - } -} \ No newline at end of file +internal val BytecodePatchContext.skipLimitBehaviorMethod by gettingFirstMutableMethodDeclaratively { + name("getSkipLimitBehavior") + definingClass("UserData;"::endsWith) +} From 6dfe4440bb4a598f3fde8a6ef9710e8ba0f58280 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sun, 11 Jan 2026 23:46:19 +0700 Subject: [PATCH 07/55] refactor(peacocktv): HideAdsPatch --- .../revanced/patches/peacocktv/ads/Fingerprints.kt | 10 ++++++---- .../revanced/patches/peacocktv/ads/HideAdsPatch.kt | 11 +++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/peacocktv/ads/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/peacocktv/ads/Fingerprints.kt index 35c195664..616f9e873 100644 --- a/patches/src/main/kotlin/app/revanced/patches/peacocktv/ads/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/peacocktv/ads/Fingerprints.kt @@ -1,10 +1,12 @@ package app.revanced.patches.peacocktv.ads -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.accessFlags +import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags -internal val mediaTailerAdServiceFingerprint = fingerprint { +internal val BytecodePatchContext.mediaTailerAdServiceMethod by gettingFirstMutableMethodDeclaratively("Could not build MT Advertising service") { accessFlags(AccessFlags.PUBLIC) - returns("Ljava/lang/Object") - strings("Could not build MT Advertising service") + returnType("Ljava/lang/Object;") } diff --git a/patches/src/main/kotlin/app/revanced/patches/peacocktv/ads/HideAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/peacocktv/ads/HideAdsPatch.kt index ce6b7ec5a..df499e2c4 100644 --- a/patches/src/main/kotlin/app/revanced/patches/peacocktv/ads/HideAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/peacocktv/ads/HideAdsPatch.kt @@ -1,16 +1,15 @@ package app.revanced.patches.peacocktv.ads -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.util.returnEarly -@Suppress("unused") -val hideAdsPatch = bytecodePatch( - name = "Hide ads", - description = "Hides all video ads.", +@Suppress("unused", "ObjectPropertyName") +val `Hide Ads` by creatingBytecodePatch( + description = "Hides all video ads." ) { compatibleWith("com.peacocktv.peacockandroid") apply { - mediaTailerAdServiceFingerprint.method.returnEarly(false) + mediaTailerAdServiceMethod.returnEarly(false) } } From b8cacb507d6b2a11ecb9aed78611945f6b46db46 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sun, 11 Jan 2026 23:50:09 +0700 Subject: [PATCH 08/55] refactor(netguard): RemoveBroadcastsRestrictionPatch --- .../removerestriction/RemoveBroadcastsRestrictionPatch.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/netguard/broadcasts/removerestriction/RemoveBroadcastsRestrictionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/netguard/broadcasts/removerestriction/RemoveBroadcastsRestrictionPatch.kt index a7e6912e0..3ed424595 100644 --- a/patches/src/main/kotlin/app/revanced/patches/netguard/broadcasts/removerestriction/RemoveBroadcastsRestrictionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/netguard/broadcasts/removerestriction/RemoveBroadcastsRestrictionPatch.kt @@ -1,11 +1,10 @@ package app.revanced.patches.netguard.broadcasts.removerestriction -import app.revanced.patcher.patch.resourcePatch +import app.revanced.patcher.patch.creatingResourcePatch import org.w3c.dom.Element -@Suppress("unused") -val removeBroadcastsRestrictionPatch = resourcePatch( - name = "Remove broadcasts restriction", +@Suppress("unused", "ObjectPropertyName") +val `Remove broadcasts restriction` by creatingResourcePatch( description = "Enables starting/stopping NetGuard via broadcasts.", ) { compatibleWith("eu.faircode.netguard") From 8e94a17c28f510dac108bf2494e3320ba124e5e6 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sun, 11 Jan 2026 23:52:48 +0700 Subject: [PATCH 09/55] refactor(myfitnesspal): HideAdsPatch --- .../patches/myfitnesspal/ads/Fingerprints.kt | 23 +++++++++++-------- .../patches/myfitnesspal/ads/HideAdsPatch.kt | 13 +++++------ 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/myfitnesspal/ads/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/myfitnesspal/ads/Fingerprints.kt index 160e2db27..92a1e2ad5 100644 --- a/patches/src/main/kotlin/app/revanced/patches/myfitnesspal/ads/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/myfitnesspal/ads/Fingerprints.kt @@ -1,19 +1,22 @@ package app.revanced.patches.myfitnesspal.ads -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.accessFlags +import app.revanced.patcher.definingClass +import app.revanced.patcher.name +import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags -internal val isPremiumUseCaseImplFingerprint = fingerprint { +internal val BytecodePatchContext.isPremiumUseCaseImplMethod by gettingFirstMutableMethodDeclaratively { accessFlags(AccessFlags.PUBLIC) - custom { method, classDef -> - classDef.endsWith("IsPremiumUseCaseImpl;") && method.name == "doWork" - } + definingClass("IsPremiumUseCaseImpl;") + name("doWork") } -internal val mainActivityNavigateToNativePremiumUpsellFingerprint = fingerprint { +internal val BytecodePatchContext.mainActivityNavigateToNativePremiumUpsellMethod by gettingFirstMutableMethodDeclaratively { accessFlags(AccessFlags.PRIVATE, AccessFlags.FINAL) - returns("V") - custom { method, classDef -> - classDef.endsWith("MainActivity;") && method.name == "navigateToNativePremiumUpsell" - } + returnType("V") + definingClass("MainActivity;") + name("navigateToNativePremiumUpsell") } diff --git a/patches/src/main/kotlin/app/revanced/patches/myfitnesspal/ads/HideAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/myfitnesspal/ads/HideAdsPatch.kt index f32015c62..43bc2fb62 100644 --- a/patches/src/main/kotlin/app/revanced/patches/myfitnesspal/ads/HideAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/myfitnesspal/ads/HideAdsPatch.kt @@ -1,18 +1,17 @@ package app.revanced.patches.myfitnesspal.ads import app.revanced.patcher.extensions.replaceInstructions -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch -@Suppress("unused") -val hideAdsPatch = bytecodePatch( - name = "Hide ads", - description = "Hides most of the ads across the app.", +@Suppress("unused", "ObjectPropertyName") +val `Hide ads` by creatingBytecodePatch( + description = "Hides most of the ads across the app." ) { compatibleWith("com.myfitnesspal.android"("24.14.2")) apply { // Overwrite the premium status specifically for ads. - isPremiumUseCaseImplFingerprint.method.replaceInstructions( + isPremiumUseCaseImplMethod.replaceInstructions( 0, """ sget-object v0, Ljava/lang/Boolean;->TRUE:Ljava/lang/Boolean; @@ -22,7 +21,7 @@ val hideAdsPatch = bytecodePatch( // Prevent the premium upsell dialog from showing when the main activity is launched. // In other places that are premium-only the dialog will still show. - mainActivityNavigateToNativePremiumUpsellFingerprint.method.replaceInstructions( + mainActivityNavigateToNativePremiumUpsellMethod.replaceInstructions( 0, "return-void", ) From d5c56c4889cf68b98ed7ead10e07da88345abdd6 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sun, 11 Jan 2026 23:54:35 +0700 Subject: [PATCH 10/55] refactor(myexpenses): UnlockProPatch --- .../patches/myexpenses/misc/pro/Fingerprints.kt | 9 +++++---- .../patches/myexpenses/misc/pro/UnlockProPatch.kt | 10 ++++------ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/myexpenses/misc/pro/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/myexpenses/misc/pro/Fingerprints.kt index 6bc4c21e5..a143e7372 100644 --- a/patches/src/main/kotlin/app/revanced/patches/myexpenses/misc/pro/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/myexpenses/misc/pro/Fingerprints.kt @@ -1,8 +1,9 @@ package app.revanced.patches.myexpenses.misc.pro -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType -internal val isEnabledFingerprint = fingerprint { - returns("Z") - strings("feature", "feature.licenceStatus") +internal val BytecodePatchContext.isEnabledMethod by gettingFirstMutableMethodDeclaratively("feature", "feature.licenceStatus") { + returnType("Z") } \ No newline at end of file diff --git a/patches/src/main/kotlin/app/revanced/patches/myexpenses/misc/pro/UnlockProPatch.kt b/patches/src/main/kotlin/app/revanced/patches/myexpenses/misc/pro/UnlockProPatch.kt index bc85dc122..11f1460cd 100644 --- a/patches/src/main/kotlin/app/revanced/patches/myexpenses/misc/pro/UnlockProPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/myexpenses/misc/pro/UnlockProPatch.kt @@ -1,16 +1,14 @@ package app.revanced.patches.myexpenses.misc.pro import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch -@Suppress("unused") -val unlockProPatch = bytecodePatch( - name = "Unlock pro", -) { +@Suppress("unused", "ObjectPropertyName") +val `Unlock pro` by creatingBytecodePatch { compatibleWith("org.totschnig.myexpenses"("3.4.9")) apply { - isEnabledFingerprint.method.addInstructions( + isEnabledMethod.addInstructions( 0, """ const/4 v0, 0x1 From e7d596e4d8afdbbdadf99f28364e40ae0e0d6cd7 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sun, 11 Jan 2026 23:59:39 +0700 Subject: [PATCH 11/55] refactor(pixiv): HideAdsPatch --- .../revanced/patches/pixiv/ads/Fingerprints.kt | 16 ++++++++++------ .../revanced/patches/pixiv/ads/HideAdsPatch.kt | 10 ++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/pixiv/ads/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/pixiv/ads/Fingerprints.kt index 3e2addaa0..ce3d3d813 100644 --- a/patches/src/main/kotlin/app/revanced/patches/pixiv/ads/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/pixiv/ads/Fingerprints.kt @@ -1,12 +1,16 @@ package app.revanced.patches.pixiv.ads +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.accessFlags +import app.revanced.patcher.definingClass +import app.revanced.patcher.name +import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags -import app.revanced.patcher.fingerprint -internal val shouldShowAdsFingerprint = fingerprint { +internal val BytecodePatchContext.shouldShowAdsMethod by gettingFirstMutableMethodDeclaratively { accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) - returns("Z") - custom { methodDef, classDef -> - classDef.type.endsWith("AdUtils;") && methodDef.name == "shouldShowAds" - } + returnType("Z") + definingClass("AdUtils;"::endsWith) + name("shouldShowAds") } diff --git a/patches/src/main/kotlin/app/revanced/patches/pixiv/ads/HideAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/pixiv/ads/HideAdsPatch.kt index 93962a332..c854e761f 100644 --- a/patches/src/main/kotlin/app/revanced/patches/pixiv/ads/HideAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/pixiv/ads/HideAdsPatch.kt @@ -1,15 +1,13 @@ package app.revanced.patches.pixiv.ads -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.util.returnEarly -@Suppress("unused") -val hideAdsPatch = bytecodePatch( - name = "Hide ads", -) { +@Suppress("unused", "ObjectPropertyName") +val `Hide ads` by creatingBytecodePatch { compatibleWith("jp.pxv.android"("6.141.1")) apply { - shouldShowAdsFingerprint.method.returnEarly(false) + shouldShowAdsMethod.returnEarly(false) } } From 1cecadf54c9aa82c606523efaad34d15f9844aac Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 00:01:21 +0700 Subject: [PATCH 12/55] refactor(rar): HidePurchaseReminderPatch --- .../annoyances/purchasereminder/Fingerprints.kt | 16 ++++++++++------ .../HidePurchaseReminderPatch.kt | 12 +++++------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/rar/misc/annoyances/purchasereminder/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/rar/misc/annoyances/purchasereminder/Fingerprints.kt index a4d2c9e22..3dd0dddf6 100644 --- a/patches/src/main/kotlin/app/revanced/patches/rar/misc/annoyances/purchasereminder/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/rar/misc/annoyances/purchasereminder/Fingerprints.kt @@ -1,12 +1,16 @@ package app.revanced.patches.rar.misc.annoyances.purchasereminder -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.accessFlags +import app.revanced.patcher.definingClass +import app.revanced.patcher.name +import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags -internal val showReminderFingerprint = fingerprint { +internal val BytecodePatchContext.showReminderMethod by gettingFirstMutableMethodDeclaratively { accessFlags(AccessFlags.PUBLIC, AccessFlags.STATIC) - returns("V") - custom { method, _ -> - method.definingClass.endsWith("AdsNotify;") && method.name == "show" - } + returnType("V") + definingClass("AdsNotify;"::endsWith) + name("show") } diff --git a/patches/src/main/kotlin/app/revanced/patches/rar/misc/annoyances/purchasereminder/HidePurchaseReminderPatch.kt b/patches/src/main/kotlin/app/revanced/patches/rar/misc/annoyances/purchasereminder/HidePurchaseReminderPatch.kt index 59b3eb1f8..45e253a54 100644 --- a/patches/src/main/kotlin/app/revanced/patches/rar/misc/annoyances/purchasereminder/HidePurchaseReminderPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/rar/misc/annoyances/purchasereminder/HidePurchaseReminderPatch.kt @@ -1,17 +1,15 @@ package app.revanced.patches.rar.misc.annoyances.purchasereminder import app.revanced.patcher.extensions.addInstruction -import app.revanced.patcher.patch.bytecodePatch - -@Suppress("unused") -val hidePurchaseReminderPatch = bytecodePatch( - name = "Hide purchase reminder", - description = "Hides the popup that reminds you to purchase the app.", +import app.revanced.patcher.patch.creatingBytecodePatch +@Suppress("unused", "ObjectPropertyName") +val `Hide purchase reminder` by creatingBytecodePatch( + description = "Hides the popup that reminds you to purchase the app." ) { compatibleWith("com.rarlab.rar") apply { - showReminderFingerprint.method.addInstruction(0, "return-void") + showReminderMethod.addInstruction(0, "return-void") } } From c17bfcb452912cea88e6027028c345d19b6e6a83 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 00:04:41 +0700 Subject: [PATCH 13/55] refactor(piccomafr): DisableTrackingPatch --- .../tracking/DisableTrackingPatch.kt | 15 +++++++------ .../piccomafr/tracking/Fingerprints.kt | 21 ++++++++----------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/piccomafr/tracking/DisableTrackingPatch.kt b/patches/src/main/kotlin/app/revanced/patches/piccomafr/tracking/DisableTrackingPatch.kt index a31cfff13..a83fef5de 100644 --- a/patches/src/main/kotlin/app/revanced/patches/piccomafr/tracking/DisableTrackingPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/piccomafr/tracking/DisableTrackingPatch.kt @@ -3,16 +3,15 @@ package app.revanced.patches.piccomafr.tracking import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.extensions.instructions import app.revanced.patcher.extensions.replaceInstruction -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.util.getReference import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.reference.StringReference -@Suppress("unused") -val disableTrackingPatch = bytecodePatch( - name = "Disable tracking", - description = "Disables tracking by replacing tracking URLs with example.com.", +@Suppress("unused", "ObjectPropertyName") +val `Disable tracking` by creatingBytecodePatch( + description = "Disables tracking by replacing tracking URLs with example.com." ) { compatibleWith( "com.piccomaeurope.fr"( @@ -34,7 +33,7 @@ val disableTrackingPatch = bytecodePatch( ) apply { - facebookSDKFingerprint.method.apply { + facebookSDKMethod.apply { instructions.filter { instruction -> instruction.opcode == Opcode.CONST_STRING }.forEach { instruction -> @@ -47,7 +46,7 @@ val disableTrackingPatch = bytecodePatch( } } - firebaseInstallFingerprint.method.apply { + firebaseInstallMethod.apply { instructions.filter { it.opcode == Opcode.CONST_STRING }.filter { @@ -62,6 +61,6 @@ val disableTrackingPatch = bytecodePatch( } } - appMeasurementFingerprint.method.addInstruction(0, "return-void") + appMeasurementMethod.addInstruction(0, "return-void") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/piccomafr/tracking/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/piccomafr/tracking/Fingerprints.kt index 83b3e56f4..2b727fef4 100644 --- a/patches/src/main/kotlin/app/revanced/patches/piccomafr/tracking/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/piccomafr/tracking/Fingerprints.kt @@ -1,23 +1,20 @@ package app.revanced.patches.piccomafr.tracking -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.accessFlags +import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags -internal val appMeasurementFingerprint = fingerprint { +internal val BytecodePatchContext.appMeasurementMethod by gettingFirstMutableMethodDeclaratively("config/app/", "Fetching remote configuration") { accessFlags(AccessFlags.PRIVATE, AccessFlags.FINAL) - returns("V") - strings("config/app/", "Fetching remote configuration") + returnType("V") } -internal val facebookSDKFingerprint = fingerprint { - accessFlags(AccessFlags.STATIC, AccessFlags.CONSTRUCTOR) - strings("instagram.com", "facebook.com") +internal val BytecodePatchContext.facebookSDKMethod by gettingFirstMutableMethodDeclaratively("instagram.com", "facebook.com") { + accessFlags(AccessFlags.PRIVATE, AccessFlags.CONSTRUCTOR) } -internal val firebaseInstallFingerprint = fingerprint { +internal val BytecodePatchContext.firebaseInstallMethod by gettingFirstMutableMethodDeclaratively("https://%s/%s/%s", "firebaseinstallations.googleapis.com") { accessFlags(AccessFlags.PRIVATE) - strings( - "https://%s/%s/%s", - "firebaseinstallations.googleapis.com", - ) } From 6a4c03220e8c33e6728fd1e7aaf15f5f21e7a5bc Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 00:08:18 +0700 Subject: [PATCH 14/55] refactor(protonvpn): RemoveDelayPatch --- .../patches/protonvpn/delay/Fingerprints.kt | 19 ++++++++----------- .../protonvpn/delay/RemoveDelayPatch.kt | 15 +++++++-------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/protonvpn/delay/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/protonvpn/delay/Fingerprints.kt index bc8ad3925..3ca1535d3 100644 --- a/patches/src/main/kotlin/app/revanced/patches/protonvpn/delay/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/protonvpn/delay/Fingerprints.kt @@ -1,16 +1,13 @@ package app.revanced.patches.protonvpn.delay -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.name +import app.revanced.patcher.patch.BytecodePatchContext - -internal val longDelayFingerprint = fingerprint { - custom { method, _ -> - method.name == "getChangeServerLongDelayInSeconds" - } +internal val BytecodePatchContext.longDelayMethod by gettingFirstMutableMethodDeclaratively { + name("getChangeServerLongDelayInSeconds") } -internal val shortDelayFingerprint = fingerprint { - custom { method, _ -> - method.name == "getChangeServerShortDelayInSeconds" - } -} \ No newline at end of file +internal val BytecodePatchContext.shortDelayMethod by gettingFirstMutableMethodDeclaratively { + name("getChangeServerShortDelayInSeconds") +} diff --git a/patches/src/main/kotlin/app/revanced/patches/protonvpn/delay/RemoveDelayPatch.kt b/patches/src/main/kotlin/app/revanced/patches/protonvpn/delay/RemoveDelayPatch.kt index 01794b88f..ceb771886 100644 --- a/patches/src/main/kotlin/app/revanced/patches/protonvpn/delay/RemoveDelayPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/protonvpn/delay/RemoveDelayPatch.kt @@ -1,17 +1,16 @@ package app.revanced.patches.protonvpn.delay -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.util.returnEarly -@Suppress("unused") -val removeDelayPatch = bytecodePatch( - name = "Remove delay", - description = "Removes the delay when changing servers.", +@Suppress("unused", "ObjectPropertyName") +val `Remove delay` by creatingBytecodePatch( + description = "Removes the delay when changing servers." ) { compatibleWith("ch.protonvpn.android") apply { - longDelayFingerprint.method.returnEarly(0) - shortDelayFingerprint.method.returnEarly(0) + longDelayMethod.returnEarly(0) + shortDelayMethod.returnEarly(0) } -} \ No newline at end of file +} From c7ea78824a08ef96b0def6b9859e2adbdd520bf0 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 00:10:13 +0700 Subject: [PATCH 15/55] refactor(protonmail): RemoveFreeAccountsLimitPatch --- .../protonmail/account/RemoveFreeAccountsLimitPatch.kt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/protonmail/account/RemoveFreeAccountsLimitPatch.kt b/patches/src/main/kotlin/app/revanced/patches/protonmail/account/RemoveFreeAccountsLimitPatch.kt index bc99597b9..0ed2f184e 100644 --- a/patches/src/main/kotlin/app/revanced/patches/protonmail/account/RemoveFreeAccountsLimitPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/protonmail/account/RemoveFreeAccountsLimitPatch.kt @@ -1,12 +1,11 @@ package app.revanced.patches.protonmail.account -import app.revanced.patcher.patch.resourcePatch +import app.revanced.patcher.patch.creatingResourcePatch import app.revanced.util.findElementByAttributeValueOrThrow -@Suppress("unused") -val removeFreeAccountsLimitPatch = resourcePatch( - name = "Remove free accounts limit", - description = "Removes the limit for maximum free accounts logged in.", +@Suppress("unused", "ObjectPropertyName") +val `Remove free accounts limit` by creatingResourcePatch( + description = "Removes the limit for maximum free accounts logged in." ) { compatibleWith("ch.protonmail.android"("4.15.0")) From 61225c825cdd680674d40ba1fee163072196d207 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 00:10:19 +0700 Subject: [PATCH 16/55] refactor(protonmail): RemoveSentFromSignaturePatch --- .../protonmail/signature/RemoveSentFromSignaturePatch.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/protonmail/signature/RemoveSentFromSignaturePatch.kt b/patches/src/main/kotlin/app/revanced/patches/protonmail/signature/RemoveSentFromSignaturePatch.kt index 440daca54..129c29224 100644 --- a/patches/src/main/kotlin/app/revanced/patches/protonmail/signature/RemoveSentFromSignaturePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/protonmail/signature/RemoveSentFromSignaturePatch.kt @@ -1,14 +1,14 @@ package app.revanced.patches.protonmail.signature import app.revanced.patcher.patch.PatchException +import app.revanced.patcher.patch.creatingResourcePatch import app.revanced.patcher.patch.resourcePatch import app.revanced.util.findElementByAttributeValue import java.io.File -@Suppress("unused") -val removeSentFromSignaturePatch = resourcePatch( - name = "Remove 'Sent from' signature", - description = "Removes the 'Sent from Proton Mail mobile' signature from emails.", +@Suppress("unused", "ObjectPropertyName") +val `Remove 'Sent from' signature` by creatingResourcePatch( + description = "Removes the 'Sent from Proton Mail mobile' signature from emails." ) { compatibleWith("ch.protonmail.android"("4.15.0")) From 7a41f5b28526dd8c73f4497ac2538a7e473244d2 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 14:53:46 +0700 Subject: [PATCH 17/55] refactor(music): SettingsPatch --- .../music/misc/settings/Fingerprints.kt | 18 +++++++++++------- .../music/misc/settings/SettingsPatch.kt | 11 ++++++----- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/music/misc/settings/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/music/misc/settings/Fingerprints.kt index 580e6e767..332b6e4b7 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/misc/settings/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/misc/settings/Fingerprints.kt @@ -1,11 +1,15 @@ package app.revanced.patches.music.misc.settings -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.definingClass +import app.revanced.patcher.name +import app.revanced.patcher.parameterTypes +import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType -internal val googleApiActivityFingerprint = fingerprint { - returns("V") - parameters("Landroid/os/Bundle;") - custom { method, classDef -> - classDef.endsWith("GoogleApiActivity;") && method.name == "onCreate" - } +internal val BytecodePatchContext.googleApiActivityMethod by gettingFirstMutableMethodDeclaratively { + returnType("V") + parameterTypes("Landroid/os/Bundle;") + definingClass("GoogleApiActivity;"::endsWith) + name("onCreate") } diff --git a/patches/src/main/kotlin/app/revanced/patches/music/misc/settings/SettingsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/music/misc/settings/SettingsPatch.kt index 3a153e8b9..c7315f5cf 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/misc/settings/SettingsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/misc/settings/SettingsPatch.kt @@ -1,6 +1,7 @@ package app.revanced.patches.music.misc.settings -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.classDef +import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.patcher.patch.resourcePatch import app.revanced.patches.all.misc.packagename.setOrGetFallbackPackageName import app.revanced.patches.all.misc.resources.addResources @@ -64,8 +65,8 @@ private val settingsResourcePatch = resourcePatch { } } -val settingsPatch = bytecodePatch( - description = "Adds settings for ReVanced to YouTube Music.", +val Settings by creatingBytecodePatch( + description = "Adds settings for ReVanced to YouTube Music." ) { dependsOn( sharedExtensionPatch, @@ -100,8 +101,8 @@ val settingsPatch = bytecodePatch( ) modifyActivityForSettingsInjection( - googleApiActivityFingerprint.classDef, - googleApiActivityFingerprint.method, + googleApiActivityMethod.classDef, + googleApiActivityMethod, GOOGLE_API_ACTIVITY_HOOK_CLASS_DESCRIPTOR, true ) From ae0240c69ba71c643a1b7a25528a9fad0c4459d2 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 14:58:21 +0700 Subject: [PATCH 18/55] refactor(music): VersionCheckPatch --- .../patches/music/playservice/VersionCheckPatch.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/music/playservice/VersionCheckPatch.kt b/patches/src/main/kotlin/app/revanced/patches/music/playservice/VersionCheckPatch.kt index e5b8ba0d0..a4339a3df 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/playservice/VersionCheckPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/playservice/VersionCheckPatch.kt @@ -2,7 +2,7 @@ package app.revanced.patches.music.playservice -import app.revanced.patcher.patch.resourcePatch +import app.revanced.patcher.patch.creatingResourcePatch import app.revanced.util.findPlayStoreServicesVersion import kotlin.properties.Delegates @@ -21,12 +21,14 @@ var is_8_11_or_greater: Boolean by Delegates.notNull() var is_8_15_or_greater: Boolean by Delegates.notNull() private set -val versionCheckPatch = resourcePatch( - description = "Uses the Play Store service version to find the major/minor version of the YouTube Music target app.", +@Suppress("unused", "ObjectPropertyName") +val `Version check` by creatingResourcePatch( + description = "Uses the Play Store service version to find the major/minor version of the YouTube Music target app." ) { apply { // The app version is missing from the decompiled manifest, // so instead use the Google Play services version and compare against specific releases. + // This requires ResourcePatchContext, which creatingResourcePatch provides. val playStoreServicesVersion = findPlayStoreServicesVersion() // All bug fix releases always seem to use the same play store version as the minor version. From f8e912f937f3d30a58a5b49a673cf80f89203162 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 15:04:05 +0700 Subject: [PATCH 19/55] refactor(reddit): HideBannerPatch --- .../app/revanced/patches/reddit/ad/banner/HideBannerPatch.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/ad/banner/HideBannerPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/ad/banner/HideBannerPatch.kt index adca01e02..dac78869c 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/ad/banner/HideBannerPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/ad/banner/HideBannerPatch.kt @@ -1,11 +1,12 @@ package app.revanced.patches.reddit.ad.banner -import app.revanced.patcher.patch.resourcePatch +import app.revanced.patcher.patch.creatingResourcePatch // Note that for now, this patch and anything using it will only work on // Reddit 2024.17.0 or older. Newer versions will crash during patching. // See https://github.com/ReVanced/revanced-patches/issues/3099 -val hideBannerPatch = resourcePatch( +@Suppress("unused") +val `Hide banner` = creatingResourcePatch( description = "Hides banner ads from comments on subreddits.", ) { apply { From da08df7d9eff859ee1e639507524020048ce8bee Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 15:07:36 +0700 Subject: [PATCH 20/55] refactor(reddit): HideCommentAdsPatch --- .../patches/reddit/ad/comments/Fingerprints.kt | 13 +++++++------ .../reddit/ad/comments/HideCommentAdsPatch.kt | 8 +++++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/ad/comments/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/ad/comments/Fingerprints.kt index 4fa8dbc81..9b8e61c67 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/ad/comments/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/ad/comments/Fingerprints.kt @@ -1,10 +1,11 @@ package app.revanced.patches.reddit.ad.comments -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.definingClass +import app.revanced.patcher.name +import app.revanced.patcher.patch.BytecodePatchContext -internal val hideCommentAdsFingerprint = fingerprint { - custom { method, classDef -> - method.name == "invokeSuspend" && - classDef.contains("LoadAdsCombinedCall") - } +internal val BytecodePatchContext.hideCommentAdsMethod by gettingFirstMutableMethodDeclaratively { + name("invokeSuspend") + definingClass("LoadAdsCombinedCall"::contains) } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/ad/comments/HideCommentAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/ad/comments/HideCommentAdsPatch.kt index 4890ea83c..0a19d4146 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/ad/comments/HideCommentAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/ad/comments/HideCommentAdsPatch.kt @@ -2,12 +2,14 @@ package app.revanced.patches.reddit.ad.comments import app.revanced.patcher.extensions.replaceInstructions import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch -val hideCommentAdsPatch = bytecodePatch( - description = "Removes ads in the comments.", +@Suppress("unused", "ObjectPropertyName") +val `Hide comment ads` by creatingBytecodePatch( + description = "Removes ads in the comments." ) { apply { - hideCommentAdsFingerprint.method.replaceInstructions(0, "return-object p1") + hideCommentAdsMethod.replaceInstructions(0, "return-object p1") } } From 4540e7a48462cb4ed622e77b5c4bd969e396d437 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 15:20:18 +0700 Subject: [PATCH 21/55] refactor(reddit): HideAdsPatch --- .../patches/reddit/ad/general/Fingerprints.kt | 26 ++++++++++++------- .../patches/reddit/ad/general/HideAdsPatch.kt | 20 +++++++------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/ad/general/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/ad/general/Fingerprints.kt index 22cf466fc..a637f8b6d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/ad/general/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/ad/general/Fingerprints.kt @@ -1,16 +1,24 @@ -package app.revanced.patches.reddit.ad.general +package app.revanced.patches.nunl.ads -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.definingClass +import app.revanced.patcher.instructions +import app.revanced.patcher.invoke +import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.Opcode -internal val adPostFingerprint = fingerprint { - returns("V") +internal val BytecodePatchContext.adPostMethod by gettingFirstMutableMethodDeclaratively("children") { + returnType("V") // "children" are present throughout multiple versions - strings("children") - custom { _, classDef -> classDef.endsWith("Listing;") } + instructions("children"()) + definingClass { endsWith("Listing;") } } -internal val newAdPostFingerprint = fingerprint { - opcodes(Opcode.INVOKE_VIRTUAL) - strings("feedElement", "com.reddit.cookie") +internal val BytecodePatchContext.newAdPostMethod by gettingFirstMutableMethodDeclaratively( + "feedElement", "com.reddit.cookie" +) { + instructions(Opcode.INVOKE_VIRTUAL()) + instructions("feedElement"()) + instructions("com.reddit.cookie"()) } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/ad/general/HideAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/ad/general/HideAdsPatch.kt index 14e53a3d0..f4393c252 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/ad/general/HideAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/ad/general/HideAdsPatch.kt @@ -2,8 +2,10 @@ package app.revanced.patches.reddit.ad.general import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.removeInstruction -import app.revanced.patcher.patch.bytecodePatch -import app.revanced.patches.reddit.ad.comments.hideCommentAdsPatch +import app.revanced.patcher.patch.creatingBytecodePatch +import app.revanced.patches.nunl.ads.adPostMethod +import app.revanced.patches.nunl.ads.newAdPostMethod +import app.revanced.patches.reddit.ad.comments.`Hide comment ads` import app.revanced.patches.reddit.misc.extension.sharedExtensionPatch import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction @@ -11,11 +13,11 @@ import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction22c import com.android.tools.smali.dexlib2.iface.reference.FieldReference import com.android.tools.smali.dexlib2.iface.reference.MethodReference -@Suppress("unused") -val hideAdsPatch = bytecodePatch( - name = "Hide ads", +@Suppress("unused", "ObjectPropertyName") +val `Hide ads` by creatingBytecodePatch( + description = "Hide ads" ) { - dependsOn(hideCommentAdsPatch, sharedExtensionPatch) + dependsOn(`Hide comment ads`, sharedExtensionPatch) compatibleWith("com.reddit.frontpage") @@ -26,7 +28,7 @@ val hideAdsPatch = bytecodePatch( "Lapp/revanced/extension/reddit/patches/FilterPromotedLinksPatch;" + "->filterChildren(Ljava/lang/Iterable;)Ljava/util/List;" - adPostFingerprint.method.apply { + adPostMethod.apply { val setPostsListChildren = implementation!!.instructions.first { instruction -> if (instruction.opcode != Opcode.IPUT_OBJECT) return@first false @@ -58,7 +60,7 @@ val hideAdsPatch = bytecodePatch( // AdElementConverter is conveniently responsible for inserting all feed ads. // By removing the appending instruction no ad posts gets appended to the feed. - val index = newAdPostFingerprint.originalMethod.implementation!!.instructions.indexOfFirst { + val index = newAdPostMethod.implementation!!.instructions.indexOfFirst { if (it.opcode != Opcode.INVOKE_VIRTUAL) return@indexOfFirst false val reference = (it as ReferenceInstruction).reference as MethodReference @@ -66,7 +68,7 @@ val hideAdsPatch = bytecodePatch( reference.name == "add" && reference.definingClass == "Ljava/util/ArrayList;" } - newAdPostFingerprint.method.removeInstruction(index) + newAdPostMethod.removeInstruction(index) } // endregion From eadc76b1617c2cea5aef0f8959e96b08f67cc1a8 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 15:28:50 +0700 Subject: [PATCH 22/55] refactor(baconreader): FixRedgifsApiPatch --- .../baconreader/fix/redgifs/Fingerprints.kt | 20 +++++++++++-------- .../fix/redgifs/FixRedgifsApiPatch.kt | 3 +-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/fix/redgifs/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/fix/redgifs/Fingerprints.kt index 78ce2c7db..fa5450809 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/fix/redgifs/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/fix/redgifs/Fingerprints.kt @@ -1,11 +1,15 @@ package app.revanced.patches.reddit.customclients.baconreader.fix.redgifs -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.definingClass +import app.revanced.patcher.name +import app.revanced.patcher.parameterTypes +import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType -internal val getOkHttpClientFingerprint = fingerprint { - returns("Lokhttp3/OkHttpClient;") - parameters() - custom { method, classDef -> - classDef.type == "Lcom/onelouder/baconreader/media/gfycat/RedGifsManager;" && method.name == "getOkhttpClient" - } -} \ No newline at end of file +internal val BytecodePatchContext.getOkHttpClientMethod by gettingFirstMutableMethodDeclaratively { + returnType("Lokhttp3/OkHttpClient;") + parameterTypes() + definingClass("Lcom/onelouder/baconreader/media/gfycat/RedGifsManager;") + name("getOkhttpClient") +} diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/fix/redgifs/FixRedgifsApiPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/fix/redgifs/FixRedgifsApiPatch.kt index 5b4d73241..8c1fd5614 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/fix/redgifs/FixRedgifsApiPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/fix/redgifs/FixRedgifsApiPatch.kt @@ -1,7 +1,6 @@ package app.revanced.patches.reddit.customclients.baconreader.fix.redgifs import app.revanced.patcher.extensions.getInstruction -import app.revanced.patcher.extensions.removeInstruction import app.revanced.patcher.extensions.removeInstructions import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patches.reddit.customclients.INSTALL_NEW_CLIENT_METHOD @@ -28,7 +27,7 @@ val fixRedgifsApi = fixRedgifsApiPatch( apply { // region Patch Redgifs OkHttp3 client. - getOkHttpClientFingerprint.method.apply { + getOkHttpClientMethod.apply { // Remove conflicting OkHttp interceptors. val originalInterceptorInstallIndex = indexOfFirstInstructionOrThrow { opcode == Opcode.NEW_INSTANCE && getReference()?.type == "Lcom/onelouder/baconreader/media/gfycat/RedGifsManager\$HeaderInterceptor;" From 8b833268bb64711ebd3f41ad15975a2680a24b13 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 15:40:35 +0700 Subject: [PATCH 23/55] refactor(baconreader): SpoofClientPatch --- .../baconreader/api/Fingerprints.kt | 27 +++++++++--------- .../baconreader/api/SpoofClientPatch.kt | 28 +++++++++++-------- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/api/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/api/Fingerprints.kt index bb87c2114..0626439cf 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/api/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/api/Fingerprints.kt @@ -1,19 +1,20 @@ package app.revanced.patches.reddit.customclients.baconreader.api -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.definingClass +import app.revanced.patcher.name +import app.revanced.patcher.patch.BytecodePatchContext -internal val getAuthorizationUrlFingerprint = fingerprint { - strings("client_id=zACVn0dSFGdWqQ") -} -internal val getClientIdFingerprint = fingerprint { - strings("client_id=zACVn0dSFGdWqQ") - custom { method, classDef -> - if (!classDef.endsWith("RedditOAuth;")) return@custom false +internal val BytecodePatchContext.getAuthorizationUrlMethod by gettingFirstMutableMethodDeclaratively( + "client_id=zACVn0dSFGdWqQ" +) - method.name == "getAuthorizeUrl" - } +internal val BytecodePatchContext.getClientIdMethod by gettingFirstMutableMethodDeclaratively("client_id=zACVn0dSFGdWqQ") { + name("getAuthorizeUrl") + definingClass { endsWith("RedditOAuth;") } } -internal val requestTokenFingerprint = fingerprint { - strings("zACVn0dSFGdWqQ", "kDm2tYpu9DqyWFFyPlNcXGEni4k") // App ID and secret. -} +internal val BytecodePatchContext.requestTokenMethod by gettingFirstMutableMethodDeclaratively( + "zACVn0dSFGdWqQ", + "kDm2tYpu9DqyWFFyPlNcXGEni4k" +) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/api/SpoofClientPatch.kt index 588af2338..e0485dacd 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/api/SpoofClientPatch.kt @@ -1,11 +1,15 @@ package app.revanced.patches.reddit.customclients.baconreader.api -import app.revanced.patcher.Fingerprint import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patches.reddit.customclients.spoofClientPatch import app.revanced.patches.shared.misc.string.replaceStringPatch +import app.revanced.util.getReference +import app.revanced.util.indexOfFirstInstructionOrThrow +import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction +import com.android.tools.smali.dexlib2.iface.reference.StringReference +import com.android.tools.smali.dexlib2.mutable.MutableMethod val spoofClientPatch = spoofClientPatch(redirectUri = "http://baconreader.com/auth") { clientIdOption -> dependsOn( @@ -22,22 +26,22 @@ val spoofClientPatch = spoofClientPatch(redirectUri = "http://baconreader.com/au val clientId by clientIdOption apply { - fun Fingerprint.patch(replacementString: String) { - val clientIdIndex = stringMatches.first().index - - method.apply { - val clientIdRegister = getInstruction(clientIdIndex).registerA - replaceInstruction( - clientIdIndex, - "const-string v$clientIdRegister, \"$replacementString\"", - ) + fun MutableMethod.patch(targetString: String, replacementString: String) { + val clientIdIndex = indexOfFirstInstructionOrThrow { + opcode == Opcode.CONST_STRING && getReference()?.string == targetString } + + val clientIdRegister = getInstruction(clientIdIndex).registerA + replaceInstruction( + clientIdIndex, + "const-string v$clientIdRegister, \"$replacementString\"", + ) } // Patch client id in authorization url. - getAuthorizationUrlFingerprint.patch("client_id=$clientId") + getAuthorizationUrlMethod.patch("client_id=zACVn0dSFGdWqQ", "client_id=$clientId") // Patch client id for access token request. - requestTokenFingerprint.patch(clientId!!) + requestTokenMethod.patch("zACVn0dSFGdWqQ", clientId!!) } } From 968dfde7a840622b520303d12957be23fa629ec2 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 15:42:53 +0700 Subject: [PATCH 24/55] refactor(boostforreddit): DisableAdsPatch --- .../boostforreddit/ads/DisableAdsPatch.kt | 12 +++++------- .../boostforreddit/ads/Fingerprints.kt | 15 ++++++++------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/ads/DisableAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/ads/DisableAdsPatch.kt index 5ffab44fc..f96c75505 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/ads/DisableAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/ads/DisableAdsPatch.kt @@ -1,17 +1,15 @@ package app.revanced.patches.reddit.customclients.boostforreddit.ads import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch -@Suppress("unused") -val disableAdsPatch = bytecodePatch( - name = "Disable ads", -) { +@Suppress("unused", "ObjectPropertyName") +val `Disable ads` by creatingBytecodePatch { compatibleWith("com.rubenmayayo.reddit") apply { - arrayOf(maxMediationFingerprint, admobMediationFingerprint).forEach { fingerprint -> - fingerprint.method.addInstructions(0, "return-void") + arrayOf(maxMediationMethod, admobMediationMethod).forEach { method -> + method.addInstructions(0, "return-void") } } } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/ads/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/ads/Fingerprints.kt index 618e2f145..475d10bdf 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/ads/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/ads/Fingerprints.kt @@ -1,11 +1,12 @@ package app.revanced.patches.reddit.customclients.boostforreddit.ads -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.patch.BytecodePatchContext -internal val maxMediationFingerprint = fingerprint { - strings("MaxMediation: Attempting to initialize SDK") -} +internal val BytecodePatchContext.maxMediationMethod by gettingFirstMutableMethodDeclaratively( + "MaxMediation: Attempting to initialize SDK" +) -internal val admobMediationFingerprint = fingerprint { - strings("AdmobMediation: Attempting to initialize SDK") -} +internal val BytecodePatchContext.admobMediationMethod by gettingFirstMutableMethodDeclaratively( + "AdmobMediation: Attempting to initialize SDK" +) From e2bc428b29e8a9c8b35eee5c9beb67ac3da36a0e Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 15:44:53 +0700 Subject: [PATCH 25/55] refactor(boostforreddit): SpoofClientPatch --- .../boostforreddit/api/Fingerprints.kt | 22 +++++++++---------- .../boostforreddit/api/SpoofClientPatch.kt | 20 ++++++++++++----- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/Fingerprints.kt index cc06fd396..0067b7c3c 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/Fingerprints.kt @@ -1,15 +1,15 @@ package app.revanced.patches.reddit.customclients.boostforreddit.api -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.definingClass +import app.revanced.patcher.name +import app.revanced.patcher.patch.BytecodePatchContext -internal val buildUserAgentFingerprint = fingerprint { - strings("%s:%s:%s (by /u/%s)") -} - -internal val getClientIdFingerprint = fingerprint { - custom { method, classDef -> - if (!classDef.endsWith("Credentials;")) return@custom false - - method.name == "getClientId" - } +internal val BytecodePatchContext.buildUserAgentMethod by gettingFirstMutableMethodDeclaratively( + "%s:%s:%s (by /u/%s)" +) + +internal val BytecodePatchContext.getClientIdMethod by gettingFirstMutableMethodDeclaratively { + name("getClientId") + definingClass { endsWith("Credentials;") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt index bc2c3b6c6..a977099da 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt @@ -3,9 +3,14 @@ package app.revanced.patches.reddit.customclients.boostforreddit.api import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patches.reddit.customclients.spoofClientPatch +import app.revanced.util.getReference +import app.revanced.util.indexOfFirstInstructionOrThrow import app.revanced.util.returnEarly +import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction +import com.android.tools.smali.dexlib2.iface.reference.StringReference +@Suppress("unused") val spoofClientPatch = spoofClientPatch(redirectUri = "http://rubenmayayo.com") { clientIdOption -> compatibleWith("com.rubenmayayo.reddit") @@ -14,7 +19,7 @@ val spoofClientPatch = spoofClientPatch(redirectUri = "http://rubenmayayo.com") apply { // region Patch client id. - getClientIdFingerprint.method.returnEarly(clientId!!) + getClientIdMethod.returnEarly(clientId!!) // endregion @@ -23,11 +28,14 @@ val spoofClientPatch = spoofClientPatch(redirectUri = "http://rubenmayayo.com") // Use a random user agent. val randomName = (0..100000).random() val userAgent = "$randomName:app.revanced.$randomName:v1.0.0 (by /u/revanced)" - buildUserAgentFingerprint.let { - val userAgentTemplateIndex = it.stringMatches.first().index - val register = it.method.getInstruction(userAgentTemplateIndex).registerA - - it.method.replaceInstruction(userAgentTemplateIndex, "const-string v$register, \"$userAgent\"") + + buildUserAgentMethod.apply { + val userAgentTemplateIndex = indexOfFirstInstructionOrThrow { + opcode == Opcode.CONST_STRING && getReference()?.string == "%s:%s:%s (by /u/%s)" + } + val register = getInstruction(userAgentTemplateIndex).registerA + + replaceInstruction(userAgentTemplateIndex, "const-string v$register, \"$userAgent\"") } // endregion From 68a57901d822f2ae6f8192e5b2ba6dc936e1663f Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 15:47:33 +0700 Subject: [PATCH 26/55] refactor(boostforreddit): FixSLinksPatch --- .../boostforreddit/fix/slink/Fingerprints.kt | 29 ++++++++++--------- .../fix/slink/FixSLinksPatch.kt | 4 +-- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/slink/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/slink/Fingerprints.kt index 665dba5a4..dd8541c67 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/slink/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/slink/Fingerprints.kt @@ -1,21 +1,22 @@ package app.revanced.patches.reddit.customclients.boostforreddit.fix.slink +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.accessFlags +import app.revanced.patcher.definingClass +import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags -import app.revanced.patcher.fingerprint -internal val getOAuthAccessTokenFingerprint = fingerprint { +internal val BytecodePatchContext.getOAuthAccessTokenMethod by gettingFirstMutableMethodDeclaratively("access_token") { accessFlags(AccessFlags.PUBLIC) - returns("Ljava/lang/String") - strings("access_token") - custom { method, _ -> method.definingClass == "Lnet/dean/jraw/http/oauth/OAuthData;" } + returnType("Ljava/lang/String;") + definingClass("Lnet/dean/jraw/http/oauth/OAuthData;") } -internal val handleNavigationFingerprint = fingerprint { - strings( - "android.intent.action.SEARCH", - "subscription", - "sort", - "period", - "boostforreddit.com/themes", - ) -} +internal val BytecodePatchContext.handleNavigationMethod by gettingFirstMutableMethodDeclaratively( + "android.intent.action.SEARCH", + "subscription", + "sort", + "period", + "boostforreddit.com/themes" +) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/slink/FixSLinksPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/slink/FixSLinksPatch.kt index 6960751f6..373aff56d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/slink/FixSLinksPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/slink/FixSLinksPatch.kt @@ -20,7 +20,7 @@ val fixSlinksPatch = fixSLinksPatch( apply { // region Patch navigation handler. - handleNavigationFingerprint.method.apply { + handleNavigationMethod.apply { val urlRegister = "p1" val tempRegister = "v1" @@ -40,7 +40,7 @@ val fixSlinksPatch = fixSLinksPatch( // region Patch set access token. - getOAuthAccessTokenFingerprint.method.addInstruction( + getOAuthAccessTokenMethod.addInstruction( 3, "invoke-static { v0 }, $EXTENSION_CLASS_DESCRIPTOR->$SET_ACCESS_TOKEN_METHOD", ) From 24cb9d987bba3967c23119d459c89b07d3572766 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 15:52:02 +0700 Subject: [PATCH 27/55] refactor(boostforreddit): FixAudioMissingInDownloadsPatch --- .../fix/downloads/Fingerprints.kt | 10 ++++--- .../FixAudioMissingInDownloadsPatch.kt | 26 ++++++++++++------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/downloads/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/downloads/Fingerprints.kt index a2b1530b8..9b8d09bfa 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/downloads/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/downloads/Fingerprints.kt @@ -1,7 +1,9 @@ package app.revanced.patches.reddit.customclients.boostforreddit.fix.downloads -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.patch.BytecodePatchContext -internal val downloadAudioFingerprint = fingerprint { - strings("/DASH_audio.mp4", "/audio") -} +internal val BytecodePatchContext.downloadAudioMethod by gettingFirstMutableMethodDeclaratively( + "/DASH_audio.mp4", + "/audio" +) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/downloads/FixAudioMissingInDownloadsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/downloads/FixAudioMissingInDownloadsPatch.kt index ec0f99ec7..8df738f2b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/downloads/FixAudioMissingInDownloadsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/downloads/FixAudioMissingInDownloadsPatch.kt @@ -2,12 +2,15 @@ package app.revanced.patches.reddit.customclients.boostforreddit.fix.downloads import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.replaceInstruction -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch +import app.revanced.util.findInstructionIndicesReversed +import app.revanced.util.getReference +import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction +import com.android.tools.smali.dexlib2.iface.reference.StringReference -@Suppress("unused") -val fixAudioMissingInDownloadsPatch = bytecodePatch( - name = "Fix missing audio in video downloads", +@Suppress("unused", "ObjectPropertyName") +val `Fix missing audio in video downloads` by creatingBytecodePatch( description = "Fixes audio missing in videos downloaded from v.redd.it.", ) { compatibleWith("com.rubenmayayo.reddit") @@ -18,12 +21,15 @@ val fixAudioMissingInDownloadsPatch = bytecodePatch( "/audio" to "/DASH_AUDIO_64.mp4", ) - downloadAudioFingerprint.method.apply { - downloadAudioFingerprint.stringMatches.forEach { match -> - val replacement = endpointReplacements[match.string] - val register = getInstruction(match.index).registerA - - replaceInstruction(match.index, "const-string v$register, \"$replacement\"") + downloadAudioMethod.apply { + endpointReplacements.forEach { (target, replacement) -> + // Find all occurrences of the target string in the method + findInstructionIndicesReversed { + opcode == Opcode.CONST_STRING && getReference()?.string == target + }.forEach { index -> + val register = getInstruction(index).registerA + replaceInstruction(index, "const-string v$register, \"$replacement\"") + } } } } From 7787268bedd84dc08573697d27e6549ed983e3c2 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 15:54:35 +0700 Subject: [PATCH 28/55] refactor(boostforreddit): FixRedgifsApiPatch --- .../fix/redgifs/Fingerprints.kt | 34 ++++++++++++------- .../fix/redgifs/FixRedgifsApiPatch.kt | 2 +- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/redgifs/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/redgifs/Fingerprints.kt index 1f3560d73..27e5f81ca 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/redgifs/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/redgifs/Fingerprints.kt @@ -1,20 +1,30 @@ package app.revanced.patches.reddit.customclients.boostforreddit.fix.redgifs -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.accessFlags +import app.revanced.patcher.classDef +import app.revanced.patcher.custom +import app.revanced.patcher.instructions +import app.revanced.patcher.invoke +import app.revanced.patcher.patch.BytecodePatchContext import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode +import com.android.tools.smali.dexlib2.iface.Method -internal val createOkHttpClientFingerprint = fingerprint { +internal val BytecodePatchContext.createOkHttpClientMethod by gettingFirstMutableMethodDeclaratively { accessFlags(AccessFlags.PRIVATE) - opcodes( - Opcode.NEW_INSTANCE, - Opcode.INVOKE_DIRECT, - Opcode.NEW_INSTANCE, - Opcode.INVOKE_DIRECT, - Opcode.NEW_INSTANCE, - Opcode.INVOKE_DIRECT, - Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT_OBJECT + instructions( + Opcode.NEW_INSTANCE(), + Opcode.INVOKE_DIRECT(), + Opcode.NEW_INSTANCE(), + Opcode.INVOKE_DIRECT(), + Opcode.NEW_INSTANCE(), + Opcode.INVOKE_DIRECT(), + Opcode.INVOKE_VIRTUAL(), + Opcode.MOVE_RESULT_OBJECT() ) - custom { _, classDef -> classDef.sourceFile == "RedGifsAPIv2.java" } + + // Helper to capture the BytecodePatchContext for classDef access + fun Method.isTargetSourceFile() = classDef.sourceFile == "RedGifsAPIv2.java" + custom { isTargetSourceFile() } } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/redgifs/FixRedgifsApiPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/redgifs/FixRedgifsApiPatch.kt index be54ca33c..4db18ee72 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/redgifs/FixRedgifsApiPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/redgifs/FixRedgifsApiPatch.kt @@ -19,7 +19,7 @@ val fixRedgifsApi = fixRedgifsApiPatch( apply { // region Patch Redgifs OkHttp3 client. - createOkHttpClientFingerprint.method.apply { + createOkHttpClientMethod.apply { val index = indexOfFirstInstructionOrThrow { val reference = getReference() reference?.name == "build" && reference.definingClass == "Lokhttp3/OkHttpClient\$Builder;" From 555b6fe3caca0d33f19e5a17c66433b8bc1bd6a1 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 15:57:16 +0700 Subject: [PATCH 29/55] refactor(infinityforreddit): UnlockSubscriptionPatch --- .../infinityforreddit/subscription/Fingerprints.kt | 12 ++++++------ .../subscription/UnlockSubscriptionPatch.kt | 13 ++++++------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/Fingerprints.kt index b8999d22c..c133028a6 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/Fingerprints.kt @@ -1,14 +1,14 @@ package app.revanced.patches.reddit.customclients.infinityforreddit.subscription -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.instructions import app.revanced.patcher.literal +import app.revanced.patcher.patch.BytecodePatchContext -internal val billingClientOnServiceConnectedFingerprint = fingerprint { - strings("Billing service connected") -} +internal val BytecodePatchContext.billingClientOnServiceConnectedMethod by gettingFirstMutableMethodDeclaratively("Billing service connected") -internal val startSubscriptionActivityFingerprint = fingerprint { +internal val BytecodePatchContext.startSubscriptionActivityMethod by gettingFirstMutableMethodDeclaratively { instructions( - literal(0x10008000) // Intent start flag only used in the subscription activity + literal(0x10008000) ) } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/UnlockSubscriptionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/UnlockSubscriptionPatch.kt index 86c228fca..6fc58b566 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/UnlockSubscriptionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/UnlockSubscriptionPatch.kt @@ -1,12 +1,11 @@ package app.revanced.patches.reddit.customclients.infinityforreddit.subscription -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.patches.reddit.customclients.infinityforreddit.api.spoofClientPatch import app.revanced.util.returnEarly -@Suppress("unused") -val unlockSubscriptionPatch = bytecodePatch( - name = "Unlock subscription", +@Suppress("unused", "ObjectPropertyName") +val `Unlock subscription` by creatingBytecodePatch( description = "Unlocks the subscription feature but requires a custom client ID.", ) { dependsOn(spoofClientPatch) @@ -19,8 +18,8 @@ val unlockSubscriptionPatch = bytecodePatch( apply { setOf( - startSubscriptionActivityFingerprint, - billingClientOnServiceConnectedFingerprint, - ).forEach { it.method.returnEarly() } + billingClientOnServiceConnectedMethod, + startSubscriptionActivityMethod, + ).forEach { it.returnEarly() } } } From cdec438fd4f4939462ad5467d460b51679276d06 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 15:59:23 +0700 Subject: [PATCH 30/55] refactor(joeyforreddit): DisableAdsPatch --- .../joeyforreddit/ads/DisableAdsPatch.kt | 9 ++++----- .../joeyforreddit/ads/Fingerprints.kt | 14 +++++++++----- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/DisableAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/DisableAdsPatch.kt index 25db4840b..e93bc20c4 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/DisableAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/DisableAdsPatch.kt @@ -2,18 +2,17 @@ package app.revanced.patches.reddit.customclients.joeyforreddit.ads import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.disablePiracyDetectionPatch -@Suppress("unused") -val disableAdsPatch = bytecodePatch( - name = "Disable ads", -) { +@Suppress("unused", "ObjectPropertyName") +val `Disable ads` by creatingBytecodePatch { dependsOn(disablePiracyDetectionPatch) compatibleWith("o.o.joey") apply { - isAdFreeUserFingerprint.method.addInstructions( + isAdFreeUserMethod.addInstructions( 0, """ const/4 v0, 0x1 diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/Fingerprints.kt index 465faf120..da1c7a574 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/Fingerprints.kt @@ -1,10 +1,14 @@ package app.revanced.patches.reddit.customclients.joeyforreddit.ads +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.accessFlags +import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType +import app.revanced.patcher.string import com.android.tools.smali.dexlib2.AccessFlags -import app.revanced.patcher.fingerprint -internal val isAdFreeUserFingerprint = fingerprint { +internal val BytecodePatchContext.isAdFreeUserMethod by gettingFirstMutableMethodDeclaratively { accessFlags(AccessFlags.PUBLIC) - returns("Z") - strings("AD_FREE_USER") -} \ No newline at end of file + returnType("Z") + string("AD_FREE_USER") +} From b6c1ec7d18785666d3b6c8cb51d7be16cdf29add Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 16:03:25 +0700 Subject: [PATCH 31/55] refactor(joeyforreddit): SpoofClientPatch --- .../joeyforreddit/api/Fingerprints.kt | 43 ++++++++++--------- .../joeyforreddit/api/SpoofClientPatch.kt | 6 ++- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/Fingerprints.kt index e6c591748..0c2240404 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/Fingerprints.kt @@ -1,28 +1,31 @@ -package app.revanced.patches.reddit.customclients.joeyforreddit.api +package app.revanced.patches.reddit.customclients.infinity.api -import com.android.tools.smali.dexlib2.Opcode +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.accessFlags +import app.revanced.patcher.classDef +import app.revanced.patcher.custom +import app.revanced.patcher.instructions +import app.revanced.patcher.invoke +import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags -import app.revanced.patcher.fingerprint +import com.android.tools.smali.dexlib2.Opcode -internal val authUtilityUserAgentFingerprint = fingerprint { +internal val BytecodePatchContext.authUtilityUserAgentMethod by gettingFirstMutableMethodDeclaratively { accessFlags(AccessFlags.PUBLIC, AccessFlags.STATIC) - returns("Ljava/lang/String;") - opcodes(Opcode.APUT_OBJECT) - custom { method, classDef -> - classDef.sourceFile == "AuthUtility.java" - } + returnType("Ljava/lang/String;") + instructions(Opcode.APUT_OBJECT()) + custom { classDef.sourceFile == "AuthUtility.java" } } -internal val getClientIdFingerprint = fingerprint { +internal val BytecodePatchContext.getClientIdMethod by gettingFirstMutableMethodDeclaratively { accessFlags(AccessFlags.PUBLIC, AccessFlags.STATIC) - returns("L") - opcodes( - Opcode.CONST, // R.string.valuable_cid - Opcode.INVOKE_STATIC, // StringMaster.decrypt - Opcode.MOVE_RESULT_OBJECT, - Opcode.RETURN_OBJECT + returnType("L") + instructions( + Opcode.CONST(), + Opcode.INVOKE_STATIC(), + Opcode.MOVE_RESULT_OBJECT(), + Opcode.RETURN_OBJECT(), ) - custom { _, classDef -> - classDef.sourceFile == "AuthUtility.java" - } -} \ No newline at end of file + custom { classDef.sourceFile == "AuthUtility.java" } +} diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt index 1de143ee7..323499f69 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt @@ -1,5 +1,7 @@ package app.revanced.patches.reddit.customclients.joeyforreddit.api +import app.revanced.patches.reddit.customclients.infinity.api.authUtilityUserAgentMethod +import app.revanced.patches.reddit.customclients.infinity.api.getClientIdMethod import app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.disablePiracyDetectionPatch import app.revanced.patches.reddit.customclients.spoofClientPatch import app.revanced.util.returnEarly @@ -18,7 +20,7 @@ val spoofClientPatch = spoofClientPatch(redirectUri = "https://127.0.0.1:65023/a apply { // region Patch client id. - getClientIdFingerprint.method.returnEarly(clientId!!) + getClientIdMethod.returnEarly(clientId!!) // endregion @@ -28,7 +30,7 @@ val spoofClientPatch = spoofClientPatch(redirectUri = "https://127.0.0.1:65023/a val randomName = (0..100000).random() val userAgent = "$randomName:app.revanced.$randomName:v1.0.0 (by /u/revanced)" - authUtilityUserAgentFingerprint.method.returnEarly(userAgent) + authUtilityUserAgentMethod.returnEarly(userAgent) // endregion } From 94cc175b5599bf80a90db1a2ae07878b356431ff Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 16:08:28 +0700 Subject: [PATCH 32/55] refactor(joeyforreddit): DisablePiracyDetectionPatch --- .../joeyforreddit/api/SpoofClientPatch.kt | 2 +- .../piracy/DisablePiracyDetectionPatch.kt | 8 ++--- .../detection/piracy/Fingerprints.kt | 34 +++++++++++-------- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt index 323499f69..28dba13cf 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt @@ -2,8 +2,8 @@ package app.revanced.patches.reddit.customclients.joeyforreddit.api import app.revanced.patches.reddit.customclients.infinity.api.authUtilityUserAgentMethod import app.revanced.patches.reddit.customclients.infinity.api.getClientIdMethod -import app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.disablePiracyDetectionPatch import app.revanced.patches.reddit.customclients.spoofClientPatch +import app.revanced.patches.reddit.customclients.sync.detection.piracy.disablePiracyDetectionPatch import app.revanced.util.returnEarly val spoofClientPatch = spoofClientPatch(redirectUri = "https://127.0.0.1:65023/authorize_callback") { clientIdOption -> diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/DisablePiracyDetectionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/DisablePiracyDetectionPatch.kt index aa8089358..5ad24d59f 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/DisablePiracyDetectionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/DisablePiracyDetectionPatch.kt @@ -1,11 +1,11 @@ package app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy import app.revanced.patcher.extensions.addInstruction -import app.revanced.patcher.patch.bytecodePatch - -val disablePiracyDetectionPatch = bytecodePatch { +import app.revanced.patcher.patch.creatingBytecodePatch +@Suppress("unused", "ObjectPropertyName") +val `Disable piracy detection` by creatingBytecodePatch { apply { - piracyDetectionFingerprint.method.addInstruction(0, "return-void") + piracyDetectionMethod.addInstruction(0, "return-void") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/Fingerprints.kt index 76343a530..aaffb09ae 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/Fingerprints.kt @@ -1,21 +1,25 @@ package app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy -import com.android.tools.smali.dexlib2.Opcode +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.accessFlags +import app.revanced.patcher.definingClass +import app.revanced.patcher.instructions +import app.revanced.patcher.invoke +import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags -import app.revanced.patcher.fingerprint +import com.android.tools.smali.dexlib2.Opcode -internal val piracyDetectionFingerprint = fingerprint { +internal val BytecodePatchContext.piracyDetectionMethod by gettingFirstMutableMethodDeclaratively { accessFlags(AccessFlags.PRIVATE, AccessFlags.STATIC) - returns("V") - opcodes( - Opcode.NEW_INSTANCE, - Opcode.CONST_16, - Opcode.CONST_WIDE_16, - Opcode.INVOKE_DIRECT, - Opcode.INVOKE_VIRTUAL, - Opcode.RETURN_VOID + returnType("V") + instructions( + Opcode.NEW_INSTANCE(), + Opcode.CONST_16(), + Opcode.CONST_WIDE_16(), + Opcode.INVOKE_DIRECT(), + Opcode.INVOKE_VIRTUAL(), + Opcode.RETURN_VOID() ) - custom { _, classDef -> - classDef.endsWith("ProcessLifeCyleListener;") - } -} \ No newline at end of file + definingClass("ProcessLifeCyleListener;"::endsWith) +} From 8dfcbd09cc77668383d1cdd498ec8ca03993df14 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 16:27:33 +0700 Subject: [PATCH 33/55] refactor(redditisfun): SpoofClientPatch --- .../redditisfun/api/Fingerprints.kt | 42 ++++++++++--------- .../redditisfun/api/SpoofClientPatch.kt | 40 ++++++++++++------ 2 files changed, 50 insertions(+), 32 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/Fingerprints.kt index 5b3029094..e8fda82a8 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/Fingerprints.kt @@ -1,31 +1,35 @@ package app.revanced.patches.reddit.customclients.redditisfun.api -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.accessFlags +import app.revanced.patcher.instructions +import app.revanced.patcher.invoke +import app.revanced.patcher.parameterTypes +import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode -internal fun baseClientIdFingerprint(string: String) = fingerprint { - strings("yyOCBp.RHJhDKd", string) -} - -internal val basicAuthorizationFingerprint = baseClientIdFingerprint( - string = "fJOxVwBUyo*=f: compatibleWith( "com.andrewshu.android.reddit", @@ -30,21 +31,34 @@ val spoofClientPatch = spoofClientPatch(redirectUri = "redditisfun://auth") { cl * @param getReplacementIndex A function that returns the index of the instruction to replace * using the [Match.StringMatch] list from the [Match]. */ - fun Fingerprint.replaceWith( + fun MutableMethod.replaceWith( string: String, - getReplacementIndex: List.() -> Int, - ) = method.apply { - val replacementIndex = stringMatches.getReplacementIndex() - val clientIdRegister = getInstruction(replacementIndex).registerA + offset: Int, + getReplacementIndex: String + ) { + val anchorIndex = indexOfFirstInstructionOrThrow { + opcode == Opcode.CONST_STRING && getReference()?.string == string + } - replaceInstruction(replacementIndex, "const-string v$clientIdRegister, \"$string\"") + val targetIndex = anchorIndex + offset + val clientIdRegister = getInstruction(targetIndex).registerA + + replaceInstruction(targetIndex, "const-string v$clientIdRegister, \"$getReplacementIndex\"") } // Patch OAuth authorization. - buildAuthorizationStringFingerprint.replaceWith(clientId!!) { first().index + 4 } + buildAuthorizationStringMethod.replaceWith( + string = "yyOCBp.RHJhDKd", + offset = 4, + getReplacementIndex = clientId!! + ) // Path basic authorization. - basicAuthorizationFingerprint.replaceWith("$clientId:") { last().index + 7 } + basicAuthorizationMethod.replaceWith( + string = "fJOxVwBUyo*=f:()?.contains("old.reddit.com") == true + getReference()?.string?.contains("old.reddit.com") == true } val targetRegister = getInstruction(index).registerA From decd7cb23c5686e909faf7f808faba4035675b64 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 16:29:36 +0700 Subject: [PATCH 34/55] refactor(relayforreddit): SpoofClientPatch --- .../relayforreddit/api/Fingerprints.kt | 45 ++++++++++--------- .../relayforreddit/api/SpoofClientPatch.kt | 35 ++++++++------- 2 files changed, 45 insertions(+), 35 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/Fingerprints.kt index 66ad07bbe..005883772 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/Fingerprints.kt @@ -1,27 +1,32 @@ package app.revanced.patches.reddit.customclients.relayforreddit.api -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.instructions +import app.revanced.patcher.invoke +import app.revanced.patcher.parameterTypes +import app.revanced.patcher.patch.BytecodePatchContext import com.android.tools.smali.dexlib2.Opcode -internal fun baseClientIdFingerprint(string: String) = fingerprint { - strings("dj-xCIZQYiLbEg", string) +internal val BytecodePatchContext.getLoggedInBearerTokenMethod by gettingFirstMutableMethodDeclaratively( + "dj-xCIZQYiLbEg", "authorization_code" +) + +internal val BytecodePatchContext.getLoggedOutBearerTokenMethod by gettingFirstMutableMethodDeclaratively( + "dj-xCIZQYiLbEg", "https://oauth.reddit.com/grants/installed_client" +) + +internal val BytecodePatchContext.getRefreshTokenMethod by gettingFirstMutableMethodDeclaratively( + "dj-xCIZQYiLbEg", "refresh_token" +) + +internal val BytecodePatchContext.loginActivityClientIdMethod by gettingFirstMutableMethodDeclaratively( + "dj-xCIZQYiLbEg", "&duration=permanent" +) + +internal val BytecodePatchContext.redditCheckDisableAPIMethod by gettingFirstMutableMethodDeclaratively("Reddit Disabled") { + instructions(Opcode.IF_EQZ()) } -internal val getLoggedInBearerTokenFingerprint = baseClientIdFingerprint("authorization_code") - -internal val getLoggedOutBearerTokenFingerprint = baseClientIdFingerprint("https://oauth.reddit.com/grants/installed_client") - -internal val getRefreshTokenFingerprint = baseClientIdFingerprint("refresh_token") - -internal val loginActivityClientIdFingerprint = baseClientIdFingerprint("&duration=permanent") - -internal val redditCheckDisableAPIFingerprint = fingerprint { - opcodes(Opcode.IF_EQZ) - strings("Reddit Disabled") +internal val BytecodePatchContext.setRemoteConfigMethod by gettingFirstMutableMethodDeclaratively("reddit_oauth_url") { + parameterTypes("Lcom/google/firebase/remoteconfig/FirebaseRemoteConfig;") } - -internal val setRemoteConfigFingerprint = fingerprint { - parameters("Lcom/google/firebase/remoteconfig/FirebaseRemoteConfig;") - strings("reddit_oauth_url") -} - diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/SpoofClientPatch.kt index fa6745dcc..58a35990d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/SpoofClientPatch.kt @@ -4,33 +4,39 @@ import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patches.reddit.customclients.spoofClientPatch +import app.revanced.util.getReference +import app.revanced.util.indexOfFirstInstructionOrThrow import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction10t import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21t import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction +import com.android.tools.smali.dexlib2.iface.reference.StringReference -val spoofClientPatch = spoofClientPatch(redirectUri = "dbrady://relay") { +@Suppress("unused") +val spoofClientPatch = spoofClientPatch(redirectUri = "dbrady://relay") { clientIdOption -> compatibleWith( "free.reddit.news", "reddit.news", ) - val clientId by it + val clientId by clientIdOption apply { // region Patch client id. - setOf( - loginActivityClientIdFingerprint, - getLoggedInBearerTokenFingerprint, - getLoggedOutBearerTokenFingerprint, - getRefreshTokenFingerprint, - ).forEach { fingerprint -> - val clientIdIndex = fingerprint.stringMatches.first().index - fingerprint.method.apply { + listOf( + loginActivityClientIdMethod, + getLoggedInBearerTokenMethod, + getLoggedOutBearerTokenMethod, + getRefreshTokenMethod, + ).forEach { method -> + method.apply { + val clientIdIndex = indexOfFirstInstructionOrThrow { + opcode == Opcode.CONST_STRING && getReference()?.string == "dj-xCIZQYiLbEg" + } val clientIdRegister = getInstruction(clientIdIndex).registerA - fingerprint.method.replaceInstruction( + replaceInstruction( clientIdIndex, "const-string v$clientIdRegister, \"$clientId\"", ) @@ -42,12 +48,11 @@ val spoofClientPatch = spoofClientPatch(redirectUri = "dbrady://relay") { // region Patch miscellaneous. // Do not load remote config which disables OAuth login remotely. - setRemoteConfigFingerprint.method.addInstructions(0, "return-void") + setRemoteConfigMethod.addInstructions(0, "return-void") // Prevent OAuth login being disabled remotely. - val checkIsOAuthRequestIndex = redditCheckDisableAPIFingerprint.instructionMatches.first().index - - redditCheckDisableAPIFingerprint.method.apply { + redditCheckDisableAPIMethod.apply { + val checkIsOAuthRequestIndex = indexOfFirstInstructionOrThrow(Opcode.IF_EQZ) val returnNextChain = getInstruction(checkIsOAuthRequestIndex).target replaceInstruction(checkIsOAuthRequestIndex, BuilderInstruction10t(Opcode.GOTO, returnNextChain)) } From 60861a850687971d9f208468f97f1fd0a23b168c Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 16:33:23 +0700 Subject: [PATCH 35/55] refactor(slide): SpoofClientPatch --- .../reddit/customclients/slide/api/Fingerprints.kt | 14 +++++++------- .../customclients/slide/api/SpoofClientPatch.kt | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/slide/api/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/slide/api/Fingerprints.kt index 4ff8be461..d7f9f5d80 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/slide/api/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/slide/api/Fingerprints.kt @@ -1,11 +1,11 @@ package app.revanced.patches.reddit.customclients.slide.api -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.definingClass +import app.revanced.patcher.name +import app.revanced.patcher.patch.BytecodePatchContext -internal val getClientIdFingerprint = fingerprint { - custom { method, classDef -> - if (!classDef.endsWith("Credentials;")) return@custom false - - method.name == "getClientId" - } +internal val BytecodePatchContext.getClientIdMethod by gettingFirstMutableMethodDeclaratively { + name("getClientId") + definingClass { endsWith("Credentials;") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/slide/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/slide/api/SpoofClientPatch.kt index 4e0600afb..70dec0a42 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/slide/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/slide/api/SpoofClientPatch.kt @@ -1,14 +1,14 @@ package app.revanced.patches.reddit.customclients.slide.api -import app.revanced.patches.reddit.customclients.spoofClientPatch +import app.revanced.patches.reddit.customclients.`Spoof client` import app.revanced.util.returnEarly -val spoofClientPatch = spoofClientPatch(redirectUri = "http://www.ccrama.me") { clientIdOption -> +val spoofClientPatch = `Spoof client`(redirectUri = "http://www.ccrama.me") { clientIdOption -> compatibleWith("me.ccrama.redditslide") val clientId by clientIdOption apply { - getClientIdFingerprint.method.returnEarly(clientId!!) + getClientIdMethod.returnEarly(clientId!!) } } From f4f43660da1367ef95e2eed04489834cec64bb92 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 16:34:39 +0700 Subject: [PATCH 36/55] refactor(reddit): block patch naming --- .../patches/reddit/customclients/FixRedgifsApiPatch.kt | 6 +++--- .../patches/reddit/customclients/FixSLinksPatch.kt | 6 +++--- .../patches/reddit/customclients/SpoofClientPatch.kt | 7 +++---- .../customclients/baconreader/api/SpoofClientPatch.kt | 4 ++-- .../baconreader/fix/redgifs/FixRedgifsApiPatch.kt | 4 ++-- .../customclients/boostforreddit/api/SpoofClientPatch.kt | 4 ++-- .../boostforreddit/fix/redgifs/FixRedgifsApiPatch.kt | 4 ++-- .../infinityforreddit/api/SpoofClientPatch.kt | 4 ++-- .../customclients/joeyforreddit/api/SpoofClientPatch.kt | 4 ++-- .../customclients/redditisfun/api/SpoofClientPatch.kt | 4 ++-- .../customclients/relayforreddit/api/SpoofClientPatch.kt | 4 ++-- .../sync/syncforreddit/api/SpoofClientPatch.kt | 4 ++-- .../sync/syncforreddit/fix/redgifs/FixRedgifsApiPatch.kt | 4 ++-- 13 files changed, 29 insertions(+), 30 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/FixRedgifsApiPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/FixRedgifsApiPatch.kt index 382e8cb97..ea3f5ce5e 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/FixRedgifsApiPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/FixRedgifsApiPatch.kt @@ -2,15 +2,15 @@ package app.revanced.patches.reddit.customclients import app.revanced.patcher.patch.BytecodePatchBuilder import app.revanced.patcher.patch.Patch -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch const val INSTALL_NEW_CLIENT_METHOD = "install(Lokhttp3/OkHttpClient${'$'}Builder;)Lokhttp3/OkHttpClient;" const val CREATE_NEW_CLIENT_METHOD = "createClient()Lokhttp3/OkHttpClient;" -fun fixRedgifsApiPatch( +fun `Fix Redgifs API`( extensionPatch: Patch, block: BytecodePatchBuilder.() -> Unit = {}, -) = bytecodePatch(name = "Fix Redgifs API") { +) = creatingBytecodePatch { dependsOn(extensionPatch) block() diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/FixSLinksPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/FixSLinksPatch.kt index 2c3d89acc..c130a1f7b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/FixSLinksPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/FixSLinksPatch.kt @@ -2,15 +2,15 @@ package app.revanced.patches.reddit.customclients import app.revanced.patcher.patch.BytecodePatchBuilder import app.revanced.patcher.patch.Patch -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch const val RESOLVE_S_LINK_METHOD = "patchResolveSLink(Ljava/lang/String;)Z" const val SET_ACCESS_TOKEN_METHOD = "patchSetAccessToken(Ljava/lang/String;)V" -fun fixSLinksPatch( +fun `Fix s links`( extensionPatch: Patch, block: BytecodePatchBuilder.() -> Unit = {}, -) = bytecodePatch(name = "Fix /s/ links") { +) = creatingBytecodePatch { dependsOn(extensionPatch) block() diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/SpoofClientPatch.kt index aeebd02a6..3a3851afb 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/SpoofClientPatch.kt @@ -2,7 +2,7 @@ package app.revanced.patches.reddit.customclients import app.revanced.patcher.patch.BytecodePatchBuilder import app.revanced.patcher.patch.Option -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.patcher.patch.stringOption /** @@ -11,11 +11,10 @@ import app.revanced.patcher.patch.stringOption * @param redirectUri The redirect URI of the Reddit OAuth client. * @param block The patch block. It is called with the client ID option. */ -fun spoofClientPatch( +fun `Spoof client`( redirectUri: String, block: BytecodePatchBuilder.(Option) -> Unit = {}, -) = bytecodePatch( - name = "Spoof client", +) = creatingBytecodePatch( description = "Restores functionality of the app by using custom client ID.", ) { block( diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/api/SpoofClientPatch.kt index e0485dacd..45994659b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/api/SpoofClientPatch.kt @@ -2,7 +2,7 @@ package app.revanced.patches.reddit.customclients.baconreader.api import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.replaceInstruction -import app.revanced.patches.reddit.customclients.spoofClientPatch +import app.revanced.patches.reddit.customclients.`Spoof client` import app.revanced.patches.shared.misc.string.replaceStringPatch import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow @@ -11,7 +11,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.reference.StringReference import com.android.tools.smali.dexlib2.mutable.MutableMethod -val spoofClientPatch = spoofClientPatch(redirectUri = "http://baconreader.com/auth") { clientIdOption -> +val spoofClientPatch = `Spoof client`(redirectUri = "http://baconreader.com/auth") { clientIdOption -> dependsOn( // Redirects from SSL to WWW domain are bugged causing auth problems. // Manually rewrite the URLs to fix this. diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/fix/redgifs/FixRedgifsApiPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/fix/redgifs/FixRedgifsApiPatch.kt index 8c1fd5614..68ce7ce72 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/fix/redgifs/FixRedgifsApiPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/fix/redgifs/FixRedgifsApiPatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.extensions.removeInstructions import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patches.reddit.customclients.INSTALL_NEW_CLIENT_METHOD import app.revanced.patches.reddit.customclients.baconreader.misc.extension.sharedExtensionPatch -import app.revanced.patches.reddit.customclients.fixRedgifsApiPatch +import app.revanced.patches.reddit.customclients.`Fix Redgifs API` import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import com.android.tools.smali.dexlib2.Opcode @@ -16,7 +16,7 @@ import com.android.tools.smali.dexlib2.iface.reference.TypeReference internal const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/baconreader/FixRedgifsApiPatch;" @Suppress("unused") -val fixRedgifsApi = fixRedgifsApiPatch( +val fixRedgifsApi = `Fix Redgifs API`( extensionPatch = sharedExtensionPatch ) { compatibleWith( diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt index a977099da..3677f9dff 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt @@ -2,7 +2,7 @@ package app.revanced.patches.reddit.customclients.boostforreddit.api import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.replaceInstruction -import app.revanced.patches.reddit.customclients.spoofClientPatch +import app.revanced.patches.reddit.customclients.`Spoof client` import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import app.revanced.util.returnEarly @@ -11,7 +11,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.reference.StringReference @Suppress("unused") -val spoofClientPatch = spoofClientPatch(redirectUri = "http://rubenmayayo.com") { clientIdOption -> +val spoofClientPatch = `Spoof client`(redirectUri = "http://rubenmayayo.com") { clientIdOption -> compatibleWith("com.rubenmayayo.reddit") val clientId by clientIdOption diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/redgifs/FixRedgifsApiPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/redgifs/FixRedgifsApiPatch.kt index 4db18ee72..bcc53c264 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/redgifs/FixRedgifsApiPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/redgifs/FixRedgifsApiPatch.kt @@ -3,7 +3,7 @@ package app.revanced.patches.reddit.customclients.boostforreddit.fix.redgifs import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patches.reddit.customclients.CREATE_NEW_CLIENT_METHOD import app.revanced.patches.reddit.customclients.boostforreddit.misc.extension.sharedExtensionPatch -import app.revanced.patches.reddit.customclients.fixRedgifsApiPatch +import app.revanced.patches.reddit.customclients.`Fix Redgifs API` import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import com.android.tools.smali.dexlib2.iface.reference.MethodReference @@ -11,7 +11,7 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/boostforreddit/FixRedgifsApiPatch;" @Suppress("unused") -val fixRedgifsApi = fixRedgifsApiPatch( +val fixRedgifsApi = `Fix Redgifs API`( extensionPatch = sharedExtensionPatch ) { compatibleWith("com.rubenmayayo.reddit") diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/SpoofClientPatch.kt index e87172b12..8a517551f 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/SpoofClientPatch.kt @@ -1,13 +1,13 @@ package app.revanced.patches.reddit.customclients.infinityforreddit.api import app.revanced.patcher.extensions.toInstructions -import app.revanced.patches.reddit.customclients.spoofClientPatch +import app.revanced.patches.reddit.customclients.`Spoof client` import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.immutable.ImmutableMethod import com.android.tools.smali.dexlib2.immutable.ImmutableMethodImplementation import com.android.tools.smali.dexlib2.mutable.MutableMethod.Companion.toMutable -val spoofClientPatch = spoofClientPatch(redirectUri = "infinity://localhost") { clientIdOption -> +val spoofClientPatch = `Spoof client`(redirectUri = "infinity://localhost") { clientIdOption -> compatibleWith( "ml.docilealligator.infinityforreddit", "ml.docilealligator.infinityforreddit.plus", diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt index 28dba13cf..d14b8ca59 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt @@ -2,11 +2,11 @@ package app.revanced.patches.reddit.customclients.joeyforreddit.api import app.revanced.patches.reddit.customclients.infinity.api.authUtilityUserAgentMethod import app.revanced.patches.reddit.customclients.infinity.api.getClientIdMethod -import app.revanced.patches.reddit.customclients.spoofClientPatch +import app.revanced.patches.reddit.customclients.`Spoof client` import app.revanced.patches.reddit.customclients.sync.detection.piracy.disablePiracyDetectionPatch import app.revanced.util.returnEarly -val spoofClientPatch = spoofClientPatch(redirectUri = "https://127.0.0.1:65023/authorize_callback") { clientIdOption -> +val spoofClientPatch = `Spoof client`(redirectUri = "https://127.0.0.1:65023/authorize_callback") { clientIdOption -> dependsOn(disablePiracyDetectionPatch) compatibleWith( diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch.kt index cb3c262b3..6c2cf9795 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch.kt @@ -2,7 +2,7 @@ package app.revanced.patches.reddit.customclients.redditisfun.api import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.replaceInstruction -import app.revanced.patches.reddit.customclients.spoofClientPatch +import app.revanced.patches.reddit.customclients.`Spoof client` import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import app.revanced.util.returnEarly @@ -12,7 +12,7 @@ import com.android.tools.smali.dexlib2.iface.reference.StringReference import com.android.tools.smali.dexlib2.mutable.MutableMethod @Suppress("unused") -val spoofClientPatch = spoofClientPatch(redirectUri = "redditisfun://auth") { clientIdOption -> +val spoofClientPatch = `Spoof client`(redirectUri = "redditisfun://auth") { clientIdOption -> compatibleWith( "com.andrewshu.android.reddit", "com.andrewshu.android.redditdonation", diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/SpoofClientPatch.kt index 58a35990d..534e89c26 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/SpoofClientPatch.kt @@ -3,7 +3,7 @@ package app.revanced.patches.reddit.customclients.relayforreddit.api import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.replaceInstruction -import app.revanced.patches.reddit.customclients.spoofClientPatch +import app.revanced.patches.reddit.customclients.`Spoof client` import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import com.android.tools.smali.dexlib2.Opcode @@ -13,7 +13,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.reference.StringReference @Suppress("unused") -val spoofClientPatch = spoofClientPatch(redirectUri = "dbrady://relay") { clientIdOption -> +val spoofClientPatch = `Spoof client`(redirectUri = "dbrady://relay") { clientIdOption -> compatibleWith( "free.reddit.news", "reddit.news", diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/api/SpoofClientPatch.kt index 47a5cf815..2b00e2051 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/api/SpoofClientPatch.kt @@ -2,7 +2,7 @@ package app.revanced.patches.reddit.customclients.sync.syncforreddit.api import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.replaceInstruction -import app.revanced.patches.reddit.customclients.spoofClientPatch +import app.revanced.patches.reddit.customclients.`Spoof client` import app.revanced.patches.reddit.customclients.sync.detection.piracy.disablePiracyDetectionPatch import app.revanced.patches.shared.misc.string.replaceStringPatch import app.revanced.util.returnEarly @@ -11,7 +11,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.reference.StringReference import java.util.Base64 -val spoofClientPatch = spoofClientPatch( +val spoofClientPatch = `Spoof client`( redirectUri = "http://redditsync/auth", ) { clientIdOption -> dependsOn( diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/redgifs/FixRedgifsApiPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/redgifs/FixRedgifsApiPatch.kt index 9d6454198..e1ad4257d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/redgifs/FixRedgifsApiPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/redgifs/FixRedgifsApiPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patches.reddit.customclients.INSTALL_NEW_CLIENT_METHOD -import app.revanced.patches.reddit.customclients.fixRedgifsApiPatch +import app.revanced.patches.reddit.customclients.`Fix Redgifs API` import app.revanced.patches.reddit.customclients.sync.syncforreddit.extension.sharedExtensionPatch import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow @@ -14,7 +14,7 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference internal const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/syncforreddit/FixRedgifsApiPatch;" @Suppress("unused") -val fixRedgifsApi = fixRedgifsApiPatch( +val fixRedgifsApi = `Fix Redgifs API`( extensionPatch = sharedExtensionPatch ) { compatibleWith( From 5477e8edbe3b5a764b0aef3af3ce8b1580ee1f50 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 16:46:43 +0700 Subject: [PATCH 37/55] refactor(sync): DisablePiracyDetectionPatch --- .../piracy/DisablePiracyDetectionPatch.kt | 6 ++-- .../sync/detection/piracy/Fingerprints.kt | 34 +++++++++---------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/DisablePiracyDetectionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/DisablePiracyDetectionPatch.kt index fc0e976ef..05215d133 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/DisablePiracyDetectionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/DisablePiracyDetectionPatch.kt @@ -1,15 +1,15 @@ package app.revanced.patches.reddit.customclients.sync.detection.piracy import app.revanced.patcher.extensions.addInstruction -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch -val disablePiracyDetectionPatch = bytecodePatch( +val `Disable privacy detection` = creatingBytecodePatch( description = "Disables detection of modified versions.", ) { apply { // Do not throw an error if the fingerprint is not resolved. // This is fine because new versions of the target app do not need this patch. - piracyDetectionFingerprint.methodOrNull?.addInstruction(0, "return-void") + piracyDetectionMethod.addInstruction(0, "return-void") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/Fingerprints.kt index 801a5ecaf..df2d43249 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/Fingerprints.kt @@ -1,26 +1,24 @@ package app.revanced.patches.reddit.customclients.sync.detection.piracy -import app.revanced.patcher.extensions.instructions -import app.revanced.patcher.fingerprint -import app.revanced.util.getReference +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.accessFlags +import app.revanced.patcher.instructions +import app.revanced.patcher.invoke +import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode -import com.android.tools.smali.dexlib2.iface.reference.Reference -internal val piracyDetectionFingerprint = fingerprint { +internal val BytecodePatchContext.piracyDetectionMethod by gettingFirstMutableMethodDeclaratively( + "Lcom/github/javiersantos/piracychecker/PiracyChecker;" +) { accessFlags(AccessFlags.PRIVATE, AccessFlags.FINAL) - returns("V") - opcodes( - Opcode.NEW_INSTANCE, - Opcode.INVOKE_DIRECT, - Opcode.NEW_INSTANCE, - Opcode.INVOKE_DIRECT, - Opcode.INVOKE_VIRTUAL, + returnType("V") + instructions( + Opcode.NEW_INSTANCE(), + Opcode.INVOKE_DIRECT(), + Opcode.NEW_INSTANCE(), + Opcode.INVOKE_DIRECT(), + Opcode.INVOKE_VIRTUAL(), ) - custom { method, _ -> - method.implementation ?: return@custom false - method.instructions.any { - it.getReference()?.toString() == "Lcom/github/javiersantos/piracychecker/PiracyChecker;" - } - } } From dd5b9ac58d6db1d664dc6e8a0e3cf029e45ca621 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 16:47:12 +0700 Subject: [PATCH 38/55] fix(joeyforreddit/Disable ads): Switch import naming --- .../customclients/joeyforreddit/ads/DisableAdsPatch.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/DisableAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/DisableAdsPatch.kt index e93bc20c4..1a912847d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/DisableAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/DisableAdsPatch.kt @@ -1,13 +1,12 @@ package app.revanced.patches.reddit.customclients.joeyforreddit.ads import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.patch.bytecodePatch import app.revanced.patcher.patch.creatingBytecodePatch -import app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.disablePiracyDetectionPatch +import app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.`Disable piracy detection` @Suppress("unused", "ObjectPropertyName") val `Disable ads` by creatingBytecodePatch { - dependsOn(disablePiracyDetectionPatch) + dependsOn(`Disable piracy detection`) compatibleWith("o.o.joey") From 2e6b7c2fe46804f4ab6c503c55acd33358c0f5da Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 16:49:57 +0700 Subject: [PATCH 39/55] refactor(syncforreddit): DisableSyncForLemmyBottomSheetPatch --- .../startup/DisableSyncForLemmyBottomSheetPatch.kt | 9 ++++----- .../syncforreddit/annoyances/startup/Fingerprints.kt | 12 +++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/annoyances/startup/DisableSyncForLemmyBottomSheetPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/annoyances/startup/DisableSyncForLemmyBottomSheetPatch.kt index 865af827d..a3ebe101a 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/annoyances/startup/DisableSyncForLemmyBottomSheetPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/annoyances/startup/DisableSyncForLemmyBottomSheetPatch.kt @@ -1,11 +1,10 @@ package app.revanced.patches.reddit.customclients.sync.syncforreddit.annoyances.startup import app.revanced.patcher.extensions.removeInstruction -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch -@Suppress("unused") -val disableSyncForLemmyBottomSheetPatch = bytecodePatch( - name = "Disable Sync for Lemmy bottom sheet", +@Suppress("unused", "ObjectPropertyName") +val `Disable Sync for Lemmy bottom sheet` = creatingBytecodePatch( description = "Disables the bottom sheet at the startup that asks you to signup to \"Sync for Lemmy\".", ) { compatibleWith( @@ -15,7 +14,7 @@ val disableSyncForLemmyBottomSheetPatch = bytecodePatch( ) apply { - mainActivityOnCreateFingerprint.method.apply { + mainActivityOnCreateMethod.apply { val showBottomSheetIndex = implementation!!.instructions.lastIndex - 1 removeInstruction(showBottomSheetIndex) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/annoyances/startup/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/annoyances/startup/Fingerprints.kt index 21c788a89..91d6e12c9 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/annoyances/startup/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/annoyances/startup/Fingerprints.kt @@ -1,9 +1,11 @@ package app.revanced.patches.reddit.customclients.sync.syncforreddit.annoyances.startup -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.definingClass +import app.revanced.patcher.name +import app.revanced.patcher.patch.BytecodePatchContext -internal val mainActivityOnCreateFingerprint = fingerprint { - custom { method, classDef -> - classDef.endsWith("MainActivity;") && method.name == "onCreate" - } +internal val BytecodePatchContext.mainActivityOnCreateMethod by gettingFirstMutableMethodDeclaratively { + definingClass("MainActivity;") + name("onCreate") } From 357051105c0020dc35e6ca25b4273c334cee0f80 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 17:01:16 +0700 Subject: [PATCH 40/55] fix(reddit/sync/Disable Piracy Detection): Privacy typo --- .../sync/detection/piracy/DisablePiracyDetectionPatch.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/DisablePiracyDetectionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/DisablePiracyDetectionPatch.kt index 05215d133..6b6524eaf 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/DisablePiracyDetectionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/DisablePiracyDetectionPatch.kt @@ -3,7 +3,7 @@ package app.revanced.patches.reddit.customclients.sync.detection.piracy import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.patch.creatingBytecodePatch -val `Disable privacy detection` = creatingBytecodePatch( +val `Disable piracy detection` by creatingBytecodePatch( description = "Disables detection of modified versions.", ) { From fcce0a6948577afa13b4e8bfc66540e300eb6f3b Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 17:01:25 +0700 Subject: [PATCH 41/55] refactor(syncforreddit): SpoofClientPatch --- .../sync/syncforreddit/api/Fingerprints.kt | 19 ++---- .../syncforreddit/api/SpoofClientPatch.kt | 59 +++++++++++-------- 2 files changed, 40 insertions(+), 38 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/api/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/api/Fingerprints.kt index c7902b1f4..1d2ff2bad 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/api/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/api/Fingerprints.kt @@ -1,19 +1,12 @@ package app.revanced.patches.reddit.customclients.sync.syncforreddit.api -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.patch.BytecodePatchContext -internal val getAuthorizationStringFingerprint = fingerprint { - strings("authorize.compact?client_id") -} +internal val BytecodePatchContext.getAuthorizationStringMethod by gettingFirstMutableMethodDeclaratively("authorize.compact?client_id") -internal val getBearerTokenFingerprint = fingerprint { - strings("Basic") -} +internal val BytecodePatchContext.getBearerTokenMethod by gettingFirstMutableMethodDeclaratively("Basic") -internal val getUserAgentFingerprint = fingerprint { - strings("android:com.laurencedawson.reddit_sync") -} +internal val BytecodePatchContext.getUserAgentMethod by gettingFirstMutableMethodDeclaratively("android:com.laurencedawson.reddit_sync") -internal val imgurImageAPIFingerprint = fingerprint { - strings("https://imgur-apiv3.p.rapidapi.com/3/image") -} +internal val BytecodePatchContext.imgurImageAPIMethod by gettingFirstMutableMethodDeclaratively("https://imgur-apiv3.p.rapidapi.com/3/image") diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/api/SpoofClientPatch.kt index 2b00e2051..469ca5086 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/api/SpoofClientPatch.kt @@ -3,19 +3,22 @@ package app.revanced.patches.reddit.customclients.sync.syncforreddit.api import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patches.reddit.customclients.`Spoof client` -import app.revanced.patches.reddit.customclients.sync.detection.piracy.disablePiracyDetectionPatch +import app.revanced.patches.reddit.customclients.sync.detection.piracy.`Disable piracy detection` import app.revanced.patches.shared.misc.string.replaceStringPatch +import app.revanced.util.getReference +import app.revanced.util.indexOfFirstInstructionOrThrow import app.revanced.util.returnEarly +import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.reference.StringReference import java.util.Base64 +@Suppress("unused") val spoofClientPatch = `Spoof client`( redirectUri = "http://redditsync/auth", ) { clientIdOption -> dependsOn( - disablePiracyDetectionPatch, + `Disable piracy detection`, // Redirects from SSL to WWW domain are bugged causing auth problems. // Manually rewrite the URLs to fix this. replaceStringPatch("ssl.reddit.com", "www.reddit.com") @@ -32,28 +35,30 @@ val spoofClientPatch = `Spoof client`( apply { // region Patch client id. - getBearerTokenFingerprint.match(getAuthorizationStringFingerprint.originalClassDef).method.apply { + getBearerTokenMethod.apply { val auth = Base64.getEncoder().encodeToString("$clientId:".toByteArray(Charsets.UTF_8)) returnEarly("Basic $auth") + } - val occurrenceIndex = - getAuthorizationStringFingerprint.stringMatches.first().index - - getAuthorizationStringFingerprint.method.apply { - val authorizationStringInstruction = getInstruction(occurrenceIndex) - val targetRegister = (authorizationStringInstruction as OneRegisterInstruction).registerA - val reference = authorizationStringInstruction.reference as StringReference - - val newAuthorizationUrl = reference.string.replace( - "client_id=.*?&".toRegex(), - "client_id=$clientId&", - ) - - replaceInstruction( - occurrenceIndex, - "const-string v$targetRegister, \"$newAuthorizationUrl\"", - ) + getAuthorizationStringMethod.apply { + val occurrenceIndex = indexOfFirstInstructionOrThrow { + opcode == Opcode.CONST_STRING && + getReference()?.string?.contains("client_id=") == true } + + val authorizationStringInstruction = getInstruction(occurrenceIndex) + val targetRegister = authorizationStringInstruction.registerA + val reference = authorizationStringInstruction.getReference()!! + + val newAuthorizationUrl = reference.string.replace( + "client_id=.*?&".toRegex(), + "client_id=$clientId&", + ) + + replaceInstruction( + occurrenceIndex, + "const-string v$targetRegister, \"$newAuthorizationUrl\"", + ) } // endregion @@ -64,15 +69,19 @@ val spoofClientPatch = `Spoof client`( val randomName = (0..100000).random() val userAgent = "$randomName:app.revanced.$randomName:v1.0.0 (by /u/revanced)" - getUserAgentFingerprint.method.returnEarly(userAgent) + getUserAgentMethod.returnEarly(userAgent) // endregion // region Patch Imgur API URL. - imgurImageAPIFingerprint.let { - val apiUrlIndex = it.stringMatches.first().index - it.method.replaceInstruction( + imgurImageAPIMethod.apply { + val apiUrlIndex = indexOfFirstInstructionOrThrow { + opcode == Opcode.CONST_STRING && + getReference()?.string == "https://api.imgur.com/3/image" + } + + replaceInstruction( apiUrlIndex, "const-string v1, \"https://api.imgur.com/3/image\"", ) From 165f4b45e02800e9472d173eccf44bd3fe0fecc6 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 17:05:23 +0700 Subject: [PATCH 42/55] refactor(primevideo): PlaybackSpeedPatch --- .../primevideo/video/speed/Fingerprints.kt | 31 ++++++++++--------- .../video/speed/PlaybackSpeedPatch.kt | 9 +++--- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/primevideo/video/speed/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/primevideo/video/speed/Fingerprints.kt index bd4431d56..933e3dfda 100644 --- a/patches/src/main/kotlin/app/revanced/patches/primevideo/video/speed/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/primevideo/video/speed/Fingerprints.kt @@ -1,23 +1,26 @@ package app.revanced.patches.primevideo.video.speed -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.accessFlags +import app.revanced.patcher.definingClass +import app.revanced.patcher.name +import app.revanced.patcher.parameterTypes +import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags -internal val playbackUserControlsInitializeFingerprint = fingerprint { +internal val BytecodePatchContext.playbackUserControlsInitializeMethod by gettingFirstMutableMethodDeclaratively { accessFlags(AccessFlags.PUBLIC) - parameters("Lcom/amazon/avod/playbackclient/PlaybackInitializationContext;") - returns("V") - custom { method, classDef -> - method.name == "initialize" && classDef.type == "Lcom/amazon/avod/playbackclient/activity/feature/PlaybackUserControlsFeature;" - } + parameterTypes("Lcom/amazon/avod/playbackclient/PlaybackInitializationContext;") + returnType("V") + name("initialize") + definingClass("Lcom/amazon/avod/playbackclient/activity/feature/PlaybackUserControlsFeature;") } -internal val playbackUserControlsPrepareForPlaybackFingerprint = fingerprint { +internal val BytecodePatchContext.playbackUserControlsPrepareForPlaybackMethod by gettingFirstMutableMethodDeclaratively { accessFlags(AccessFlags.PUBLIC) - parameters("Lcom/amazon/avod/playbackclient/PlaybackContext;") - returns("V") - custom { method, classDef -> - method.name == "prepareForPlayback" && - classDef.type == "Lcom/amazon/avod/playbackclient/activity/feature/PlaybackUserControlsFeature;" - } + parameterTypes("Lcom/amazon/avod/playbackclient/PlaybackContext;") + returnType("V") + name("prepareForPlayback") + definingClass("Lcom/amazon/avod/playbackclient/activity/feature/PlaybackUserControlsFeature;") } \ No newline at end of file diff --git a/patches/src/main/kotlin/app/revanced/patches/primevideo/video/speed/PlaybackSpeedPatch.kt b/patches/src/main/kotlin/app/revanced/patches/primevideo/video/speed/PlaybackSpeedPatch.kt index 36829f818..3f3f7476b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/primevideo/video/speed/PlaybackSpeedPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/primevideo/video/speed/PlaybackSpeedPatch.kt @@ -3,6 +3,7 @@ package app.revanced.patches.primevideo.video.speed import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.patches.primevideo.misc.extension.sharedExtensionPatch import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow @@ -13,8 +14,8 @@ import com.android.tools.smali.dexlib2.iface.reference.FieldReference private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/primevideo/videoplayer/PlaybackSpeedPatch;" -val playbackSpeedPatch = bytecodePatch( - name = "Playback speed", +@Suppress("unused", "ObjectPropertyName") +val `Playback speed` by creatingBytecodePatch( description = "Adds playback speed controls to the video player.", ) { dependsOn( @@ -26,7 +27,7 @@ val playbackSpeedPatch = bytecodePatch( ) apply { - playbackUserControlsInitializeFingerprint.method.apply { + playbackUserControlsInitializeMethod.apply { val getIndex = indexOfFirstInstructionOrThrow { opcode == Opcode.IPUT_OBJECT && getReference()?.name == "mUserControls" @@ -42,7 +43,7 @@ val playbackSpeedPatch = bytecodePatch( ) } - playbackUserControlsPrepareForPlaybackFingerprint.method.apply { + playbackUserControlsPrepareForPlaybackMethod.apply { addInstructions( 0, """ From ad783451ed8862c8c0563c572574b8b5a348e402 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 17:06:10 +0700 Subject: [PATCH 43/55] refactor(primevideo): RenamePermissionsPatch --- .../primevideo/misc/permissions/RenamePermissionsPatch.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/primevideo/misc/permissions/RenamePermissionsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/primevideo/misc/permissions/RenamePermissionsPatch.kt index 4894e10a1..b07aea249 100644 --- a/patches/src/main/kotlin/app/revanced/patches/primevideo/misc/permissions/RenamePermissionsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/primevideo/misc/permissions/RenamePermissionsPatch.kt @@ -1,14 +1,14 @@ package app.revanced.patches.primevideo.misc.permissions import app.revanced.patcher.patch.PatchException +import app.revanced.patcher.patch.creatingResourcePatch import app.revanced.patcher.patch.resourcePatch import app.revanced.util.asSequence import app.revanced.util.getNode import org.w3c.dom.Element -@Suppress("unused") -val renamePermissionsPatch = resourcePatch( - name = "Rename shared permissions", +@Suppress("unused", "ObjectPropertyName") +val `Rename shared permissions` by creatingResourcePatch( description = "Rename certain permissions shared across Amazon apps. " + "Applying this patch can fix installation errors, but can also break features in certain apps.", use = false From 198cb93ef275a09891ac59364225198b83524ab3 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 17:10:00 +0700 Subject: [PATCH 44/55] refactor(primevideo): SkipAdsPatch --- .../patches/primevideo/ads/Fingerprints.kt | 50 +++++++++++-------- .../patches/primevideo/ads/SkipAdsPatch.kt | 22 +++++--- 2 files changed, 42 insertions(+), 30 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/primevideo/ads/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/primevideo/ads/Fingerprints.kt index ac3a1c43a..25831a4bb 100644 --- a/patches/src/main/kotlin/app/revanced/patches/primevideo/ads/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/primevideo/ads/Fingerprints.kt @@ -1,33 +1,39 @@ package app.revanced.patches.primevideo.ads -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.accessFlags +import app.revanced.patcher.definingClass +import app.revanced.patcher.instructions +import app.revanced.patcher.invoke +import app.revanced.patcher.name +import app.revanced.patcher.parameterTypes +import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode -internal val enterServerInsertedAdBreakStateFingerprint = fingerprint { +internal val BytecodePatchContext.enterServerInsertedAdBreakStateMethod by gettingFirstMutableMethodDeclaratively { accessFlags(AccessFlags.PUBLIC) - parameters("Lcom/amazon/avod/fsm/Trigger;") - returns("V") - opcodes( - Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT_OBJECT, - Opcode.CONST_4, - Opcode.CONST_4 + parameterTypes("Lcom/amazon/avod/fsm/Trigger;") + returnType("V") + instructions( + Opcode.INVOKE_VIRTUAL(), + Opcode.MOVE_RESULT_OBJECT(), + Opcode.CONST_4(), + Opcode.CONST_4() ) - custom { method, classDef -> - method.name == "enter" && classDef.type == "Lcom/amazon/avod/media/ads/internal/state/ServerInsertedAdBreakState;" - } + name("enter") + definingClass("Lcom/amazon/avod/media/ads/internal/state/ServerInsertedAdBreakState;") } -internal val doTriggerFingerprint = fingerprint { +internal val BytecodePatchContext.doTriggerMethod by gettingFirstMutableMethodDeclaratively { accessFlags(AccessFlags.PROTECTED) - returns("V") - opcodes( - Opcode.IGET_OBJECT, - Opcode.INVOKE_INTERFACE, - Opcode.RETURN_VOID + returnType("V") + instructions( + Opcode.IGET_OBJECT(), + Opcode.INVOKE_INTERFACE(), + Opcode.RETURN_VOID() ) - custom { method, classDef -> - method.name == "doTrigger" && classDef.type == "Lcom/amazon/avod/fsm/StateBase;" - } -} \ No newline at end of file + name("doTrigger") + definingClass("Lcom/amazon/avod/fsm/StateBase;") +} diff --git a/patches/src/main/kotlin/app/revanced/patches/primevideo/ads/SkipAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/primevideo/ads/SkipAdsPatch.kt index d223490b6..0168e7764 100644 --- a/patches/src/main/kotlin/app/revanced/patches/primevideo/ads/SkipAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/primevideo/ads/SkipAdsPatch.kt @@ -2,14 +2,17 @@ package app.revanced.patches.primevideo.ads import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.getInstruction -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.patches.primevideo.misc.extension.sharedExtensionPatch +import app.revanced.util.getReference +import app.revanced.util.indexOfFirstInstructionOrThrow import com.android.tools.smali.dexlib2.AccessFlags +import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction +import com.android.tools.smali.dexlib2.iface.reference.MethodReference -@Suppress("unused") -val skipAdsPatch = bytecodePatch( - name = "Skip ads", +@Suppress("unused", "ObjectPropertyName") +val `Skip ads` by creatingBytecodePatch( description = "Automatically skips video stream ads.", ) { compatibleWith("com.amazon.avod.thirdpartyclient"("3.0.412.2947")) @@ -20,13 +23,17 @@ val skipAdsPatch = bytecodePatch( // ad break. Instead, force the video player to seek over the entire break and reset the state machine. apply { // Force doTrigger() access to public so we can call it from our extension. - doTriggerFingerprint.method.accessFlags = AccessFlags.PUBLIC.value; + doTriggerMethod.accessFlags = AccessFlags.PUBLIC.value - val getPlayerIndex = enterServerInsertedAdBreakStateFingerprint.patternMatch.startIndex - enterServerInsertedAdBreakStateFingerprint.method.apply { + enterServerInsertedAdBreakStateMethod.apply { // Get register that stores VideoPlayer: // invoke-virtual ->getPrimaryPlayer() // move-result-object { playerRegister } + val getPlayerIndex = indexOfFirstInstructionOrThrow { + opcode == Opcode.INVOKE_VIRTUAL && + getReference()?.name == "getPrimaryPlayer" + } + val playerRegister = getInstruction(getPlayerIndex + 1).registerA // Reuse the params from the original method: @@ -42,4 +49,3 @@ val skipAdsPatch = bytecodePatch( } } } - From 530f81b436154e8ed205939decc0166bb50f79fa Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 17:12:08 +0700 Subject: [PATCH 45/55] refactor(photomath): SpoofDeviceIdPatch --- .../detection/deviceid/Fingerprints.kt | 37 +++++++++++-------- .../detection/deviceid/SpoofDeviceIdPatch.kt | 7 ++-- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/photomath/detection/deviceid/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/photomath/detection/deviceid/Fingerprints.kt index 90c0bbb91..08b38930b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/photomath/detection/deviceid/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/photomath/detection/deviceid/Fingerprints.kt @@ -1,21 +1,26 @@ package app.revanced.patches.photomath.detection.deviceid +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.instructions +import app.revanced.patcher.invoke +import app.revanced.patcher.parameterTypes +import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.Opcode -import app.revanced.patcher.fingerprint -internal val getDeviceIdFingerprint = fingerprint { - returns("Ljava/lang/String;") - parameters() - opcodes( - Opcode.SGET_OBJECT, - Opcode.IGET_OBJECT, - Opcode.INVOKE_STATIC, - Opcode.MOVE_RESULT_OBJECT, - Opcode.IF_NEZ, - Opcode.INVOKE_STATIC, - Opcode.MOVE_RESULT_OBJECT, - Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT_OBJECT, - Opcode.INVOKE_VIRTUAL, +internal val BytecodePatchContext.getDeviceIdMethod by gettingFirstMutableMethodDeclaratively { + returnType("Ljava/lang/String;") + parameterTypes() + instructions( + Opcode.SGET_OBJECT(), + Opcode.IGET_OBJECT(), + Opcode.INVOKE_STATIC(), + Opcode.MOVE_RESULT_OBJECT(), + Opcode.IF_NEZ(), + Opcode.INVOKE_STATIC(), + Opcode.MOVE_RESULT_OBJECT(), + Opcode.INVOKE_VIRTUAL(), + Opcode.MOVE_RESULT_OBJECT(), + Opcode.INVOKE_VIRTUAL(), ) -} \ No newline at end of file +} diff --git a/patches/src/main/kotlin/app/revanced/patches/photomath/detection/deviceid/SpoofDeviceIdPatch.kt b/patches/src/main/kotlin/app/revanced/patches/photomath/detection/deviceid/SpoofDeviceIdPatch.kt index 44d4df42c..8e955ed28 100644 --- a/patches/src/main/kotlin/app/revanced/patches/photomath/detection/deviceid/SpoofDeviceIdPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/photomath/detection/deviceid/SpoofDeviceIdPatch.kt @@ -1,13 +1,12 @@ package app.revanced.patches.photomath.detection.deviceid -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.patches.photomath.detection.signature.signatureDetectionPatch import app.revanced.util.returnEarly import kotlin.random.Random @Suppress("unused") -val getDeviceIdPatch = bytecodePatch( - name = "Spoof device ID", +val `Spoof device ID` by creatingBytecodePatch( description = "Spoofs device ID to mitigate manual bans by developers.", ) { dependsOn(signatureDetectionPatch) @@ -15,6 +14,6 @@ val getDeviceIdPatch = bytecodePatch( compatibleWith("com.microblink.photomath") apply { - getDeviceIdFingerprint.method.returnEarly(Random.nextLong().toString(16)) + getDeviceIdMethod.returnEarly(Random.nextLong().toString(16)) } } From 1ee89fe0e6a8353d72bb742c06d9f9571f535784 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 17:16:28 +0700 Subject: [PATCH 46/55] refactor(photomath): SignatureDetectionPatch --- .../detection/signature/Fingerprints.kt | 26 ++++++++++--------- .../signature/SignatureDetectionPatch.kt | 16 +++++++----- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/photomath/detection/signature/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/photomath/detection/signature/Fingerprints.kt index c6563270e..fa7fdaa52 100644 --- a/patches/src/main/kotlin/app/revanced/patches/photomath/detection/signature/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/photomath/detection/signature/Fingerprints.kt @@ -1,18 +1,20 @@ package app.revanced.patches.photomath.detection.signature +import app.revanced.patcher.allOf +import app.revanced.patcher.firstMethodComposite +import app.revanced.patcher.instructions +import app.revanced.patcher.invoke import com.android.tools.smali.dexlib2.Opcode -import app.revanced.patcher.fingerprint -internal val checkSignatureFingerprint = fingerprint { - opcodes( - Opcode.CONST_STRING, - Opcode.INVOKE_STATIC, - Opcode.INVOKE_STATIC, - Opcode.MOVE_RESULT_OBJECT, - Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT_OBJECT, - Opcode.INVOKE_STATIC, - Opcode.MOVE_RESULT, +internal val checkSignatureMethodMatch = firstMethodComposite("SHA") { + instructions( + allOf(Opcode.CONST_STRING(), "SHA"()), + Opcode.INVOKE_STATIC(), + Opcode.INVOKE_STATIC(), + Opcode.MOVE_RESULT_OBJECT(), + Opcode.INVOKE_VIRTUAL(), + Opcode.MOVE_RESULT_OBJECT(), + Opcode.INVOKE_STATIC(), + Opcode.MOVE_RESULT(), ) - strings("SHA") } diff --git a/patches/src/main/kotlin/app/revanced/patches/photomath/detection/signature/SignatureDetectionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/photomath/detection/signature/SignatureDetectionPatch.kt index af1f088c0..ab8045ad2 100644 --- a/patches/src/main/kotlin/app/revanced/patches/photomath/detection/signature/SignatureDetectionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/photomath/detection/signature/SignatureDetectionPatch.kt @@ -2,17 +2,19 @@ package app.revanced.patches.photomath.detection.signature import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.replaceInstruction -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -val signatureDetectionPatch = bytecodePatch( +@Suppress("unused", "ObjectPropertyName") +val `Signature detection` by creatingBytecodePatch( description = "Disables detection of incorrect signature.", ) { - apply { - val replacementIndex = checkSignatureFingerprint.instructionMatches.last().index - val checkRegister = - checkSignatureFingerprint.method.getInstruction(replacementIndex).registerA - checkSignatureFingerprint.method.replaceInstruction(replacementIndex, "const/4 v$checkRegister, 0x1") + val replacementIndex = checkSignatureMethodMatch.indices.last() + + checkSignatureMethodMatch.method.apply { + val checkRegister = getInstruction(replacementIndex).registerA + replaceInstruction(replacementIndex, "const/4 v$checkRegister, 0x1") + } } } From 70328c5a655cce9dbfe8ca17d932742ecb067489 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 17:17:11 +0700 Subject: [PATCH 47/55] fix(photomath/Spoof Device Id): Switch import naming --- .../photomath/detection/deviceid/SpoofDeviceIdPatch.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/photomath/detection/deviceid/SpoofDeviceIdPatch.kt b/patches/src/main/kotlin/app/revanced/patches/photomath/detection/deviceid/SpoofDeviceIdPatch.kt index 8e955ed28..303517a70 100644 --- a/patches/src/main/kotlin/app/revanced/patches/photomath/detection/deviceid/SpoofDeviceIdPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/photomath/detection/deviceid/SpoofDeviceIdPatch.kt @@ -1,7 +1,7 @@ package app.revanced.patches.photomath.detection.deviceid import app.revanced.patcher.patch.creatingBytecodePatch -import app.revanced.patches.photomath.detection.signature.signatureDetectionPatch +import app.revanced.patches.photomath.detection.signature.`Signature detection` import app.revanced.util.returnEarly import kotlin.random.Random @@ -9,7 +9,7 @@ import kotlin.random.Random val `Spoof device ID` by creatingBytecodePatch( description = "Spoofs device ID to mitigate manual bans by developers.", ) { - dependsOn(signatureDetectionPatch) + dependsOn(`Signature detection`) compatibleWith("com.microblink.photomath") From be005c533af4dbdebd1b1e742a54d4bd3396c22d Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 17:22:27 +0700 Subject: [PATCH 48/55] refactor(photomath): HideUpdatePopupPatch --- .../photomath/misc/annoyances/Fingerprints.kt | 28 +++++++++++-------- .../misc/annoyances/HideUpdatePopupPatch.kt | 12 ++++---- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/annoyances/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/annoyances/Fingerprints.kt index 301f2f9a5..ce9deca51 100644 --- a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/annoyances/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/annoyances/Fingerprints.kt @@ -1,21 +1,25 @@ package app.revanced.patches.photomath.misc.annoyances +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.accessFlags +import app.revanced.patcher.definingClass import app.revanced.patcher.fingerprint +import app.revanced.patcher.instructions +import app.revanced.patcher.invoke +import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode -internal val hideUpdatePopupFingerprint = fingerprint { +internal val BytecodePatchContext.hideUpdatePopupMethod by gettingFirstMutableMethodDeclaratively { accessFlags(AccessFlags.FINAL, AccessFlags.PUBLIC) - returns("V") - opcodes( - Opcode.CONST_HIGH16, - Opcode.INVOKE_VIRTUAL, // ViewPropertyAnimator.alpha(1.0f) - Opcode.MOVE_RESULT_OBJECT, - Opcode.CONST_WIDE_16, - Opcode.INVOKE_VIRTUAL, // ViewPropertyAnimator.setDuration(1000L) + returnType("V") + definingClass("Lcom/microblink/photomath/main/activity/MainActivity;") + instructions( + Opcode.CONST_HIGH16(), + Opcode.INVOKE_VIRTUAL(), // ViewPropertyAnimator.alpha(1.0f) + Opcode.MOVE_RESULT_OBJECT(), + Opcode.CONST_WIDE_16(), + Opcode.INVOKE_VIRTUAL(), // ViewPropertyAnimator.setDuration(1000L) ) - custom { method, _ -> - // The popup is shown only in the main activity - method.definingClass == "Lcom/microblink/photomath/main/activity/MainActivity;" - } } diff --git a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/annoyances/HideUpdatePopupPatch.kt b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/annoyances/HideUpdatePopupPatch.kt index 6a9c66b07..88678aa3c 100644 --- a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/annoyances/HideUpdatePopupPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/annoyances/HideUpdatePopupPatch.kt @@ -1,20 +1,20 @@ package app.revanced.patches.photomath.misc.annoyances import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.patch.bytecodePatch -import app.revanced.patches.photomath.detection.signature.signatureDetectionPatch +import app.revanced.patcher.patch.creatingBytecodePatch +import app.revanced.patches.photomath.detection.signature.`Signature detection` + @Suppress("unused") -val hideUpdatePopupPatch = bytecodePatch( - name = "Hide update popup", +val `Hide update popup` by creatingBytecodePatch( description = "Prevents the update popup from showing up.", ) { - dependsOn(signatureDetectionPatch) + dependsOn(`Signature detection`) compatibleWith("com.microblink.photomath") apply { - hideUpdatePopupFingerprint.method.addInstructions( + hideUpdatePopupMethod.addInstructions( 2, // Insert after the null check. "return-void", ) From f4a04e7917d6e9cd33ab52d8bc4064f164529cb9 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 17:25:01 +0700 Subject: [PATCH 49/55] refactor(photomath): EnableBookpointPatch --- .../unlock/bookpoint/EnableBookpointPatch.kt | 7 ++--- .../misc/unlock/bookpoint/Fingerprints.kt | 26 ++++++++++++------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/bookpoint/EnableBookpointPatch.kt b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/bookpoint/EnableBookpointPatch.kt index 7617395e1..72091c63c 100644 --- a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/bookpoint/EnableBookpointPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/bookpoint/EnableBookpointPatch.kt @@ -1,14 +1,15 @@ package app.revanced.patches.photomath.misc.unlock.bookpoint import app.revanced.patcher.extensions.replaceInstructions -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch -val enableBookpointPatch = bytecodePatch( +@Suppress("unused") +val `Enable bookpoint` by creatingBytecodePatch( description = "Enables textbook access", ) { apply { - isBookpointEnabledFingerprint.method.replaceInstructions( + isBookpointEnabledMethod.replaceInstructions( 0, """ const/4 v0, 0x1 diff --git a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/bookpoint/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/bookpoint/Fingerprints.kt index 6722f4223..3b316d054 100644 --- a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/bookpoint/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/bookpoint/Fingerprints.kt @@ -1,16 +1,22 @@ package app.revanced.patches.photomath.misc.unlock.bookpoint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.accessFlags +import app.revanced.patcher.instructions +import app.revanced.patcher.invoke +import app.revanced.patcher.parameterTypes +import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags -import app.revanced.patcher.fingerprint -internal val isBookpointEnabledFingerprint = fingerprint { +internal val BytecodePatchContext.isBookpointEnabledMethod by gettingFirstMutableMethodDeclaratively { accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) - returns("Z") - parameters() - strings( - "NoGeoData", - "NoCountryInGeo", - "RemoteConfig", - "GeoRCMismatch" + returnType("Z") + parameterTypes() + instructions( + "NoGeoData"(), + "NoCountryInGeo"(), + "RemoteConfig"(), + "GeoRCMismatch"() ) -} \ No newline at end of file +} From bce0a745db12ba233e4c070e8581e0b30bb039fb Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 17:26:27 +0700 Subject: [PATCH 50/55] refactor(photomath): UnlockPlusPatch --- .../misc/unlock/plus/Fingerprints.kt | 19 +++++++++++-------- .../misc/unlock/plus/UnlockPlusPatch.kt | 14 ++++++-------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/Fingerprints.kt index a9e9e8044..9ffd32b90 100644 --- a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/Fingerprints.kt @@ -1,13 +1,16 @@ package app.revanced.patches.photomath.misc.unlock.plus +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.accessFlags +import app.revanced.patcher.definingClass +import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType +import app.revanced.patcher.string import com.android.tools.smali.dexlib2.AccessFlags -import app.revanced.patcher.fingerprint -internal val isPlusUnlockedFingerprint = fingerprint { +internal val BytecodePatchContext.isPlusUnlockedMethod by gettingFirstMutableMethodDeclaratively { accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) - returns("Z") - strings("genius") - custom { _, classDef -> - classDef.endsWith("/User;") - } -} \ No newline at end of file + returnType("Z") + string("genius") + definingClass("/User;"::endsWith) +} diff --git a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/UnlockPlusPatch.kt b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/UnlockPlusPatch.kt index 132a1eacb..3f0f8b159 100644 --- a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/UnlockPlusPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/UnlockPlusPatch.kt @@ -1,20 +1,18 @@ package app.revanced.patches.photomath.misc.unlock.plus import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.patch.bytecodePatch -import app.revanced.patches.photomath.detection.signature.signatureDetectionPatch -import app.revanced.patches.photomath.misc.unlock.bookpoint.enableBookpointPatch +import app.revanced.patcher.patch.creatingBytecodePatch +import app.revanced.patches.photomath.detection.signature.`Signature detection` +import app.revanced.patches.photomath.misc.unlock.bookpoint.`Enable bookpoint` @Suppress("unused") -val unlockPlusPatch = bytecodePatch( - name = "Unlock plus", -) { - dependsOn(signatureDetectionPatch, enableBookpointPatch) +val `Unlock plus` by creatingBytecodePatch { + dependsOn(`Signature detection`, `Enable bookpoint`) compatibleWith("com.microblink.photomath") apply { - isPlusUnlockedFingerprint.method.addInstructions( + isPlusUnlockedMethod.addInstructions( 0, """ const/4 v0, 0x1 From 811a7855f15caa59861b6da02a17009c45b48b2c Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 17:28:40 +0700 Subject: [PATCH 51/55] fix(reddit/syncforlemmy): Switch import naming --- .../customclients/sync/syncforlemmy/ads/DisableAdsPatch.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforlemmy/ads/DisableAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforlemmy/ads/DisableAdsPatch.kt index ca74997aa..ee1197a13 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforlemmy/ads/DisableAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforlemmy/ads/DisableAdsPatch.kt @@ -1,11 +1,11 @@ package app.revanced.patches.reddit.customclients.sync.syncforlemmy.ads import app.revanced.patches.reddit.customclients.sync.ads.disableAdsPatch -import app.revanced.patches.reddit.customclients.sync.detection.piracy.disablePiracyDetectionPatch +import app.revanced.patches.reddit.customclients.sync.detection.piracy.`Disable piracy detection` @Suppress("unused") val disableAdsPatch = disableAdsPatch { - dependsOn(disablePiracyDetectionPatch) + dependsOn(`Disable piracy detection`) compatibleWith("com.laurencedawson.reddit_sync") } From 8c0c3b44e5cfb9a52e186eaad21a2f7598188539 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 17:28:44 +0700 Subject: [PATCH 52/55] fix(reddit/joeyforreddit): Switch import naming --- .../customclients/joeyforreddit/api/SpoofClientPatch.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt index d14b8ca59..c52a7c3d5 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt @@ -3,11 +3,11 @@ package app.revanced.patches.reddit.customclients.joeyforreddit.api import app.revanced.patches.reddit.customclients.infinity.api.authUtilityUserAgentMethod import app.revanced.patches.reddit.customclients.infinity.api.getClientIdMethod import app.revanced.patches.reddit.customclients.`Spoof client` -import app.revanced.patches.reddit.customclients.sync.detection.piracy.disablePiracyDetectionPatch +import app.revanced.patches.reddit.customclients.sync.detection.piracy.`Disable piracy detection` import app.revanced.util.returnEarly val spoofClientPatch = `Spoof client`(redirectUri = "https://127.0.0.1:65023/authorize_callback") { clientIdOption -> - dependsOn(disablePiracyDetectionPatch) + dependsOn(`Disable piracy detection`) compatibleWith( "o.o.joey", From 50f95543f1deb33059d87598b4aa6c836f3d6321 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Wed, 14 Jan 2026 02:23:45 +0100 Subject: [PATCH 53/55] fix --- .../detection/root/RootDetectionPatch.kt | 6 +- .../hide/navigation/HideNavigationButtons.kt | 3 +- .../domain/ChangeLinkSharingDomainPatch.kt | 6 +- .../privacy/SanitizeSharingLinksPatch.kt | 6 +- .../misc/signature/SignatureCheckPatch.kt | 2 +- .../music/misc/settings/Fingerprints.kt | 4 +- .../music/misc/settings/SettingsPatch.kt | 4 +- .../music/playservice/VersionCheckPatch.kt | 6 +- .../patches/myfitnesspal/ads/Fingerprints.kt | 8 +-- .../revanced/patches/nunl/ads/Fingerprints.kt | 19 ++---- .../revanced/patches/nunl/ads/HideAdsPatch.kt | 16 ++--- .../patches/nunl/firebase/Fingerprints.kt | 24 +++---- .../nunl/firebase/SpoofCertificatePatch.kt | 4 +- .../orfon/detection/root/Fingerprints.kt | 2 +- .../root/RemoveRootDetectionPatch.kt | 3 +- .../pandora/misc/EnableUnlimitedSkipsPatch.kt | 6 +- .../patches/pandora/misc/Fingerprints.kt | 2 +- .../patches/peacocktv/ads/HideAdsPatch.kt | 2 +- .../detection/signature/Fingerprints.kt | 3 +- .../signature/SignatureDetectionPatch.kt | 7 +- .../photomath/misc/annoyances/Fingerprints.kt | 9 +-- .../unlock/bookpoint/EnableBookpointPatch.kt | 4 +- .../misc/unlock/bookpoint/Fingerprints.kt | 15 ++--- .../misc/unlock/plus/Fingerprints.kt | 4 +- .../misc/unlock/plus/UnlockPlusPatch.kt | 4 +- .../tracking/DisableTrackingPatch.kt | 41 ++++++------ .../piccomafr/tracking/Fingerprints.kt | 2 +- .../patches/pixiv/ads/Fingerprints.kt | 4 +- .../patches/primevideo/ads/Fingerprints.kt | 16 ++--- .../primevideo/video/speed/Fingerprints.kt | 14 ++-- .../purchasereminder/Fingerprints.kt | 4 +- .../reddit/ad/banner/HideBannerPatch.kt | 35 ---------- .../patches/reddit/ad/general/Fingerprints.kt | 11 ++- .../patches/reddit/ad/general/HideAdsPatch.kt | 56 +++++++--------- .../customclients/FixRedgifsApiPatch.kt | 6 +- .../reddit/customclients/FixSLinksPatch.kt | 8 ++- .../reddit/customclients/SpoofClientPatch.kt | 7 +- .../baconreader/api/Fingerprints.kt | 26 +++---- .../baconreader/api/SpoofClientPatch.kt | 24 +++---- .../baconreader/fix/redgifs/Fingerprints.kt | 4 +- .../fix/redgifs/FixRedgifsApiPatch.kt | 41 ++++++------ .../boostforreddit/ads/DisableAdsPatch.kt | 7 +- .../boostforreddit/api/Fingerprints.kt | 2 +- .../boostforreddit/api/SpoofClientPatch.kt | 16 ++--- .../fix/downloads/Fingerprints.kt | 15 +++-- .../FixAudioMissingInDownloadsPatch.kt | 25 +++---- .../fix/redgifs/Fingerprints.kt | 12 +--- .../fix/redgifs/FixRedgifsApiPatch.kt | 23 +++---- .../boostforreddit/fix/slink/Fingerprints.kt | 2 +- .../fix/slink/FixSLinksPatch.kt | 27 ++++---- .../infinityforreddit/api/Fingerprints.kt | 7 +- .../infinityforreddit/api/SpoofClientPatch.kt | 6 +- .../subscription/Fingerprints.kt | 9 ++- .../subscription/UnlockSubscriptionPatch.kt | 6 +- .../joeyforreddit/ads/DisableAdsPatch.kt | 10 +-- .../joeyforreddit/ads/Fingerprints.kt | 4 +- .../joeyforreddit/api/Fingerprints.kt | 13 ++-- .../joeyforreddit/api/SpoofClientPatch.kt | 10 ++- .../detection/piracy/Fingerprints.kt | 6 +- .../redditisfun/api/Fingerprints.kt | 26 +++---- .../redditisfun/api/SpoofClientPatch.kt | 43 +++++------- .../relayforreddit/api/Fingerprints.kt | 25 +++---- .../relayforreddit/api/SpoofClientPatch.kt | 33 ++++----- .../customclients/slide/api/Fingerprints.kt | 2 +- .../slide/api/SpoofClientPatch.kt | 4 +- .../piracy/DisablePiracyDetectionPatch.kt | 4 +- .../sync/detection/piracy/Fingerprints.kt | 15 +++-- .../sync/syncforlemmy/ads/DisableAdsPatch.kt | 4 +- .../annoyances/startup/Fingerprints.kt | 2 +- .../sync/syncforreddit/api/Fingerprints.kt | 22 ++++-- .../syncforreddit/api/SpoofClientPatch.kt | 67 ++++++++----------- .../fix/redgifs/FixRedgifsApiPatch.kt | 4 +- .../tracking/url/SanitizeUrlQueryPatch.kt | 6 +- .../detection/root/RootDetectionPatch.kt | 6 +- .../patches/shared/SharedPatchNames.kt | 16 ----- .../misc/privacy/SanitizeSharingLinksPatch.kt | 6 +- .../misc/privacy/SanitizeSharingLinksPatch.kt | 6 +- .../misc/share/SanitizeShareUrlsPatch.kt | 7 +- .../links/ChangeLinkSharingDomainPatch.kt | 6 +- .../misc/links/SanitizeSharingLinksPatch.kt | 6 +- .../misc/navbar/HideNavigationButtons.kt | 3 +- 81 files changed, 393 insertions(+), 588 deletions(-) delete mode 100644 patches/src/main/kotlin/app/revanced/patches/reddit/ad/banner/HideBannerPatch.kt delete mode 100644 patches/src/main/kotlin/app/revanced/patches/shared/SharedPatchNames.kt diff --git a/patches/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/RootDetectionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/RootDetectionPatch.kt index d5529e9a7..49bacecbd 100644 --- a/patches/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/RootDetectionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/RootDetectionPatch.kt @@ -2,13 +2,11 @@ package app.revanced.patches.finanzonline.detection.root import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.patch.bytecodePatch -import app.revanced.patches.shared.PATCH_DESCRIPTION_REMOVE_ROOT_DETECTION -import app.revanced.patches.shared.PATCH_NAME_REMOVE_ROOT_DETECTION @Suppress("unused") val rootDetectionPatch = bytecodePatch( - name = PATCH_NAME_REMOVE_ROOT_DETECTION, - description = PATCH_DESCRIPTION_REMOVE_ROOT_DETECTION, + name = "Remove root detection", + description = "Removes the check for root permissions and unlocked bootloader.", ) { compatibleWith("at.gv.bmf.bmf2go") diff --git a/patches/src/main/kotlin/app/revanced/patches/instagram/hide/navigation/HideNavigationButtons.kt b/patches/src/main/kotlin/app/revanced/patches/instagram/hide/navigation/HideNavigationButtons.kt index 2d4fe480a..7b7b54821 100644 --- a/patches/src/main/kotlin/app/revanced/patches/instagram/hide/navigation/HideNavigationButtons.kt +++ b/patches/src/main/kotlin/app/revanced/patches/instagram/hide/navigation/HideNavigationButtons.kt @@ -5,7 +5,6 @@ import app.revanced.patcher.fingerprint import app.revanced.patcher.patch.booleanOption import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.instagram.misc.extension.sharedExtensionPatch -import app.revanced.patches.shared.PATCH_NAME_HIDE_NAVIGATION_BUTTONS import app.revanced.util.addInstructionsAtControlFlowLabel import app.revanced.util.findFreeRegister import app.revanced.util.getReference @@ -21,7 +20,7 @@ private const val EXTENSION_CLASS_DESCRIPTOR = @Suppress("unused") val hideNavigationButtonsPatch = bytecodePatch( - name = PATCH_NAME_HIDE_NAVIGATION_BUTTONS, + name = "Hide navigation buttons", description = "Hides navigation bar buttons, such as the Reels and Create button.", use = false ) { diff --git a/patches/src/main/kotlin/app/revanced/patches/instagram/misc/share/domain/ChangeLinkSharingDomainPatch.kt b/patches/src/main/kotlin/app/revanced/patches/instagram/misc/share/domain/ChangeLinkSharingDomainPatch.kt index 128d3457a..090632bb8 100644 --- a/patches/src/main/kotlin/app/revanced/patches/instagram/misc/share/domain/ChangeLinkSharingDomainPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/instagram/misc/share/domain/ChangeLinkSharingDomainPatch.kt @@ -5,8 +5,6 @@ import app.revanced.patcher.patch.bytecodePatch import app.revanced.patcher.patch.stringOption import app.revanced.patches.instagram.misc.extension.sharedExtensionPatch import app.revanced.patches.instagram.misc.share.editShareLinksPatch -import app.revanced.patches.shared.PATCH_DESCRIPTION_CHANGE_LINK_SHARING_DOMAIN -import app.revanced.patches.shared.PATCH_NAME_CHANGE_LINK_SHARING_DOMAIN import app.revanced.util.returnEarly internal const val EXTENSION_CLASS_DESCRIPTOR = @@ -14,8 +12,8 @@ internal const val EXTENSION_CLASS_DESCRIPTOR = @Suppress("unused") val changeLinkSharingDomainPatch = bytecodePatch( - name = PATCH_NAME_CHANGE_LINK_SHARING_DOMAIN, - description = PATCH_DESCRIPTION_CHANGE_LINK_SHARING_DOMAIN, + name = "Change link sharing domain", + description = "Replaces the domain name of shared links.", use = false ) { compatibleWith("com.instagram.android") diff --git a/patches/src/main/kotlin/app/revanced/patches/instagram/misc/share/privacy/SanitizeSharingLinksPatch.kt b/patches/src/main/kotlin/app/revanced/patches/instagram/misc/share/privacy/SanitizeSharingLinksPatch.kt index 0b2956c15..9e9095c73 100644 --- a/patches/src/main/kotlin/app/revanced/patches/instagram/misc/share/privacy/SanitizeSharingLinksPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/instagram/misc/share/privacy/SanitizeSharingLinksPatch.kt @@ -4,16 +4,14 @@ import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.instagram.misc.extension.sharedExtensionPatch import app.revanced.patches.instagram.misc.share.editShareLinksPatch -import app.revanced.patches.shared.PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS -import app.revanced.patches.shared.PATCH_NAME_SANITIZE_SHARING_LINKS private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/instagram/misc/share/privacy/SanitizeSharingLinksPatch;" @Suppress("unused") val sanitizeSharingLinksPatch = bytecodePatch( - name = PATCH_NAME_SANITIZE_SHARING_LINKS, - description = PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS, + name = "Sanitize sharing links", + description = "Removes the tracking query parameters from shared links.", ) { compatibleWith("com.instagram.android") diff --git a/patches/src/main/kotlin/app/revanced/patches/instagram/misc/signature/SignatureCheckPatch.kt b/patches/src/main/kotlin/app/revanced/patches/instagram/misc/signature/SignatureCheckPatch.kt index bb805d053..b4f1e3fd5 100644 --- a/patches/src/main/kotlin/app/revanced/patches/instagram/misc/signature/SignatureCheckPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/instagram/misc/signature/SignatureCheckPatch.kt @@ -7,7 +7,7 @@ import app.revanced.util.returnEarly val signatureCheckPatch = bytecodePatch( name = "Disable signature check", description = "Disables the signature check that can cause the app to crash on startup. " + - "Including this patch may cause issues with sharing or opening external Instagram links.", + "Using this patch may cause issues with sharing or opening external Instagram links.", use = false ) { compatibleWith("com.instagram.android") diff --git a/patches/src/main/kotlin/app/revanced/patches/music/misc/settings/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/music/misc/settings/Fingerprints.kt index 332b6e4b7..2a10967fc 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/misc/settings/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/misc/settings/Fingerprints.kt @@ -8,8 +8,8 @@ import app.revanced.patcher.patch.BytecodePatchContext import app.revanced.patcher.returnType internal val BytecodePatchContext.googleApiActivityMethod by gettingFirstMutableMethodDeclaratively { + name("onCreate") + definingClass("GoogleApiActivity;"::endsWith) returnType("V") parameterTypes("Landroid/os/Bundle;") - definingClass("GoogleApiActivity;"::endsWith) - name("onCreate") } diff --git a/patches/src/main/kotlin/app/revanced/patches/music/misc/settings/SettingsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/music/misc/settings/SettingsPatch.kt index c7315f5cf..497e10011 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/misc/settings/SettingsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/misc/settings/SettingsPatch.kt @@ -1,7 +1,7 @@ package app.revanced.patches.music.misc.settings import app.revanced.patcher.classDef -import app.revanced.patcher.patch.creatingBytecodePatch +import app.revanced.patcher.patch.bytecodePatch import app.revanced.patcher.patch.resourcePatch import app.revanced.patches.all.misc.packagename.setOrGetFallbackPackageName import app.revanced.patches.all.misc.resources.addResources @@ -65,7 +65,7 @@ private val settingsResourcePatch = resourcePatch { } } -val Settings by creatingBytecodePatch( +val settingsPatch = bytecodePatch( description = "Adds settings for ReVanced to YouTube Music." ) { dependsOn( diff --git a/patches/src/main/kotlin/app/revanced/patches/music/playservice/VersionCheckPatch.kt b/patches/src/main/kotlin/app/revanced/patches/music/playservice/VersionCheckPatch.kt index a4339a3df..134121b67 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/playservice/VersionCheckPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/playservice/VersionCheckPatch.kt @@ -2,7 +2,7 @@ package app.revanced.patches.music.playservice -import app.revanced.patcher.patch.creatingResourcePatch +import app.revanced.patcher.patch.resourcePatch import app.revanced.util.findPlayStoreServicesVersion import kotlin.properties.Delegates @@ -21,8 +21,8 @@ var is_8_11_or_greater: Boolean by Delegates.notNull() var is_8_15_or_greater: Boolean by Delegates.notNull() private set -@Suppress("unused", "ObjectPropertyName") -val `Version check` by creatingResourcePatch( +@Suppress("unused") +val versionCheckPatch = resourcePatch( description = "Uses the Play Store service version to find the major/minor version of the YouTube Music target app." ) { apply { diff --git a/patches/src/main/kotlin/app/revanced/patches/myfitnesspal/ads/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/myfitnesspal/ads/Fingerprints.kt index 92a1e2ad5..13b47269e 100644 --- a/patches/src/main/kotlin/app/revanced/patches/myfitnesspal/ads/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/myfitnesspal/ads/Fingerprints.kt @@ -9,14 +9,14 @@ import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags internal val BytecodePatchContext.isPremiumUseCaseImplMethod by gettingFirstMutableMethodDeclaratively { - accessFlags(AccessFlags.PUBLIC) - definingClass("IsPremiumUseCaseImpl;") name("doWork") + definingClass("IsPremiumUseCaseImpl;"::endsWith) + accessFlags(AccessFlags.PUBLIC) } internal val BytecodePatchContext.mainActivityNavigateToNativePremiumUpsellMethod by gettingFirstMutableMethodDeclaratively { + name("navigateToNativePremiumUpsell") + definingClass("MainActivity;"::endsWith) accessFlags(AccessFlags.PRIVATE, AccessFlags.FINAL) returnType("V") - definingClass("MainActivity;") - name("navigateToNativePremiumUpsell") } diff --git a/patches/src/main/kotlin/app/revanced/patches/nunl/ads/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/nunl/ads/Fingerprints.kt index b6bc5fc33..48f87cad8 100644 --- a/patches/src/main/kotlin/app/revanced/patches/nunl/ads/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/nunl/ads/Fingerprints.kt @@ -1,32 +1,23 @@ package app.revanced.patches.nunl.ads +import app.revanced.patcher.* import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively -import app.revanced.patcher.accessFlags -import app.revanced.patcher.definingClass -import app.revanced.patcher.firstMethodComposite -import app.revanced.patcher.instructions -import app.revanced.patcher.invoke -import app.revanced.patcher.name -import app.revanced.patcher.parameterTypes import app.revanced.patcher.patch.BytecodePatchContext -import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode internal val BytecodePatchContext.jwPlayerConfigMethod by gettingFirstMutableMethodDeclaratively { - accessFlags(AccessFlags.PUBLIC) - definingClass($$"Lcom/jwplayer/pub/api/configuration/PlayerConfig$Builder;") name("advertisingConfig") + definingClass($$"Lcom/jwplayer/pub/api/configuration/PlayerConfig$Builder;") + accessFlags(AccessFlags.PUBLIC) } internal val screenMapperMethodMatch = firstMethodComposite { + name("map") + definingClass("Lnl/nu/android/bff/data/mappers/ScreenMapper;") accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) returnType("Lnl/nu/android/bff/domain/models/screen/ScreenEntity;") parameterTypes("Lnl/nu/performance/api/client/objects/Screen;") - - definingClass("Lnl/nu/android/bff/data/mappers/ScreenMapper;") - name("map") - instructions( Opcode.MOVE_RESULT_OBJECT(), Opcode.IF_EQZ(), diff --git a/patches/src/main/kotlin/app/revanced/patches/nunl/ads/HideAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/nunl/ads/HideAdsPatch.kt index 8efae4fc5..046d3c115 100644 --- a/patches/src/main/kotlin/app/revanced/patches/nunl/ads/HideAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/nunl/ads/HideAdsPatch.kt @@ -27,19 +27,17 @@ val `Hide ads` by creatingBytecodePatch( arrayOf(screenMapperMethodMatch, nextPageRepositoryImplMethodMatch).forEach { match -> // Index of instruction moving result of BlockPage;->getBlocks(...). val moveGetBlocksResultObjectIndex = match.indices.first() - match.method.apply { - val moveInstruction = getInstruction(moveGetBlocksResultObjectIndex) + val moveInstruction = match.method.getInstruction(moveGetBlocksResultObjectIndex) - val listRegister = moveInstruction.registerA + val listRegister = moveInstruction.registerA - // Add instruction after moving List to register and then filter this List in place. - addInstructions( - moveGetBlocksResultObjectIndex + 1, - """ + // Add instruction after moving List to register and then filter this List in place. + match.method.addInstructions( + moveGetBlocksResultObjectIndex + 1, + """ invoke-static { v$listRegister }, Lapp/revanced/extension/nunl/ads/HideAdsPatch;->filterAds(Ljava/util/List;)V """, - ) - } + ) } } } diff --git a/patches/src/main/kotlin/app/revanced/patches/nunl/firebase/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/nunl/firebase/Fingerprints.kt index 287172ff9..7e1f0ac12 100644 --- a/patches/src/main/kotlin/app/revanced/patches/nunl/firebase/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/nunl/firebase/Fingerprints.kt @@ -1,24 +1,20 @@ package app.revanced.patches.nunl.firebase +import app.revanced.patcher.* import app.revanced.patcher.BytecodePatchContextMethodMatching.firstMutableMethodDeclaratively -import app.revanced.patcher.accessFlags -import app.revanced.patcher.definingClass -import app.revanced.patcher.name -import app.revanced.patcher.parameterTypes import app.revanced.patcher.patch.BytecodePatchContext -import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags -internal val firebaseClasses = arrayOf( +internal fun BytecodePatchContext.getFingerprintHashForPackageMethods() = arrayOf( "Lcom/google/firebase/installations/remote/FirebaseInstallationServiceClient;", "Lcom/google/firebase/remoteconfig/internal/ConfigFetchHttpClient;", "Lcom/google/firebase/remoteconfig/internal/ConfigRealtimeHttpClient;" -) - -internal fun BytecodePatchContext.getFingerprintHashForPackageMethod(className: String) = firstMutableMethodDeclaratively { - accessFlags(AccessFlags.PRIVATE) - definingClass(className) - name("getFingerprintHashForPackage") - returnType("Ljava/lang/String;") - parameterTypes() +).map { + firstMutableMethodDeclaratively { + name("getFingerprintHashForPackage") + definingClass(it) + accessFlags(AccessFlags.PRIVATE) + returnType("Ljava/lang/String;") + parameterTypes() + } } diff --git a/patches/src/main/kotlin/app/revanced/patches/nunl/firebase/SpoofCertificatePatch.kt b/patches/src/main/kotlin/app/revanced/patches/nunl/firebase/SpoofCertificatePatch.kt index 1b0118999..bb29a3d6a 100644 --- a/patches/src/main/kotlin/app/revanced/patches/nunl/firebase/SpoofCertificatePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/nunl/firebase/SpoofCertificatePatch.kt @@ -10,8 +10,8 @@ val `Spoof certificate` by creatingBytecodePatch( compatibleWith("nl.sanomamedia.android.nu") apply { - firebaseClasses.forEach { className -> - getFingerprintHashForPackageMethod(className).returnEarly("eae41fc018df2731a9b6ae1ac327da44a288667b") + getFingerprintHashForPackageMethods().forEach { + it.returnEarly("eae41fc018df2731a9b6ae1ac327da44a288667b") } } } diff --git a/patches/src/main/kotlin/app/revanced/patches/orfon/detection/root/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/orfon/detection/root/Fingerprints.kt index 9f4570309..116751f63 100644 --- a/patches/src/main/kotlin/app/revanced/patches/orfon/detection/root/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/orfon/detection/root/Fingerprints.kt @@ -9,8 +9,8 @@ import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags internal val BytecodePatchContext.isDeviceRootedMethod by gettingFirstMutableMethodDeclaratively { - accessFlags(AccessFlags.PUBLIC) name("isDeviceRooted") definingClass("/RootChecker;"::endsWith) + accessFlags(AccessFlags.PUBLIC) returnType("Z") } diff --git a/patches/src/main/kotlin/app/revanced/patches/orfon/detection/root/RemoveRootDetectionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/orfon/detection/root/RemoveRootDetectionPatch.kt index e0a6198d8..9d36c81d5 100644 --- a/patches/src/main/kotlin/app/revanced/patches/orfon/detection/root/RemoveRootDetectionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/orfon/detection/root/RemoveRootDetectionPatch.kt @@ -1,12 +1,11 @@ package app.revanced.patches.orfon.detection.root import app.revanced.patcher.patch.creatingBytecodePatch -import app.revanced.patches.shared.PATCH_DESCRIPTION_REMOVE_ROOT_DETECTION import app.revanced.util.returnEarly @Suppress("unused", "ObjectPropertyName") val `Remove root detection` by creatingBytecodePatch( - description = PATCH_DESCRIPTION_REMOVE_ROOT_DETECTION + description = "Removes the check for root permissions and unlocked bootloader." ) { compatibleWith("com.nousguide.android.orftvthek") diff --git a/patches/src/main/kotlin/app/revanced/patches/pandora/misc/EnableUnlimitedSkipsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/pandora/misc/EnableUnlimitedSkipsPatch.kt index 98b19c527..395dd2d8a 100644 --- a/patches/src/main/kotlin/app/revanced/patches/pandora/misc/EnableUnlimitedSkipsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/pandora/misc/EnableUnlimitedSkipsPatch.kt @@ -4,12 +4,10 @@ import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.util.returnEarly @Suppress("unused", "ObjectPropertyName") -val `Enable Unlimited Skips` by creatingBytecodePatch( - description = "Enable unlimited skips" -) { +val `Enable Unlimited Skips` by creatingBytecodePatch { compatibleWith("com.pandora.android") apply { - skipLimitBehaviorMethod.returnEarly("unlimited") + getSkipLimitBehaviorMethod.returnEarly("unlimited") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/pandora/misc/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/pandora/misc/Fingerprints.kt index 06551370d..e9bbaa933 100644 --- a/patches/src/main/kotlin/app/revanced/patches/pandora/misc/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/pandora/misc/Fingerprints.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.definingClass import app.revanced.patcher.name import app.revanced.patcher.patch.BytecodePatchContext -internal val BytecodePatchContext.skipLimitBehaviorMethod by gettingFirstMutableMethodDeclaratively { +internal val BytecodePatchContext.getSkipLimitBehaviorMethod by gettingFirstMutableMethodDeclaratively { name("getSkipLimitBehavior") definingClass("UserData;"::endsWith) } diff --git a/patches/src/main/kotlin/app/revanced/patches/peacocktv/ads/HideAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/peacocktv/ads/HideAdsPatch.kt index df499e2c4..fb057bad7 100644 --- a/patches/src/main/kotlin/app/revanced/patches/peacocktv/ads/HideAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/peacocktv/ads/HideAdsPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.util.returnEarly @Suppress("unused", "ObjectPropertyName") -val `Hide Ads` by creatingBytecodePatch( +val `Hide ads` by creatingBytecodePatch( description = "Hides all video ads." ) { compatibleWith("com.peacocktv.peacockandroid") diff --git a/patches/src/main/kotlin/app/revanced/patches/photomath/detection/signature/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/photomath/detection/signature/Fingerprints.kt index fa7fdaa52..23074c935 100644 --- a/patches/src/main/kotlin/app/revanced/patches/photomath/detection/signature/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/photomath/detection/signature/Fingerprints.kt @@ -1,6 +1,5 @@ package app.revanced.patches.photomath.detection.signature -import app.revanced.patcher.allOf import app.revanced.patcher.firstMethodComposite import app.revanced.patcher.instructions import app.revanced.patcher.invoke @@ -8,7 +7,7 @@ import com.android.tools.smali.dexlib2.Opcode internal val checkSignatureMethodMatch = firstMethodComposite("SHA") { instructions( - allOf(Opcode.CONST_STRING(), "SHA"()), + Opcode.CONST_STRING(), Opcode.INVOKE_STATIC(), Opcode.INVOKE_STATIC(), Opcode.MOVE_RESULT_OBJECT(), diff --git a/patches/src/main/kotlin/app/revanced/patches/photomath/detection/signature/SignatureDetectionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/photomath/detection/signature/SignatureDetectionPatch.kt index ab8045ad2..70d6331e6 100644 --- a/patches/src/main/kotlin/app/revanced/patches/photomath/detection/signature/SignatureDetectionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/photomath/detection/signature/SignatureDetectionPatch.kt @@ -12,9 +12,8 @@ val `Signature detection` by creatingBytecodePatch( apply { val replacementIndex = checkSignatureMethodMatch.indices.last() - checkSignatureMethodMatch.method.apply { - val checkRegister = getInstruction(replacementIndex).registerA - replaceInstruction(replacementIndex, "const/4 v$checkRegister, 0x1") - } + val checkRegister = checkSignatureMethodMatch.method.getInstruction(replacementIndex) + .registerA + checkSignatureMethodMatch.method.replaceInstruction(replacementIndex, "const/4 v$checkRegister, 0x1") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/annoyances/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/annoyances/Fingerprints.kt index ce9deca51..6af6bd2a0 100644 --- a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/annoyances/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/annoyances/Fingerprints.kt @@ -1,20 +1,15 @@ package app.revanced.patches.photomath.misc.annoyances +import app.revanced.patcher.* import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively -import app.revanced.patcher.accessFlags -import app.revanced.patcher.definingClass -import app.revanced.patcher.fingerprint -import app.revanced.patcher.instructions -import app.revanced.patcher.invoke import app.revanced.patcher.patch.BytecodePatchContext -import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode internal val BytecodePatchContext.hideUpdatePopupMethod by gettingFirstMutableMethodDeclaratively { + definingClass("Lcom/microblink/photomath/main/activity/MainActivity;") accessFlags(AccessFlags.FINAL, AccessFlags.PUBLIC) returnType("V") - definingClass("Lcom/microblink/photomath/main/activity/MainActivity;") instructions( Opcode.CONST_HIGH16(), Opcode.INVOKE_VIRTUAL(), // ViewPropertyAnimator.alpha(1.0f) diff --git a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/bookpoint/EnableBookpointPatch.kt b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/bookpoint/EnableBookpointPatch.kt index 72091c63c..938d001b0 100644 --- a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/bookpoint/EnableBookpointPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/bookpoint/EnableBookpointPatch.kt @@ -1,10 +1,10 @@ package app.revanced.patches.photomath.misc.unlock.bookpoint import app.revanced.patcher.extensions.replaceInstructions -import app.revanced.patcher.patch.creatingBytecodePatch +import app.revanced.patcher.patch.bytecodePatch @Suppress("unused") -val `Enable bookpoint` by creatingBytecodePatch( +val enableBookpointPatch = bytecodePatch( description = "Enables textbook access", ) { diff --git a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/bookpoint/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/bookpoint/Fingerprints.kt index 3b316d054..c8686ca10 100644 --- a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/bookpoint/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/bookpoint/Fingerprints.kt @@ -2,21 +2,18 @@ package app.revanced.patches.photomath.misc.unlock.bookpoint import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively import app.revanced.patcher.accessFlags -import app.revanced.patcher.instructions -import app.revanced.patcher.invoke import app.revanced.patcher.parameterTypes import app.revanced.patcher.patch.BytecodePatchContext import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags -internal val BytecodePatchContext.isBookpointEnabledMethod by gettingFirstMutableMethodDeclaratively { +internal val BytecodePatchContext.isBookpointEnabledMethod by gettingFirstMutableMethodDeclaratively( + "NoGeoData", + "NoCountryInGeo", + "RemoteConfig", + "GeoRCMismatch" +) { accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) returnType("Z") parameterTypes() - instructions( - "NoGeoData"(), - "NoCountryInGeo"(), - "RemoteConfig"(), - "GeoRCMismatch"() - ) } diff --git a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/Fingerprints.kt index 9ffd32b90..487fc99ea 100644 --- a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/Fingerprints.kt @@ -5,12 +5,10 @@ import app.revanced.patcher.accessFlags import app.revanced.patcher.definingClass import app.revanced.patcher.patch.BytecodePatchContext import app.revanced.patcher.returnType -import app.revanced.patcher.string import com.android.tools.smali.dexlib2.AccessFlags -internal val BytecodePatchContext.isPlusUnlockedMethod by gettingFirstMutableMethodDeclaratively { +internal val BytecodePatchContext.isPlusUnlockedMethod by gettingFirstMutableMethodDeclaratively("genius") { accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) returnType("Z") - string("genius") definingClass("/User;"::endsWith) } diff --git a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/UnlockPlusPatch.kt b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/UnlockPlusPatch.kt index 3f0f8b159..ac5b87517 100644 --- a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/UnlockPlusPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/UnlockPlusPatch.kt @@ -3,11 +3,11 @@ package app.revanced.patches.photomath.misc.unlock.plus import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.patches.photomath.detection.signature.`Signature detection` -import app.revanced.patches.photomath.misc.unlock.bookpoint.`Enable bookpoint` +import app.revanced.patches.photomath.misc.unlock.bookpoint.enableBookpointPatch @Suppress("unused") val `Unlock plus` by creatingBytecodePatch { - dependsOn(`Signature detection`, `Enable bookpoint`) + dependsOn(`Signature detection`, enableBookpointPatch) compatibleWith("com.microblink.photomath") diff --git a/patches/src/main/kotlin/app/revanced/patches/piccomafr/tracking/DisableTrackingPatch.kt b/patches/src/main/kotlin/app/revanced/patches/piccomafr/tracking/DisableTrackingPatch.kt index a83fef5de..21adabc37 100644 --- a/patches/src/main/kotlin/app/revanced/patches/piccomafr/tracking/DisableTrackingPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/piccomafr/tracking/DisableTrackingPatch.kt @@ -33,34 +33,31 @@ val `Disable tracking` by creatingBytecodePatch( ) apply { - facebookSDKMethod.apply { - instructions.filter { instruction -> - instruction.opcode == Opcode.CONST_STRING - }.forEach { instruction -> - instruction as OneRegisterInstruction + facebookSDKMethod.instructions.filter { instruction -> + instruction.opcode == Opcode.CONST_STRING + }.forEach { instruction -> + instruction as OneRegisterInstruction - replaceInstruction( - instruction.location.index, - "const-string v${instruction.registerA}, \"example.com\"", - ) - } + facebookSDKMethod.replaceInstruction( + instruction.location.index, + "const-string v${instruction.registerA}, \"example.com\"", + ) } - firebaseInstallMethod.apply { - instructions.filter { - it.opcode == Opcode.CONST_STRING - }.filter { - it.getReference()?.string == "firebaseinstallations.googleapis.com" - }.forEach { instruction -> - instruction as OneRegisterInstruction + firebaseInstallMethod.instructions.filter { + it.opcode == Opcode.CONST_STRING + }.filter { + it.getReference()?.string == "firebaseinstallations.googleapis.com" + }.forEach { instruction -> + instruction as OneRegisterInstruction - replaceInstruction( - instruction.location.index, - "const-string v${instruction.registerA}, \"example.com\"", - ) - } + firebaseInstallMethod.replaceInstruction( + instruction.location.index, + "const-string v${instruction.registerA}, \"example.com\"", + ) } + appMeasurementMethod.addInstruction(0, "return-void") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/piccomafr/tracking/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/piccomafr/tracking/Fingerprints.kt index 2b727fef4..84722ee61 100644 --- a/patches/src/main/kotlin/app/revanced/patches/piccomafr/tracking/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/piccomafr/tracking/Fingerprints.kt @@ -12,7 +12,7 @@ internal val BytecodePatchContext.appMeasurementMethod by gettingFirstMutableMet } internal val BytecodePatchContext.facebookSDKMethod by gettingFirstMutableMethodDeclaratively("instagram.com", "facebook.com") { - accessFlags(AccessFlags.PRIVATE, AccessFlags.CONSTRUCTOR) + accessFlags(AccessFlags.STATIC, AccessFlags.CONSTRUCTOR) } internal val BytecodePatchContext.firebaseInstallMethod by gettingFirstMutableMethodDeclaratively("https://%s/%s/%s", "firebaseinstallations.googleapis.com") { diff --git a/patches/src/main/kotlin/app/revanced/patches/pixiv/ads/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/pixiv/ads/Fingerprints.kt index ce3d3d813..2c6e3d87b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/pixiv/ads/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/pixiv/ads/Fingerprints.kt @@ -9,8 +9,8 @@ import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags internal val BytecodePatchContext.shouldShowAdsMethod by gettingFirstMutableMethodDeclaratively { - accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) - returnType("Z") definingClass("AdUtils;"::endsWith) name("shouldShowAds") + accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) + returnType("Z") } diff --git a/patches/src/main/kotlin/app/revanced/patches/primevideo/ads/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/primevideo/ads/Fingerprints.kt index 25831a4bb..5135a609c 100644 --- a/patches/src/main/kotlin/app/revanced/patches/primevideo/ads/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/primevideo/ads/Fingerprints.kt @@ -1,18 +1,14 @@ package app.revanced.patches.primevideo.ads +import app.revanced.patcher.* import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively -import app.revanced.patcher.accessFlags -import app.revanced.patcher.definingClass -import app.revanced.patcher.instructions -import app.revanced.patcher.invoke -import app.revanced.patcher.name -import app.revanced.patcher.parameterTypes import app.revanced.patcher.patch.BytecodePatchContext -import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode internal val BytecodePatchContext.enterServerInsertedAdBreakStateMethod by gettingFirstMutableMethodDeclaratively { + name("enter") + definingClass("Lcom/amazon/avod/media/ads/internal/state/ServerInsertedAdBreakState;") accessFlags(AccessFlags.PUBLIC) parameterTypes("Lcom/amazon/avod/fsm/Trigger;") returnType("V") @@ -22,11 +18,11 @@ internal val BytecodePatchContext.enterServerInsertedAdBreakStateMethod by getti Opcode.CONST_4(), Opcode.CONST_4() ) - name("enter") - definingClass("Lcom/amazon/avod/media/ads/internal/state/ServerInsertedAdBreakState;") } internal val BytecodePatchContext.doTriggerMethod by gettingFirstMutableMethodDeclaratively { + name("doTrigger") + definingClass("Lcom/amazon/avod/fsm/StateBase;") accessFlags(AccessFlags.PROTECTED) returnType("V") instructions( @@ -34,6 +30,4 @@ internal val BytecodePatchContext.doTriggerMethod by gettingFirstMutableMethodDe Opcode.INVOKE_INTERFACE(), Opcode.RETURN_VOID() ) - name("doTrigger") - definingClass("Lcom/amazon/avod/fsm/StateBase;") } diff --git a/patches/src/main/kotlin/app/revanced/patches/primevideo/video/speed/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/primevideo/video/speed/Fingerprints.kt index 933e3dfda..9b020f8b5 100644 --- a/patches/src/main/kotlin/app/revanced/patches/primevideo/video/speed/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/primevideo/video/speed/Fingerprints.kt @@ -1,26 +1,22 @@ package app.revanced.patches.primevideo.video.speed +import app.revanced.patcher.* import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively -import app.revanced.patcher.accessFlags -import app.revanced.patcher.definingClass -import app.revanced.patcher.name -import app.revanced.patcher.parameterTypes import app.revanced.patcher.patch.BytecodePatchContext -import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags internal val BytecodePatchContext.playbackUserControlsInitializeMethod by gettingFirstMutableMethodDeclaratively { + name("initialize") + definingClass("Lcom/amazon/avod/playbackclient/activity/feature/PlaybackUserControlsFeature;") accessFlags(AccessFlags.PUBLIC) parameterTypes("Lcom/amazon/avod/playbackclient/PlaybackInitializationContext;") returnType("V") - name("initialize") - definingClass("Lcom/amazon/avod/playbackclient/activity/feature/PlaybackUserControlsFeature;") } internal val BytecodePatchContext.playbackUserControlsPrepareForPlaybackMethod by gettingFirstMutableMethodDeclaratively { + name("prepareForPlayback") + definingClass("Lcom/amazon/avod/playbackclient/activity/feature/PlaybackUserControlsFeature;") accessFlags(AccessFlags.PUBLIC) parameterTypes("Lcom/amazon/avod/playbackclient/PlaybackContext;") returnType("V") - name("prepareForPlayback") - definingClass("Lcom/amazon/avod/playbackclient/activity/feature/PlaybackUserControlsFeature;") } \ No newline at end of file diff --git a/patches/src/main/kotlin/app/revanced/patches/rar/misc/annoyances/purchasereminder/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/rar/misc/annoyances/purchasereminder/Fingerprints.kt index 3dd0dddf6..6799b6156 100644 --- a/patches/src/main/kotlin/app/revanced/patches/rar/misc/annoyances/purchasereminder/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/rar/misc/annoyances/purchasereminder/Fingerprints.kt @@ -9,8 +9,8 @@ import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags internal val BytecodePatchContext.showReminderMethod by gettingFirstMutableMethodDeclaratively { - accessFlags(AccessFlags.PUBLIC, AccessFlags.STATIC) - returnType("V") definingClass("AdsNotify;"::endsWith) name("show") + accessFlags(AccessFlags.PUBLIC, AccessFlags.STATIC) + returnType("V") } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/ad/banner/HideBannerPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/ad/banner/HideBannerPatch.kt deleted file mode 100644 index dac78869c..000000000 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/ad/banner/HideBannerPatch.kt +++ /dev/null @@ -1,35 +0,0 @@ -package app.revanced.patches.reddit.ad.banner - -import app.revanced.patcher.patch.creatingResourcePatch - -// Note that for now, this patch and anything using it will only work on -// Reddit 2024.17.0 or older. Newer versions will crash during patching. -// See https://github.com/ReVanced/revanced-patches/issues/3099 -@Suppress("unused") -val `Hide banner` = creatingResourcePatch( - description = "Hides banner ads from comments on subreddits.", -) { - apply { - val resourceFilePath = "res/layout/merge_listheader_link_detail.xml" - - document(resourceFilePath).use { document -> - document.getElementsByTagName("merge").item(0).childNodes.apply { - val attributes = arrayOf("height", "width") - - for (i in 1 until length) { - val view = item(i) - if ( - view.hasAttributes() && - view.attributes.getNamedItem("android:id").nodeValue.endsWith("ad_view_stub") - ) { - attributes.forEach { attribute -> - view.attributes.getNamedItem("android:layout_$attribute").nodeValue = "0.0dip" - } - - break - } - } - } - } - } -} diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/ad/general/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/ad/general/Fingerprints.kt index a637f8b6d..a5a526073 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/ad/general/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/ad/general/Fingerprints.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.nunl.ads +package app.revanced.patches.reddit.ad.general import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively import app.revanced.patcher.definingClass @@ -9,16 +9,13 @@ import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.Opcode internal val BytecodePatchContext.adPostMethod by gettingFirstMutableMethodDeclaratively("children") { + definingClass("Listing;"::endsWith) returnType("V") - // "children" are present throughout multiple versions - instructions("children"()) - definingClass { endsWith("Listing;") } } internal val BytecodePatchContext.newAdPostMethod by gettingFirstMutableMethodDeclaratively( - "feedElement", "com.reddit.cookie" + "feedElement", + "com.reddit.cookie" ) { instructions(Opcode.INVOKE_VIRTUAL()) - instructions("feedElement"()) - instructions("com.reddit.cookie"()) } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/ad/general/HideAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/ad/general/HideAdsPatch.kt index f4393c252..84d0fa250 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/ad/general/HideAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/ad/general/HideAdsPatch.kt @@ -3,10 +3,10 @@ package app.revanced.patches.reddit.ad.general import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.removeInstruction import app.revanced.patcher.patch.creatingBytecodePatch -import app.revanced.patches.nunl.ads.adPostMethod -import app.revanced.patches.nunl.ads.newAdPostMethod import app.revanced.patches.reddit.ad.comments.`Hide comment ads` import app.revanced.patches.reddit.misc.extension.sharedExtensionPatch +import app.revanced.util.getReference +import app.revanced.util.indexOfFirstInstruction import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction22c @@ -14,9 +14,7 @@ import com.android.tools.smali.dexlib2.iface.reference.FieldReference import com.android.tools.smali.dexlib2.iface.reference.MethodReference @Suppress("unused", "ObjectPropertyName") -val `Hide ads` by creatingBytecodePatch( - description = "Hide ads" -) { +val `Hide ads` by creatingBytecodePatch { dependsOn(`Hide comment ads`, sharedExtensionPatch) compatibleWith("com.reddit.frontpage") @@ -26,32 +24,30 @@ val `Hide ads` by creatingBytecodePatch( val filterMethodDescriptor = "Lapp/revanced/extension/reddit/patches/FilterPromotedLinksPatch;" + - "->filterChildren(Ljava/lang/Iterable;)Ljava/util/List;" + "->filterChildren(Ljava/lang/Iterable;)Ljava/util/List;" - adPostMethod.apply { - val setPostsListChildren = implementation!!.instructions.first { instruction -> - if (instruction.opcode != Opcode.IPUT_OBJECT) return@first false + val setPostsListChildren = adPostMethod.implementation!!.instructions.first { instruction -> + if (instruction.opcode != Opcode.IPUT_OBJECT) return@first false - val reference = (instruction as ReferenceInstruction).reference as FieldReference - reference.name == "children" - } - - val castedInstruction = setPostsListChildren as Instruction22c - val itemsRegister = castedInstruction.registerA - val listInstanceRegister = castedInstruction.registerB - - // postsList.children = filterChildren(postListItems) - removeInstruction(setPostsListChildren.location.index) - addInstructions( - setPostsListChildren.location.index, - """ - invoke-static {v$itemsRegister}, $filterMethodDescriptor - move-result-object v0 - iput-object v0, v$listInstanceRegister, ${castedInstruction.reference} - """, - ) + val reference = (instruction as ReferenceInstruction).reference as FieldReference + reference.name == "children" } + val castedInstruction = setPostsListChildren as Instruction22c + val itemsRegister = castedInstruction.registerA + val listInstanceRegister = castedInstruction.registerB + + // postsList.children = filterChildren(postListItems) + adPostMethod.removeInstruction(setPostsListChildren.location.index) + adPostMethod.addInstructions( + setPostsListChildren.location.index, + """ + invoke-static {v$itemsRegister}, $filterMethodDescriptor + move-result-object v0 + iput-object v0, v$listInstanceRegister, ${castedInstruction.reference} + """, + ) + // endregion // region Remove ads from popular and latest feed @@ -60,10 +56,8 @@ val `Hide ads` by creatingBytecodePatch( // AdElementConverter is conveniently responsible for inserting all feed ads. // By removing the appending instruction no ad posts gets appended to the feed. - val index = newAdPostMethod.implementation!!.instructions.indexOfFirst { - if (it.opcode != Opcode.INVOKE_VIRTUAL) return@indexOfFirst false - - val reference = (it as ReferenceInstruction).reference as MethodReference + val index = newAdPostMethod.indexOfFirstInstruction { + val reference = getReference() ?: return@indexOfFirstInstruction false reference.name == "add" && reference.definingClass == "Ljava/util/ArrayList;" } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/FixRedgifsApiPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/FixRedgifsApiPatch.kt index ea3f5ce5e..f83711051 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/FixRedgifsApiPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/FixRedgifsApiPatch.kt @@ -2,15 +2,15 @@ package app.revanced.patches.reddit.customclients import app.revanced.patcher.patch.BytecodePatchBuilder import app.revanced.patcher.patch.Patch -import app.revanced.patcher.patch.creatingBytecodePatch +import app.revanced.patcher.patch.bytecodePatch const val INSTALL_NEW_CLIENT_METHOD = "install(Lokhttp3/OkHttpClient${'$'}Builder;)Lokhttp3/OkHttpClient;" const val CREATE_NEW_CLIENT_METHOD = "createClient()Lokhttp3/OkHttpClient;" -fun `Fix Redgifs API`( +fun fixRedgifsApi( extensionPatch: Patch, block: BytecodePatchBuilder.() -> Unit = {}, -) = creatingBytecodePatch { +) = bytecodePatch("Fix Redgifs API") { dependsOn(extensionPatch) block() diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/FixSLinksPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/FixSLinksPatch.kt index c130a1f7b..3b8d63251 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/FixSLinksPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/FixSLinksPatch.kt @@ -2,15 +2,17 @@ package app.revanced.patches.reddit.customclients import app.revanced.patcher.patch.BytecodePatchBuilder import app.revanced.patcher.patch.Patch -import app.revanced.patcher.patch.creatingBytecodePatch +import app.revanced.patcher.patch.bytecodePatch const val RESOLVE_S_LINK_METHOD = "patchResolveSLink(Ljava/lang/String;)Z" const val SET_ACCESS_TOKEN_METHOD = "patchSetAccessToken(Ljava/lang/String;)V" -fun `Fix s links`( +fun fixSLinksPatch( extensionPatch: Patch, block: BytecodePatchBuilder.() -> Unit = {}, -) = creatingBytecodePatch { +) = bytecodePatch( + "Fix /s/ links", +) { dependsOn(extensionPatch) block() diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/SpoofClientPatch.kt index 3a3851afb..aeebd02a6 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/SpoofClientPatch.kt @@ -2,7 +2,7 @@ package app.revanced.patches.reddit.customclients import app.revanced.patcher.patch.BytecodePatchBuilder import app.revanced.patcher.patch.Option -import app.revanced.patcher.patch.creatingBytecodePatch +import app.revanced.patcher.patch.bytecodePatch import app.revanced.patcher.patch.stringOption /** @@ -11,10 +11,11 @@ import app.revanced.patcher.patch.stringOption * @param redirectUri The redirect URI of the Reddit OAuth client. * @param block The patch block. It is called with the client ID option. */ -fun `Spoof client`( +fun spoofClientPatch( redirectUri: String, block: BytecodePatchBuilder.(Option) -> Unit = {}, -) = creatingBytecodePatch( +) = bytecodePatch( + name = "Spoof client", description = "Restores functionality of the app by using custom client ID.", ) { block( diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/api/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/api/Fingerprints.kt index 0626439cf..9bbb82557 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/api/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/api/Fingerprints.kt @@ -1,20 +1,16 @@ package app.revanced.patches.reddit.customclients.baconreader.api -import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively -import app.revanced.patcher.definingClass -import app.revanced.patcher.name -import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.firstMethodComposite +import app.revanced.patcher.instructions +import app.revanced.patcher.invoke -internal val BytecodePatchContext.getAuthorizationUrlMethod by gettingFirstMutableMethodDeclaratively( - "client_id=zACVn0dSFGdWqQ" -) - -internal val BytecodePatchContext.getClientIdMethod by gettingFirstMutableMethodDeclaratively("client_id=zACVn0dSFGdWqQ") { - name("getAuthorizeUrl") - definingClass { endsWith("RedditOAuth;") } +internal val getAuthorizationUrlMethodMatch = firstMethodComposite { + instructions("client_id=zACVn0dSFGdWqQ"()) } -internal val BytecodePatchContext.requestTokenMethod by gettingFirstMutableMethodDeclaratively( - "zACVn0dSFGdWqQ", - "kDm2tYpu9DqyWFFyPlNcXGEni4k" -) +internal val requestTokenMethodMatch = firstMethodComposite { + instructions( + "zACVn0dSFGdWqQ"(), + "kDm2tYpu9DqyWFFyPlNcXGEni4k"(String::contains) + ) +} \ No newline at end of file diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/api/SpoofClientPatch.kt index 45994659b..8e753ee4e 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/api/SpoofClientPatch.kt @@ -1,17 +1,13 @@ package app.revanced.patches.reddit.customclients.baconreader.api +import app.revanced.patcher.MatchBuilder import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.replaceInstruction -import app.revanced.patches.reddit.customclients.`Spoof client` +import app.revanced.patches.reddit.customclients.spoofClientPatch import app.revanced.patches.shared.misc.string.replaceStringPatch -import app.revanced.util.getReference -import app.revanced.util.indexOfFirstInstructionOrThrow -import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.StringReference -import com.android.tools.smali.dexlib2.mutable.MutableMethod -val spoofClientPatch = `Spoof client`(redirectUri = "http://baconreader.com/auth") { clientIdOption -> +val spoofClientPatch = spoofClientPatch(redirectUri = "http://baconreader.com/auth") { clientIdOption -> dependsOn( // Redirects from SSL to WWW domain are bugged causing auth problems. // Manually rewrite the URLs to fix this. @@ -26,22 +22,20 @@ val spoofClientPatch = `Spoof client`(redirectUri = "http://baconreader.com/auth val clientId by clientIdOption apply { - fun MutableMethod.patch(targetString: String, replacementString: String) { - val clientIdIndex = indexOfFirstInstructionOrThrow { - opcode == Opcode.CONST_STRING && getReference()?.string == targetString - } + fun MatchBuilder.patch(replacementString: String) { + val clientIdIndex = indices.first() - val clientIdRegister = getInstruction(clientIdIndex).registerA - replaceInstruction( + val clientIdRegister = method.getInstruction(clientIdIndex).registerA + method.replaceInstruction( clientIdIndex, "const-string v$clientIdRegister, \"$replacementString\"", ) } // Patch client id in authorization url. - getAuthorizationUrlMethod.patch("client_id=zACVn0dSFGdWqQ", "client_id=$clientId") + getAuthorizationUrlMethodMatch.patch("client_id=$clientId") // Patch client id for access token request. - requestTokenMethod.patch("zACVn0dSFGdWqQ", clientId!!) + requestTokenMethodMatch.patch(clientId!!) } } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/fix/redgifs/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/fix/redgifs/Fingerprints.kt index fa5450809..6b2dcfd8f 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/fix/redgifs/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/fix/redgifs/Fingerprints.kt @@ -8,8 +8,8 @@ import app.revanced.patcher.patch.BytecodePatchContext import app.revanced.patcher.returnType internal val BytecodePatchContext.getOkHttpClientMethod by gettingFirstMutableMethodDeclaratively { - returnType("Lokhttp3/OkHttpClient;") - parameterTypes() definingClass("Lcom/onelouder/baconreader/media/gfycat/RedGifsManager;") name("getOkhttpClient") + returnType("Lokhttp3/OkHttpClient;") + parameterTypes() } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/fix/redgifs/FixRedgifsApiPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/fix/redgifs/FixRedgifsApiPatch.kt index 68ce7ce72..74f206c38 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/fix/redgifs/FixRedgifsApiPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/fix/redgifs/FixRedgifsApiPatch.kt @@ -3,9 +3,9 @@ package app.revanced.patches.reddit.customclients.baconreader.fix.redgifs import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.removeInstructions import app.revanced.patcher.extensions.replaceInstruction +import app.revanced.patches.reddit.customclients.fixRedgifsApi import app.revanced.patches.reddit.customclients.INSTALL_NEW_CLIENT_METHOD import app.revanced.patches.reddit.customclients.baconreader.misc.extension.sharedExtensionPatch -import app.revanced.patches.reddit.customclients.`Fix Redgifs API` import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import com.android.tools.smali.dexlib2.Opcode @@ -16,7 +16,7 @@ import com.android.tools.smali.dexlib2.iface.reference.TypeReference internal const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/baconreader/FixRedgifsApiPatch;" @Suppress("unused") -val fixRedgifsApi = `Fix Redgifs API`( +val fixRedgifsApi = fixRedgifsApi( extensionPatch = sharedExtensionPatch ) { compatibleWith( @@ -27,26 +27,25 @@ val fixRedgifsApi = `Fix Redgifs API`( apply { // region Patch Redgifs OkHttp3 client. - getOkHttpClientMethod.apply { - // Remove conflicting OkHttp interceptors. - val originalInterceptorInstallIndex = indexOfFirstInstructionOrThrow { - opcode == Opcode.NEW_INSTANCE && getReference()?.type == "Lcom/onelouder/baconreader/media/gfycat/RedGifsManager\$HeaderInterceptor;" - } - removeInstructions(originalInterceptorInstallIndex, 5) - - val index = indexOfFirstInstructionOrThrow { - val reference = getReference() - reference?.name == "build" && reference.definingClass == "Lokhttp3/OkHttpClient\$Builder;" - } - val register = getInstruction(index).registerC - replaceInstruction( - index, - """ - invoke-static { v$register }, $EXTENSION_CLASS_DESCRIPTOR->$INSTALL_NEW_CLIENT_METHOD - """ - ) + // Remove conflicting OkHttp interceptors. + val originalInterceptorInstallIndex = getOkHttpClientMethod.indexOfFirstInstructionOrThrow { + opcode == Opcode.NEW_INSTANCE && getReference()?.type == "Lcom/onelouder/baconreader/media/gfycat/RedGifsManager\$HeaderInterceptor;" } + getOkHttpClientMethod.removeInstructions(originalInterceptorInstallIndex, 5) - // endregion + val index = getOkHttpClientMethod.indexOfFirstInstructionOrThrow { + val reference = getReference() + reference?.name == "build" && reference.definingClass == "Lokhttp3/OkHttpClient\$Builder;" + } + val register = getOkHttpClientMethod.getInstruction(index).registerC + getOkHttpClientMethod.replaceInstruction( + index, + """ + invoke-static { v$register }, $EXTENSION_CLASS_DESCRIPTOR->$INSTALL_NEW_CLIENT_METHOD + """ + ) } + + // endregion + } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/ads/DisableAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/ads/DisableAdsPatch.kt index f96c75505..75af181e9 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/ads/DisableAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/ads/DisableAdsPatch.kt @@ -1,15 +1,14 @@ package app.revanced.patches.reddit.customclients.boostforreddit.ads -import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.patch.creatingBytecodePatch +import app.revanced.util.returnEarly @Suppress("unused", "ObjectPropertyName") val `Disable ads` by creatingBytecodePatch { compatibleWith("com.rubenmayayo.reddit") apply { - arrayOf(maxMediationMethod, admobMediationMethod).forEach { method -> - method.addInstructions(0, "return-void") - } + maxMediationMethod.returnEarly() + admobMediationMethod.returnEarly() } } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/Fingerprints.kt index 0067b7c3c..1c95b37b9 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/Fingerprints.kt @@ -11,5 +11,5 @@ internal val BytecodePatchContext.buildUserAgentMethod by gettingFirstMutableMet internal val BytecodePatchContext.getClientIdMethod by gettingFirstMutableMethodDeclaratively { name("getClientId") - definingClass { endsWith("Credentials;") } + definingClass("Credentials;"::endsWith) } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt index 3677f9dff..b99df9d8e 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt @@ -2,7 +2,7 @@ package app.revanced.patches.reddit.customclients.boostforreddit.api import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.replaceInstruction -import app.revanced.patches.reddit.customclients.`Spoof client` +import app.revanced.patches.reddit.customclients.spoofClientPatch import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import app.revanced.util.returnEarly @@ -11,7 +11,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.reference.StringReference @Suppress("unused") -val spoofClientPatch = `Spoof client`(redirectUri = "http://rubenmayayo.com") { clientIdOption -> +val spoofClientPatch = spoofClientPatch(redirectUri = "http://rubenmayayo.com") { clientIdOption -> compatibleWith("com.rubenmayayo.reddit") val clientId by clientIdOption @@ -29,14 +29,12 @@ val spoofClientPatch = `Spoof client`(redirectUri = "http://rubenmayayo.com") { val randomName = (0..100000).random() val userAgent = "$randomName:app.revanced.$randomName:v1.0.0 (by /u/revanced)" - buildUserAgentMethod.apply { - val userAgentTemplateIndex = indexOfFirstInstructionOrThrow { - opcode == Opcode.CONST_STRING && getReference()?.string == "%s:%s:%s (by /u/%s)" - } - val register = getInstruction(userAgentTemplateIndex).registerA - - replaceInstruction(userAgentTemplateIndex, "const-string v$register, \"$userAgent\"") + val userAgentTemplateIndex = buildUserAgentMethod.indexOfFirstInstructionOrThrow { + opcode == Opcode.CONST_STRING && getReference()?.string == "%s:%s:%s (by /u/%s)" } + val register = buildUserAgentMethod.getInstruction(userAgentTemplateIndex).registerA + + buildUserAgentMethod.replaceInstruction(userAgentTemplateIndex, "const-string v$register, \"$userAgent\"") // endregion } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/downloads/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/downloads/Fingerprints.kt index 9b8d09bfa..126bc84c8 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/downloads/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/downloads/Fingerprints.kt @@ -1,9 +1,12 @@ package app.revanced.patches.reddit.customclients.boostforreddit.fix.downloads -import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively -import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.firstMethodComposite +import app.revanced.patcher.instructions +import app.revanced.patcher.invoke -internal val BytecodePatchContext.downloadAudioMethod by gettingFirstMutableMethodDeclaratively( - "/DASH_audio.mp4", - "/audio" -) +internal val downloadAudioMethodMatch = firstMethodComposite { + instructions( + "/DASH_audio.mp4"(), + "/audio"() + ) +} diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/downloads/FixAudioMissingInDownloadsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/downloads/FixAudioMissingInDownloadsPatch.kt index 8df738f2b..241a12a8b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/downloads/FixAudioMissingInDownloadsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/downloads/FixAudioMissingInDownloadsPatch.kt @@ -3,11 +3,7 @@ package app.revanced.patches.reddit.customclients.boostforreddit.fix.downloads import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patcher.patch.creatingBytecodePatch -import app.revanced.util.findInstructionIndicesReversed -import app.revanced.util.getReference -import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.StringReference @Suppress("unused", "ObjectPropertyName") val `Fix missing audio in video downloads` by creatingBytecodePatch( @@ -16,21 +12,16 @@ val `Fix missing audio in video downloads` by creatingBytecodePatch( compatibleWith("com.rubenmayayo.reddit") apply { - val endpointReplacements = mapOf( - "/DASH_audio.mp4" to "/DASH_AUDIO_128.mp4", - "/audio" to "/DASH_AUDIO_64.mp4", + val endpointReplacements = arrayOf( + "/DASH_AUDIO_128.mp4", + "/DASH_AUDIO_64.mp4", ) - downloadAudioMethod.apply { - endpointReplacements.forEach { (target, replacement) -> - // Find all occurrences of the target string in the method - findInstructionIndicesReversed { - opcode == Opcode.CONST_STRING && getReference()?.string == target - }.forEach { index -> - val register = getInstruction(index).registerA - replaceInstruction(index, "const-string v$register, \"$replacement\"") - } - } + downloadAudioMethodMatch.indices.forEachIndexed { index, i -> + val replacement = endpointReplacements[i] + val register = downloadAudioMethodMatch.method.getInstruction(index).registerA + + downloadAudioMethodMatch.method.replaceInstruction(index, "const-string v$register, \"$replacement\"") } } } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/redgifs/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/redgifs/Fingerprints.kt index 27e5f81ca..4a73809bd 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/redgifs/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/redgifs/Fingerprints.kt @@ -1,15 +1,10 @@ package app.revanced.patches.reddit.customclients.boostforreddit.fix.redgifs +import app.revanced.patcher.* import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively -import app.revanced.patcher.accessFlags -import app.revanced.patcher.classDef -import app.revanced.patcher.custom -import app.revanced.patcher.instructions -import app.revanced.patcher.invoke import app.revanced.patcher.patch.BytecodePatchContext import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode -import com.android.tools.smali.dexlib2.iface.Method internal val BytecodePatchContext.createOkHttpClientMethod by gettingFirstMutableMethodDeclaratively { accessFlags(AccessFlags.PRIVATE) @@ -23,8 +18,5 @@ internal val BytecodePatchContext.createOkHttpClientMethod by gettingFirstMutabl Opcode.INVOKE_VIRTUAL(), Opcode.MOVE_RESULT_OBJECT() ) - - // Helper to capture the BytecodePatchContext for classDef access - fun Method.isTargetSourceFile() = classDef.sourceFile == "RedGifsAPIv2.java" - custom { isTargetSourceFile() } + custom { immutableClassDef.sourceFile == "RedGifsAPIv2.java" } } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/redgifs/FixRedgifsApiPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/redgifs/FixRedgifsApiPatch.kt index bcc53c264..a9abcacff 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/redgifs/FixRedgifsApiPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/redgifs/FixRedgifsApiPatch.kt @@ -1,17 +1,16 @@ package app.revanced.patches.reddit.customclients.boostforreddit.fix.redgifs +import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patches.reddit.customclients.CREATE_NEW_CLIENT_METHOD +import app.revanced.patches.reddit.customclients.fixRedgifsApi import app.revanced.patches.reddit.customclients.boostforreddit.misc.extension.sharedExtensionPatch -import app.revanced.patches.reddit.customclients.`Fix Redgifs API` -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow -import com.android.tools.smali.dexlib2.iface.reference.MethodReference private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/boostforreddit/FixRedgifsApiPatch;" @Suppress("unused") -val fixRedgifsApi = `Fix Redgifs API`( +val fixRedgifsApi = fixRedgifsApi( extensionPatch = sharedExtensionPatch ) { compatibleWith("com.rubenmayayo.reddit") @@ -19,16 +18,14 @@ val fixRedgifsApi = `Fix Redgifs API`( apply { // region Patch Redgifs OkHttp3 client. - createOkHttpClientMethod.apply { - val index = indexOfFirstInstructionOrThrow { - val reference = getReference() - reference?.name == "build" && reference.definingClass == "Lokhttp3/OkHttpClient\$Builder;" - } - replaceInstruction( - index, - "invoke-static { }, $EXTENSION_CLASS_DESCRIPTOR->$CREATE_NEW_CLIENT_METHOD" - ) + val index = createOkHttpClientMethod.indexOfFirstInstructionOrThrow { + val reference = methodReference + reference?.name == "build" && reference.definingClass == "Lokhttp3/OkHttpClient\$Builder;" } + createOkHttpClientMethod.replaceInstruction( + index, + "invoke-static { }, $EXTENSION_CLASS_DESCRIPTOR->$CREATE_NEW_CLIENT_METHOD" + ) // endregion } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/slink/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/slink/Fingerprints.kt index dd8541c67..601bb0892 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/slink/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/slink/Fingerprints.kt @@ -8,9 +8,9 @@ import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags internal val BytecodePatchContext.getOAuthAccessTokenMethod by gettingFirstMutableMethodDeclaratively("access_token") { + definingClass("Lnet/dean/jraw/http/oauth/OAuthData;") accessFlags(AccessFlags.PUBLIC) returnType("Ljava/lang/String;") - definingClass("Lnet/dean/jraw/http/oauth/OAuthData;") } internal val BytecodePatchContext.handleNavigationMethod by gettingFirstMutableMethodDeclaratively( diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/slink/FixSLinksPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/slink/FixSLinksPatch.kt index 373aff56d..1100a7389 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/slink/FixSLinksPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/slink/FixSLinksPatch.kt @@ -20,21 +20,20 @@ val fixSlinksPatch = fixSLinksPatch( apply { // region Patch navigation handler. - handleNavigationMethod.apply { - val urlRegister = "p1" - val tempRegister = "v1" + val urlRegister = "p1" + val tempRegister = "v1" + + handleNavigationMethod.addInstructionsWithLabels( + 0, + """ + invoke-static { $urlRegister }, $EXTENSION_CLASS_DESCRIPTOR->$RESOLVE_S_LINK_METHOD + move-result $tempRegister + if-eqz $tempRegister, :continue + return $tempRegister + """, + ExternalLabel("continue", handleNavigationMethod.getInstruction(0)), + ) - addInstructionsWithLabels( - 0, - """ - invoke-static { $urlRegister }, $EXTENSION_CLASS_DESCRIPTOR->$RESOLVE_S_LINK_METHOD - move-result $tempRegister - if-eqz $tempRegister, :continue - return $tempRegister - """, - ExternalLabel("continue", getInstruction(0)), - ) - } // endregion diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/Fingerprints.kt index 4bce1362c..24b7092be 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/Fingerprints.kt @@ -1,7 +1,6 @@ package app.revanced.patches.reddit.customclients.infinityforreddit.api -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethod +import app.revanced.patcher.patch.BytecodePatchContext -internal val apiUtilsFingerprint = fingerprint { - strings("native-lib") -} \ No newline at end of file +internal val BytecodePatchContext.apiUtilsMethod by gettingFirstMutableMethod("native-lib") \ No newline at end of file diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/SpoofClientPatch.kt index 8a517551f..c027bfef8 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/SpoofClientPatch.kt @@ -1,13 +1,13 @@ package app.revanced.patches.reddit.customclients.infinityforreddit.api import app.revanced.patcher.extensions.toInstructions -import app.revanced.patches.reddit.customclients.`Spoof client` +import app.revanced.patches.reddit.customclients.spoofClientPatch import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.immutable.ImmutableMethod import com.android.tools.smali.dexlib2.immutable.ImmutableMethodImplementation import com.android.tools.smali.dexlib2.mutable.MutableMethod.Companion.toMutable -val spoofClientPatch = `Spoof client`(redirectUri = "infinity://localhost") { clientIdOption -> +val spoofClientPatch = spoofClientPatch(redirectUri = "infinity://localhost") { clientIdOption -> compatibleWith( "ml.docilealligator.infinityforreddit", "ml.docilealligator.infinityforreddit.plus", @@ -17,7 +17,7 @@ val spoofClientPatch = `Spoof client`(redirectUri = "infinity://localhost") { cl val clientId by clientIdOption apply { - apiUtilsFingerprint.classDef.methods.apply { + apiUtilsMethod.classDef.methods.apply { val getClientIdMethod = single { it.name == "getId" }.also(::remove) val newGetClientIdMethod = ImmutableMethod( diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/Fingerprints.kt index c133028a6..8bfa18fec 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/Fingerprints.kt @@ -1,14 +1,13 @@ package app.revanced.patches.reddit.customclients.infinityforreddit.subscription +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethod import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively import app.revanced.patcher.instructions -import app.revanced.patcher.literal +import app.revanced.patcher.invoke import app.revanced.patcher.patch.BytecodePatchContext -internal val BytecodePatchContext.billingClientOnServiceConnectedMethod by gettingFirstMutableMethodDeclaratively("Billing service connected") +internal val BytecodePatchContext.billingClientOnServiceConnectedMethod by gettingFirstMutableMethod("Billing service connected") internal val BytecodePatchContext.startSubscriptionActivityMethod by gettingFirstMutableMethodDeclaratively { - instructions( - literal(0x10008000) - ) + instructions(0x10008000L()) } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/UnlockSubscriptionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/UnlockSubscriptionPatch.kt index 6fc58b566..6c7636172 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/UnlockSubscriptionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/UnlockSubscriptionPatch.kt @@ -17,9 +17,7 @@ val `Unlock subscription` by creatingBytecodePatch( ) apply { - setOf( - billingClientOnServiceConnectedMethod, - startSubscriptionActivityMethod, - ).forEach { it.returnEarly() } + billingClientOnServiceConnectedMethod.returnEarly() + startSubscriptionActivityMethod.returnEarly() } } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/DisableAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/DisableAdsPatch.kt index 1a912847d..b95f72fbe 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/DisableAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/DisableAdsPatch.kt @@ -1,8 +1,8 @@ package app.revanced.patches.reddit.customclients.joeyforreddit.ads -import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.`Disable piracy detection` +import app.revanced.util.returnEarly @Suppress("unused", "ObjectPropertyName") val `Disable ads` by creatingBytecodePatch { @@ -11,12 +11,6 @@ val `Disable ads` by creatingBytecodePatch { compatibleWith("o.o.joey") apply { - isAdFreeUserMethod.addInstructions( - 0, - """ - const/4 v0, 0x1 - return v0 - """, - ) + isAdFreeUserMethod.returnEarly(true) } } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/Fingerprints.kt index da1c7a574..3beb01afb 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/Fingerprints.kt @@ -4,11 +4,9 @@ import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutab import app.revanced.patcher.accessFlags import app.revanced.patcher.patch.BytecodePatchContext import app.revanced.patcher.returnType -import app.revanced.patcher.string import com.android.tools.smali.dexlib2.AccessFlags -internal val BytecodePatchContext.isAdFreeUserMethod by gettingFirstMutableMethodDeclaratively { +internal val BytecodePatchContext.isAdFreeUserMethod by gettingFirstMutableMethodDeclaratively("AD_FREE_USER") { accessFlags(AccessFlags.PUBLIC) returnType("Z") - string("AD_FREE_USER") } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/Fingerprints.kt index 0c2240404..b307112d6 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/Fingerprints.kt @@ -1,13 +1,8 @@ -package app.revanced.patches.reddit.customclients.infinity.api +package app.revanced.patches.reddit.customclients.joeyforreddit.api +import app.revanced.patcher.* import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively -import app.revanced.patcher.accessFlags -import app.revanced.patcher.classDef -import app.revanced.patcher.custom -import app.revanced.patcher.instructions -import app.revanced.patcher.invoke import app.revanced.patcher.patch.BytecodePatchContext -import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode @@ -15,7 +10,7 @@ internal val BytecodePatchContext.authUtilityUserAgentMethod by gettingFirstMuta accessFlags(AccessFlags.PUBLIC, AccessFlags.STATIC) returnType("Ljava/lang/String;") instructions(Opcode.APUT_OBJECT()) - custom { classDef.sourceFile == "AuthUtility.java" } + custom { immutableClassDef.sourceFile == "AuthUtility.java" } } internal val BytecodePatchContext.getClientIdMethod by gettingFirstMutableMethodDeclaratively { @@ -27,5 +22,5 @@ internal val BytecodePatchContext.getClientIdMethod by gettingFirstMutableMethod Opcode.MOVE_RESULT_OBJECT(), Opcode.RETURN_OBJECT(), ) - custom { classDef.sourceFile == "AuthUtility.java" } + custom { immutableClassDef.sourceFile == "AuthUtility.java" } } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt index c52a7c3d5..8e9fa3d23 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt @@ -1,13 +1,11 @@ package app.revanced.patches.reddit.customclients.joeyforreddit.api -import app.revanced.patches.reddit.customclients.infinity.api.authUtilityUserAgentMethod -import app.revanced.patches.reddit.customclients.infinity.api.getClientIdMethod -import app.revanced.patches.reddit.customclients.`Spoof client` -import app.revanced.patches.reddit.customclients.sync.detection.piracy.`Disable piracy detection` +import app.revanced.patches.reddit.customclients.spoofClientPatch +import app.revanced.patches.reddit.customclients.sync.detection.piracy.disablePiracyDetectionPatch import app.revanced.util.returnEarly -val spoofClientPatch = `Spoof client`(redirectUri = "https://127.0.0.1:65023/authorize_callback") { clientIdOption -> - dependsOn(`Disable piracy detection`) +val spoofClientPatch = spoofClientPatch(redirectUri = "https://127.0.0.1:65023/authorize_callback") { clientIdOption -> + dependsOn(disablePiracyDetectionPatch) compatibleWith( "o.o.joey", diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/Fingerprints.kt index aaffb09ae..d64d1e195 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/Fingerprints.kt @@ -1,12 +1,8 @@ package app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy +import app.revanced.patcher.* import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively -import app.revanced.patcher.accessFlags -import app.revanced.patcher.definingClass -import app.revanced.patcher.instructions -import app.revanced.patcher.invoke import app.revanced.patcher.patch.BytecodePatchContext -import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/Fingerprints.kt index e8fda82a8..8becfda2a 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/Fingerprints.kt @@ -1,24 +1,24 @@ package app.revanced.patches.reddit.customclients.redditisfun.api +import app.revanced.patcher.* import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively -import app.revanced.patcher.accessFlags -import app.revanced.patcher.instructions -import app.revanced.patcher.invoke -import app.revanced.patcher.parameterTypes import app.revanced.patcher.patch.BytecodePatchContext -import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode -internal val BytecodePatchContext.basicAuthorizationMethod by gettingFirstMutableMethodDeclaratively( - "yyOCBp.RHJhDKd", - "fJOxVwBUyo*=f: +val spoofClientPatch = spoofClientPatch(redirectUri = "redditisfun://auth") { clientIdOption -> compatibleWith( "com.andrewshu.android.reddit", "com.andrewshu.android.redditdonation", @@ -29,36 +29,23 @@ val spoofClientPatch = `Spoof client`(redirectUri = "redditisfun://auth") { clie * * @param string The string to replace the instruction with. * @param getReplacementIndex A function that returns the index of the instruction to replace - * using the [Match.StringMatch] list from the [Match]. + * using the [Match.indices] list from the [Match]. */ - fun MutableMethod.replaceWith( + fun MatchBuilder.replaceWith( string: String, - offset: Int, - getReplacementIndex: String - ) { - val anchorIndex = indexOfFirstInstructionOrThrow { - opcode == Opcode.CONST_STRING && getReference()?.string == string - } + getReplacementIndex: List.() -> Int, + ) = method.apply { + val replacementIndex = indices.getReplacementIndex() + val clientIdRegister = getInstruction(replacementIndex).registerA - val targetIndex = anchorIndex + offset - val clientIdRegister = getInstruction(targetIndex).registerA - - replaceInstruction(targetIndex, "const-string v$clientIdRegister, \"$getReplacementIndex\"") + replaceInstruction(replacementIndex, "const-string v$clientIdRegister, \"$string\"") } // Patch OAuth authorization. - buildAuthorizationStringMethod.replaceWith( - string = "yyOCBp.RHJhDKd", - offset = 4, - getReplacementIndex = clientId!! - ) + buildAuthorizationStringMethodMatch.replaceWith(clientId!!) { first() + 4 } // Path basic authorization. - basicAuthorizationMethod.replaceWith( - string = "fJOxVwBUyo*=f:()?.string?.contains("old.reddit.com") == true + getReference()?.contains("old.reddit.com") == true } val targetRegister = getInstruction(index).registerA diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/Fingerprints.kt index 005883772..8b7d50278 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/Fingerprints.kt @@ -1,27 +1,28 @@ package app.revanced.patches.reddit.customclients.relayforreddit.api import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.firstMethodComposite import app.revanced.patcher.instructions import app.revanced.patcher.invoke import app.revanced.patcher.parameterTypes import app.revanced.patcher.patch.BytecodePatchContext import com.android.tools.smali.dexlib2.Opcode -internal val BytecodePatchContext.getLoggedInBearerTokenMethod by gettingFirstMutableMethodDeclaratively( - "dj-xCIZQYiLbEg", "authorization_code" -) -internal val BytecodePatchContext.getLoggedOutBearerTokenMethod by gettingFirstMutableMethodDeclaratively( - "dj-xCIZQYiLbEg", "https://oauth.reddit.com/grants/installed_client" -) +internal fun baseClientIdMethod(string: String) = firstMethodComposite { + instructions( + "dj-xCIZQYiLbEg"(), + string() + ) +} -internal val BytecodePatchContext.getRefreshTokenMethod by gettingFirstMutableMethodDeclaratively( - "dj-xCIZQYiLbEg", "refresh_token" -) +internal val getLoggedInBearerTokenMethodMatch = baseClientIdMethod("authorization_code") -internal val BytecodePatchContext.loginActivityClientIdMethod by gettingFirstMutableMethodDeclaratively( - "dj-xCIZQYiLbEg", "&duration=permanent" -) +internal val getLoggedOutBearerTokenMethodMatch = baseClientIdMethod("https://oauth.reddit.com/grants/installed_client") + +internal val getRefreshTokenMethodMatch = baseClientIdMethod("refresh_token") + +internal val loginActivityClientIdMethodMatch = baseClientIdMethod("&duration=permanent") internal val BytecodePatchContext.redditCheckDisableAPIMethod by gettingFirstMutableMethodDeclaratively("Reddit Disabled") { instructions(Opcode.IF_EQZ()) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/SpoofClientPatch.kt index 534e89c26..fa0f6fbf2 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/SpoofClientPatch.kt @@ -1,19 +1,17 @@ package app.revanced.patches.reddit.customclients.relayforreddit.api -import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.replaceInstruction -import app.revanced.patches.reddit.customclients.`Spoof client` -import app.revanced.util.getReference +import app.revanced.patches.reddit.customclients.spoofClientPatch import app.revanced.util.indexOfFirstInstructionOrThrow +import app.revanced.util.returnEarly import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction10t import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21t import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.StringReference @Suppress("unused") -val spoofClientPatch = `Spoof client`(redirectUri = "dbrady://relay") { clientIdOption -> +val spoofClientPatch = spoofClientPatch(redirectUri = "dbrady://relay") { clientIdOption -> compatibleWith( "free.reddit.news", "reddit.news", @@ -25,22 +23,15 @@ val spoofClientPatch = `Spoof client`(redirectUri = "dbrady://relay") { clientId // region Patch client id. listOf( - loginActivityClientIdMethod, - getLoggedInBearerTokenMethod, - getLoggedOutBearerTokenMethod, - getRefreshTokenMethod, - ).forEach { method -> - method.apply { - val clientIdIndex = indexOfFirstInstructionOrThrow { - opcode == Opcode.CONST_STRING && getReference()?.string == "dj-xCIZQYiLbEg" - } - val clientIdRegister = getInstruction(clientIdIndex).registerA + loginActivityClientIdMethodMatch, + getLoggedInBearerTokenMethodMatch, + getLoggedOutBearerTokenMethodMatch, + getRefreshTokenMethodMatch, + ).forEach { match -> + val clientIdIndex = match.indices.first() + val clientIdRegister = match.method.getInstruction(clientIdIndex).registerA - replaceInstruction( - clientIdIndex, - "const-string v$clientIdRegister, \"$clientId\"", - ) - } + match.method.replaceInstruction(clientIdIndex, "const-string v$clientIdRegister, \"$clientId\"") } // endregion @@ -48,7 +39,7 @@ val spoofClientPatch = `Spoof client`(redirectUri = "dbrady://relay") { clientId // region Patch miscellaneous. // Do not load remote config which disables OAuth login remotely. - setRemoteConfigMethod.addInstructions(0, "return-void") + setRemoteConfigMethod.returnEarly() // Prevent OAuth login being disabled remotely. redditCheckDisableAPIMethod.apply { diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/slide/api/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/slide/api/Fingerprints.kt index d7f9f5d80..3b6304ccb 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/slide/api/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/slide/api/Fingerprints.kt @@ -7,5 +7,5 @@ import app.revanced.patcher.patch.BytecodePatchContext internal val BytecodePatchContext.getClientIdMethod by gettingFirstMutableMethodDeclaratively { name("getClientId") - definingClass { endsWith("Credentials;") } + definingClass("Credentials;"::endsWith) } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/slide/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/slide/api/SpoofClientPatch.kt index 70dec0a42..aab8fff8f 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/slide/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/slide/api/SpoofClientPatch.kt @@ -1,9 +1,9 @@ package app.revanced.patches.reddit.customclients.slide.api -import app.revanced.patches.reddit.customclients.`Spoof client` +import app.revanced.patches.reddit.customclients.spoofClientPatch import app.revanced.util.returnEarly -val spoofClientPatch = `Spoof client`(redirectUri = "http://www.ccrama.me") { clientIdOption -> +val spoofClientPatch = spoofClientPatch(redirectUri = "http://www.ccrama.me") { clientIdOption -> compatibleWith("me.ccrama.redditslide") val clientId by clientIdOption diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/DisablePiracyDetectionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/DisablePiracyDetectionPatch.kt index 6b6524eaf..17c7cb492 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/DisablePiracyDetectionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/DisablePiracyDetectionPatch.kt @@ -1,9 +1,9 @@ package app.revanced.patches.reddit.customclients.sync.detection.piracy import app.revanced.patcher.extensions.addInstruction -import app.revanced.patcher.patch.creatingBytecodePatch +import app.revanced.patcher.patch.bytecodePatch -val `Disable piracy detection` by creatingBytecodePatch( +val disablePiracyDetectionPatch = bytecodePatch( description = "Disables detection of modified versions.", ) { diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/Fingerprints.kt index df2d43249..b3cf7e98d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/Fingerprints.kt @@ -1,11 +1,10 @@ package app.revanced.patches.reddit.customclients.sync.detection.piracy +import app.revanced.patcher.* import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively -import app.revanced.patcher.accessFlags -import app.revanced.patcher.instructions -import app.revanced.patcher.invoke +import app.revanced.patcher.extensions.instructions +import app.revanced.patcher.extensions.reference import app.revanced.patcher.patch.BytecodePatchContext -import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode @@ -21,4 +20,10 @@ internal val BytecodePatchContext.piracyDetectionMethod by gettingFirstMutableMe Opcode.INVOKE_DIRECT(), Opcode.INVOKE_VIRTUAL(), ) -} + // TODO: Convert to instructions() extension. + custom { + instructions.any { + it.reference.toString() == "Lcom/github/javiersantos/piracychecker/PiracyChecker;" + } + } +} \ No newline at end of file diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforlemmy/ads/DisableAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforlemmy/ads/DisableAdsPatch.kt index ee1197a13..ca74997aa 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforlemmy/ads/DisableAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforlemmy/ads/DisableAdsPatch.kt @@ -1,11 +1,11 @@ package app.revanced.patches.reddit.customclients.sync.syncforlemmy.ads import app.revanced.patches.reddit.customclients.sync.ads.disableAdsPatch -import app.revanced.patches.reddit.customclients.sync.detection.piracy.`Disable piracy detection` +import app.revanced.patches.reddit.customclients.sync.detection.piracy.disablePiracyDetectionPatch @Suppress("unused") val disableAdsPatch = disableAdsPatch { - dependsOn(`Disable piracy detection`) + dependsOn(disablePiracyDetectionPatch) compatibleWith("com.laurencedawson.reddit_sync") } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/annoyances/startup/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/annoyances/startup/Fingerprints.kt index 91d6e12c9..f84f778bb 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/annoyances/startup/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/annoyances/startup/Fingerprints.kt @@ -6,6 +6,6 @@ import app.revanced.patcher.name import app.revanced.patcher.patch.BytecodePatchContext internal val BytecodePatchContext.mainActivityOnCreateMethod by gettingFirstMutableMethodDeclaratively { - definingClass("MainActivity;") name("onCreate") + definingClass("MainActivity;"::endsWith) } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/api/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/api/Fingerprints.kt index 1d2ff2bad..e6ccf68f2 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/api/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/api/Fingerprints.kt @@ -1,12 +1,24 @@ package app.revanced.patches.reddit.customclients.sync.syncforreddit.api -import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethod +import app.revanced.patcher.firstMethodComposite +import app.revanced.patcher.instructions +import app.revanced.patcher.invoke import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.string -internal val BytecodePatchContext.getAuthorizationStringMethod by gettingFirstMutableMethodDeclaratively("authorize.compact?client_id") +internal val getAuthorizationStringMethodMatch = firstMethodComposite { + instructions(string("authorize.compact?client_id"::startsWith)) +} -internal val BytecodePatchContext.getBearerTokenMethod by gettingFirstMutableMethodDeclaratively("Basic") +internal val getBearerTokenMethodMatch = firstMethodComposite { + instructions(string("Basic"::startsWith)) +} -internal val BytecodePatchContext.getUserAgentMethod by gettingFirstMutableMethodDeclaratively("android:com.laurencedawson.reddit_sync") +internal val BytecodePatchContext.getUserAgentMethod by gettingFirstMutableMethod( + "android:com.laurencedawson.reddit_sync" +) -internal val BytecodePatchContext.imgurImageAPIMethod by gettingFirstMutableMethodDeclaratively("https://imgur-apiv3.p.rapidapi.com/3/image") +internal val imgurImageAPIMethodMatch = firstMethodComposite { + instructions("https://imgur-apiv3.p.rapidapi.com/3/image"()) +} diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/api/SpoofClientPatch.kt index 469ca5086..0d03b7210 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/api/SpoofClientPatch.kt @@ -2,23 +2,20 @@ package app.revanced.patches.reddit.customclients.sync.syncforreddit.api import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.replaceInstruction -import app.revanced.patches.reddit.customclients.`Spoof client` -import app.revanced.patches.reddit.customclients.sync.detection.piracy.`Disable piracy detection` +import app.revanced.patcher.extensions.stringReference +import app.revanced.patches.reddit.customclients.spoofClientPatch +import app.revanced.patches.reddit.customclients.sync.detection.piracy.disablePiracyDetectionPatch import app.revanced.patches.shared.misc.string.replaceStringPatch -import app.revanced.util.getReference -import app.revanced.util.indexOfFirstInstructionOrThrow import app.revanced.util.returnEarly -import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.StringReference -import java.util.Base64 +import java.util.* @Suppress("unused") -val spoofClientPatch = `Spoof client`( +val spoofClientPatch = spoofClientPatch( redirectUri = "http://redditsync/auth", ) { clientIdOption -> dependsOn( - `Disable piracy detection`, + disablePiracyDetectionPatch, // Redirects from SSL to WWW domain are bugged causing auth problems. // Manually rewrite the URLs to fix this. replaceStringPatch("ssl.reddit.com", "www.reddit.com") @@ -35,30 +32,26 @@ val spoofClientPatch = `Spoof client`( apply { // region Patch client id. - getBearerTokenMethod.apply { + getBearerTokenMethodMatch.match(getAuthorizationStringMethodMatch.immutableClassDef).method.apply { val auth = Base64.getEncoder().encodeToString("$clientId:".toByteArray(Charsets.UTF_8)) returnEarly("Basic $auth") - } - getAuthorizationStringMethod.apply { - val occurrenceIndex = indexOfFirstInstructionOrThrow { - opcode == Opcode.CONST_STRING && - getReference()?.string?.contains("client_id=") == true + val occurrenceIndex = getAuthorizationStringMethodMatch.indices.first() + + getAuthorizationStringMethodMatch.method.apply { + val authorizationStringInstruction = getInstruction(occurrenceIndex) + val targetRegister = authorizationStringInstruction.registerA + + val newAuthorizationUrl = authorizationStringInstruction.stringReference!!.string.replace( + "client_id=.*?&".toRegex(), + "client_id=$clientId&", + ) + + replaceInstruction( + occurrenceIndex, + "const-string v$targetRegister, \"$newAuthorizationUrl\"", + ) } - - val authorizationStringInstruction = getInstruction(occurrenceIndex) - val targetRegister = authorizationStringInstruction.registerA - val reference = authorizationStringInstruction.getReference()!! - - val newAuthorizationUrl = reference.string.replace( - "client_id=.*?&".toRegex(), - "client_id=$clientId&", - ) - - replaceInstruction( - occurrenceIndex, - "const-string v$targetRegister, \"$newAuthorizationUrl\"", - ) } // endregion @@ -75,17 +68,11 @@ val spoofClientPatch = `Spoof client`( // region Patch Imgur API URL. - imgurImageAPIMethod.apply { - val apiUrlIndex = indexOfFirstInstructionOrThrow { - opcode == Opcode.CONST_STRING && - getReference()?.string == "https://api.imgur.com/3/image" - } - - replaceInstruction( - apiUrlIndex, - "const-string v1, \"https://api.imgur.com/3/image\"", - ) - } + val apiUrlIndex = imgurImageAPIMethodMatch.indices.first() + imgurImageAPIMethodMatch.method.replaceInstruction( + apiUrlIndex, + "const-string v1, \"https://api.imgur.com/3/image\"", + ) // endregion } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/redgifs/FixRedgifsApiPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/redgifs/FixRedgifsApiPatch.kt index e1ad4257d..40bbcda74 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/redgifs/FixRedgifsApiPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/redgifs/FixRedgifsApiPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patches.reddit.customclients.INSTALL_NEW_CLIENT_METHOD -import app.revanced.patches.reddit.customclients.`Fix Redgifs API` +import app.revanced.patches.reddit.customclients.fixRedgifsApi import app.revanced.patches.reddit.customclients.sync.syncforreddit.extension.sharedExtensionPatch import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow @@ -14,7 +14,7 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference internal const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/syncforreddit/FixRedgifsApiPatch;" @Suppress("unused") -val fixRedgifsApi = `Fix Redgifs API`( +val fixRedgifsApi = fixRedgifsApi( extensionPatch = sharedExtensionPatch ) { compatibleWith( diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/misc/tracking/url/SanitizeUrlQueryPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/misc/tracking/url/SanitizeUrlQueryPatch.kt index 4dbf9f444..b5b813d21 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/misc/tracking/url/SanitizeUrlQueryPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/misc/tracking/url/SanitizeUrlQueryPatch.kt @@ -2,13 +2,11 @@ package app.revanced.patches.reddit.misc.tracking.url import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.patch.bytecodePatch -import app.revanced.patches.shared.PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS -import app.revanced.patches.shared.PATCH_NAME_SANITIZE_SHARING_LINKS @Suppress("unused") val sanitizeUrlQueryPatch = bytecodePatch( - name = PATCH_NAME_SANITIZE_SHARING_LINKS, - description = PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS, + name = "Sanitize sharing links", + description = "Removes the tracking query parameters from shared links.", ) { compatibleWith("com.reddit.frontpage") diff --git a/patches/src/main/kotlin/app/revanced/patches/serviceportalbund/detection/root/RootDetectionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/serviceportalbund/detection/root/RootDetectionPatch.kt index 44728b2eb..52ac9dd7c 100644 --- a/patches/src/main/kotlin/app/revanced/patches/serviceportalbund/detection/root/RootDetectionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/serviceportalbund/detection/root/RootDetectionPatch.kt @@ -2,13 +2,11 @@ package app.revanced.patches.serviceportalbund.detection.root import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.patch.bytecodePatch -import app.revanced.patches.shared.PATCH_DESCRIPTION_REMOVE_ROOT_DETECTION -import app.revanced.patches.shared.PATCH_NAME_REMOVE_ROOT_DETECTION @Suppress("unused") val rootDetectionPatch = bytecodePatch( - name = PATCH_NAME_REMOVE_ROOT_DETECTION, - description = PATCH_DESCRIPTION_REMOVE_ROOT_DETECTION + name = "Remove root detection", + description = "Removes the check for root permissions and unlocked bootloader." ) { compatibleWith("at.gv.bka.serviceportal") diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/SharedPatchNames.kt b/patches/src/main/kotlin/app/revanced/patches/shared/SharedPatchNames.kt deleted file mode 100644 index 44f6bbca7..000000000 --- a/patches/src/main/kotlin/app/revanced/patches/shared/SharedPatchNames.kt +++ /dev/null @@ -1,16 +0,0 @@ -package app.revanced.patches.shared - -// -// Names and descriptions used by different patches implementing the same feature. -// - -internal const val PATCH_NAME_REMOVE_ROOT_DETECTION = "Remove root detection" -internal const val PATCH_DESCRIPTION_REMOVE_ROOT_DETECTION = "Removes the check for root permissions and unlocked bootloader." - -internal const val PATCH_NAME_SANITIZE_SHARING_LINKS = "Sanitize sharing links" -internal const val PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS = "Removes the tracking query parameters from shared links." - -internal const val PATCH_NAME_CHANGE_LINK_SHARING_DOMAIN = "Change link sharing domain" -internal const val PATCH_DESCRIPTION_CHANGE_LINK_SHARING_DOMAIN = "Replaces the domain name of shared links." - -internal const val PATCH_NAME_HIDE_NAVIGATION_BUTTONS = "Hide navigation buttons" diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/privacy/SanitizeSharingLinksPatch.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/privacy/SanitizeSharingLinksPatch.kt index df32f9e37..40d738a48 100644 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/privacy/SanitizeSharingLinksPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/shared/misc/privacy/SanitizeSharingLinksPatch.kt @@ -8,8 +8,6 @@ import app.revanced.patcher.patch.BytecodePatchContext import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.all.misc.resources.addResources import app.revanced.patches.all.misc.resources.addResourcesPatch -import app.revanced.patches.shared.PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS -import app.revanced.patches.shared.PATCH_NAME_SANITIZE_SHARING_LINKS import app.revanced.patches.shared.misc.settings.preference.BasePreferenceScreen import app.revanced.patches.shared.misc.settings.preference.PreferenceCategory import app.revanced.patches.shared.misc.settings.preference.PreferenceScreenPreference.Sorting @@ -30,8 +28,8 @@ internal fun sanitizeSharingLinksPatch( preferenceScreen: BasePreferenceScreen.Screen, replaceMusicLinksWithYouTube: Boolean = false ) = bytecodePatch( - name = PATCH_NAME_SANITIZE_SHARING_LINKS, - description = PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS, + name = "Sanitize sharing links", + description = "Removes the tracking query parameters from shared links.", ) { block() diff --git a/patches/src/main/kotlin/app/revanced/patches/spotify/misc/privacy/SanitizeSharingLinksPatch.kt b/patches/src/main/kotlin/app/revanced/patches/spotify/misc/privacy/SanitizeSharingLinksPatch.kt index 2a0a24906..2a2c65377 100644 --- a/patches/src/main/kotlin/app/revanced/patches/spotify/misc/privacy/SanitizeSharingLinksPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/spotify/misc/privacy/SanitizeSharingLinksPatch.kt @@ -3,8 +3,6 @@ package app.revanced.patches.spotify.misc.privacy import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.patch.bytecodePatch -import app.revanced.patches.shared.PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS -import app.revanced.patches.shared.PATCH_NAME_SANITIZE_SHARING_LINKS import app.revanced.patches.spotify.misc.extension.sharedExtensionPatch import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow @@ -17,8 +15,8 @@ private const val EXTENSION_CLASS_DESCRIPTOR = @Suppress("unused") val sanitizeSharingLinksPatch = bytecodePatch( - name = PATCH_NAME_SANITIZE_SHARING_LINKS, - description = PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS, + name = "Sanitize sharing links", + description = "Removes the tracking query parameters from shared links.", ) { compatibleWith("com.spotify.music") diff --git a/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/share/SanitizeShareUrlsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/share/SanitizeShareUrlsPatch.kt index ac9fa4003..dbe1537e5 100644 --- a/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/share/SanitizeShareUrlsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/share/SanitizeShareUrlsPatch.kt @@ -1,11 +1,8 @@ package app.revanced.patches.tiktok.misc.share -import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.addInstructionsWithLabels import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.patch.bytecodePatch -import app.revanced.patches.shared.PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS -import app.revanced.patches.shared.PATCH_NAME_SANITIZE_SHARING_LINKS import app.revanced.patches.tiktok.misc.extension.sharedExtensionPatch import app.revanced.util.findFreeRegister import app.revanced.util.getReference @@ -20,8 +17,8 @@ private const val EXTENSION_CLASS_DESCRIPTOR = @Suppress("unused") val sanitizeShareUrlsPatch = bytecodePatch( - name = PATCH_NAME_SANITIZE_SHARING_LINKS, - description = PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS, + name = "Sanitize sharing links", + description = "Removes the tracking query parameters from shared links.", ) { dependsOn(sharedExtensionPatch) diff --git a/patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/ChangeLinkSharingDomainPatch.kt b/patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/ChangeLinkSharingDomainPatch.kt index a5a1bad05..4ece6e636 100644 --- a/patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/ChangeLinkSharingDomainPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/ChangeLinkSharingDomainPatch.kt @@ -5,8 +5,6 @@ import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patcher.patch.bytecodePatch import app.revanced.patcher.patch.stringOption -import app.revanced.patches.shared.PATCH_DESCRIPTION_CHANGE_LINK_SHARING_DOMAIN -import app.revanced.patches.shared.PATCH_NAME_CHANGE_LINK_SHARING_DOMAIN import app.revanced.patches.twitter.misc.extension.sharedExtensionPatch import app.revanced.util.indexOfFirstInstructionOrThrow import app.revanced.util.returnEarly @@ -62,8 +60,8 @@ internal val changeLinkSharingDomainResourcePatch = resourcePatch { @Suppress("unused") val changeLinkSharingDomainPatch = bytecodePatch( - name = PATCH_NAME_CHANGE_LINK_SHARING_DOMAIN, - description = "$PATCH_DESCRIPTION_CHANGE_LINK_SHARING_DOMAIN Including this patch can prevent making posts that quote other posts.", + name = "Change link sharing domain", + description = "Replaces the domain name of shared links. Using this patch can prevent making posts that quote other posts.", use = false ) { dependsOn( diff --git a/patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/SanitizeSharingLinksPatch.kt b/patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/SanitizeSharingLinksPatch.kt index c8267a107..90a78eb7f 100644 --- a/patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/SanitizeSharingLinksPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/SanitizeSharingLinksPatch.kt @@ -2,13 +2,11 @@ package app.revanced.patches.twitter.misc.links import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.patch.bytecodePatch -import app.revanced.patches.shared.PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS -import app.revanced.patches.shared.PATCH_NAME_SANITIZE_SHARING_LINKS @Suppress("unused") val sanitizeSharingLinksPatch = bytecodePatch( - name = PATCH_NAME_SANITIZE_SHARING_LINKS, - description = PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS, + name = "Sanitize sharing links", + description = "Removes the tracking query parameters from shared links.", ) { compatibleWith( "com.twitter.android"( diff --git a/patches/src/main/kotlin/app/revanced/patches/viber/misc/navbar/HideNavigationButtons.kt b/patches/src/main/kotlin/app/revanced/patches/viber/misc/navbar/HideNavigationButtons.kt index 0bc25e4be..030001b5b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/viber/misc/navbar/HideNavigationButtons.kt +++ b/patches/src/main/kotlin/app/revanced/patches/viber/misc/navbar/HideNavigationButtons.kt @@ -3,12 +3,11 @@ package app.revanced.patches.viber.misc.navbar import app.revanced.patcher.extensions.addInstructionsWithLabels import app.revanced.patcher.patch.booleanOption import app.revanced.patcher.patch.bytecodePatch -import app.revanced.patches.shared.PATCH_NAME_HIDE_NAVIGATION_BUTTONS import java.util.logging.Logger @Suppress("unused") val hideNavigationButtonsPatch = bytecodePatch( - name = PATCH_NAME_HIDE_NAVIGATION_BUTTONS, + name = "Hide navigation buttons", description = "Permanently hides navigation bar buttons, such as Explore and Marketplace.", use = false ) { From 5a15476a9f96c4ef0e70b0ab51b98851d1c37e62 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Wed, 14 Jan 2026 02:31:53 +0100 Subject: [PATCH 54/55] fix names --- .../finanzonline/detection/root/RootDetectionPatch.kt | 7 +++---- .../instagram/hide/navigation/HideNavigationButtons.kt | 9 ++++----- .../misc/share/privacy/SanitizeSharingLinksPatch.kt | 7 +++---- .../patches/pandora/misc/EnableUnlimitedSkipsPatch.kt | 2 +- .../photomath/detection/deviceid/SpoofDeviceIdPatch.kt | 4 ++-- .../detection/signature/SignatureDetectionPatch.kt | 6 +++--- .../photomath/misc/annoyances/HideUpdatePopupPatch.kt | 4 ++-- .../photomath/misc/unlock/plus/UnlockPlusPatch.kt | 4 ++-- .../patches/reddit/ad/comments/HideCommentAdsPatch.kt | 5 ++--- .../revanced/patches/reddit/ad/general/HideAdsPatch.kt | 4 ++-- .../patches/reddit/customclients/FixRedgifsApiPatch.kt | 2 +- .../patches/reddit/customclients/FixSLinksPatch.kt | 4 +--- .../baconreader/fix/redgifs/FixRedgifsApiPatch.kt | 4 ++-- .../boostforreddit/fix/redgifs/FixRedgifsApiPatch.kt | 4 ++-- .../customclients/joeyforreddit/ads/DisableAdsPatch.kt | 4 ++-- .../detection/piracy/DisablePiracyDetectionPatch.kt | 6 +++--- .../sync/syncforreddit/fix/redgifs/FixRedgifsApiPatch.kt | 4 ++-- .../reddit/misc/tracking/url/SanitizeUrlQueryPatch.kt | 7 +++---- .../detection/root/RootDetectionPatch.kt | 7 +++---- .../spotify/misc/privacy/SanitizeSharingLinksPatch.kt | 6 +++--- .../patches/tiktok/misc/share/SanitizeShareUrlsPatch.kt | 7 +++---- .../twitter/misc/links/SanitizeSharingLinksPatch.kt | 7 +++---- .../patches/viber/misc/navbar/HideNavigationButtons.kt | 7 +++---- 23 files changed, 55 insertions(+), 66 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/RootDetectionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/RootDetectionPatch.kt index 49bacecbd..e40358388 100644 --- a/patches/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/RootDetectionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/RootDetectionPatch.kt @@ -1,11 +1,10 @@ package app.revanced.patches.finanzonline.detection.root import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch -@Suppress("unused") -val rootDetectionPatch = bytecodePatch( - name = "Remove root detection", +@Suppress("unused", "ObjectPropertyName") +val `Remove root detection` by creatingBytecodePatch( description = "Removes the check for root permissions and unlocked bootloader.", ) { compatibleWith("at.gv.bmf.bmf2go") diff --git a/patches/src/main/kotlin/app/revanced/patches/instagram/hide/navigation/HideNavigationButtons.kt b/patches/src/main/kotlin/app/revanced/patches/instagram/hide/navigation/HideNavigationButtons.kt index 7b7b54821..95ca430fe 100644 --- a/patches/src/main/kotlin/app/revanced/patches/instagram/hide/navigation/HideNavigationButtons.kt +++ b/patches/src/main/kotlin/app/revanced/patches/instagram/hide/navigation/HideNavigationButtons.kt @@ -3,7 +3,7 @@ package app.revanced.patches.instagram.hide.navigation import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.fingerprint import app.revanced.patcher.patch.booleanOption -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.patches.instagram.misc.extension.sharedExtensionPatch import app.revanced.util.addInstructionsAtControlFlowLabel import app.revanced.util.findFreeRegister @@ -18,9 +18,8 @@ import java.util.logging.Logger private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/instagram/hide/navigation/HideNavigationButtonsPatch;" -@Suppress("unused") -val hideNavigationButtonsPatch = bytecodePatch( - name = "Hide navigation buttons", +@Suppress("unused", "ObjectPropertyName") +val `Hide navigation buttons` by creatingBytecodePatch( description = "Hides navigation bar buttons, such as the Reels and Create button.", use = false ) { @@ -65,7 +64,7 @@ val hideNavigationButtonsPatch = bytecodePatch( ) apply { - if (!hideHome!! &&!hideReels!! && !hideDirect!! && !hideSearch!! && !hideProfile!! && !hideCreate!!) { + if (!hideHome!! && !hideReels!! && !hideDirect!! && !hideSearch!! && !hideProfile!! && !hideCreate!!) { return@apply Logger.getLogger(this::class.java.name).warning( "No hide navigation buttons options are enabled. No changes made." ) diff --git a/patches/src/main/kotlin/app/revanced/patches/instagram/misc/share/privacy/SanitizeSharingLinksPatch.kt b/patches/src/main/kotlin/app/revanced/patches/instagram/misc/share/privacy/SanitizeSharingLinksPatch.kt index 9e9095c73..89072d0db 100644 --- a/patches/src/main/kotlin/app/revanced/patches/instagram/misc/share/privacy/SanitizeSharingLinksPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/instagram/misc/share/privacy/SanitizeSharingLinksPatch.kt @@ -1,16 +1,15 @@ package app.revanced.patches.instagram.misc.share.privacy import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.patches.instagram.misc.extension.sharedExtensionPatch import app.revanced.patches.instagram.misc.share.editShareLinksPatch private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/instagram/misc/share/privacy/SanitizeSharingLinksPatch;" -@Suppress("unused") -val sanitizeSharingLinksPatch = bytecodePatch( - name = "Sanitize sharing links", +@Suppress("unused", "ObjectPropertyName") +val `Sanitize sharing links` by creatingBytecodePatch( description = "Removes the tracking query parameters from shared links.", ) { compatibleWith("com.instagram.android") diff --git a/patches/src/main/kotlin/app/revanced/patches/pandora/misc/EnableUnlimitedSkipsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/pandora/misc/EnableUnlimitedSkipsPatch.kt index 395dd2d8a..2d60302e9 100644 --- a/patches/src/main/kotlin/app/revanced/patches/pandora/misc/EnableUnlimitedSkipsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/pandora/misc/EnableUnlimitedSkipsPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.util.returnEarly @Suppress("unused", "ObjectPropertyName") -val `Enable Unlimited Skips` by creatingBytecodePatch { +val `Enable unlimited skips` by creatingBytecodePatch { compatibleWith("com.pandora.android") apply { diff --git a/patches/src/main/kotlin/app/revanced/patches/photomath/detection/deviceid/SpoofDeviceIdPatch.kt b/patches/src/main/kotlin/app/revanced/patches/photomath/detection/deviceid/SpoofDeviceIdPatch.kt index 303517a70..8e955ed28 100644 --- a/patches/src/main/kotlin/app/revanced/patches/photomath/detection/deviceid/SpoofDeviceIdPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/photomath/detection/deviceid/SpoofDeviceIdPatch.kt @@ -1,7 +1,7 @@ package app.revanced.patches.photomath.detection.deviceid import app.revanced.patcher.patch.creatingBytecodePatch -import app.revanced.patches.photomath.detection.signature.`Signature detection` +import app.revanced.patches.photomath.detection.signature.signatureDetectionPatch import app.revanced.util.returnEarly import kotlin.random.Random @@ -9,7 +9,7 @@ import kotlin.random.Random val `Spoof device ID` by creatingBytecodePatch( description = "Spoofs device ID to mitigate manual bans by developers.", ) { - dependsOn(`Signature detection`) + dependsOn(signatureDetectionPatch) compatibleWith("com.microblink.photomath") diff --git a/patches/src/main/kotlin/app/revanced/patches/photomath/detection/signature/SignatureDetectionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/photomath/detection/signature/SignatureDetectionPatch.kt index 70d6331e6..5114f034f 100644 --- a/patches/src/main/kotlin/app/revanced/patches/photomath/detection/signature/SignatureDetectionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/photomath/detection/signature/SignatureDetectionPatch.kt @@ -2,11 +2,11 @@ package app.revanced.patches.photomath.detection.signature import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.replaceInstruction -import app.revanced.patcher.patch.creatingBytecodePatch +import app.revanced.patcher.patch.bytecodePatch import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -@Suppress("unused", "ObjectPropertyName") -val `Signature detection` by creatingBytecodePatch( +@Suppress("unused") +val signatureDetectionPatch = bytecodePatch( description = "Disables detection of incorrect signature.", ) { apply { diff --git a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/annoyances/HideUpdatePopupPatch.kt b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/annoyances/HideUpdatePopupPatch.kt index 88678aa3c..269a79ec7 100644 --- a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/annoyances/HideUpdatePopupPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/annoyances/HideUpdatePopupPatch.kt @@ -2,14 +2,14 @@ package app.revanced.patches.photomath.misc.annoyances import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.patch.creatingBytecodePatch -import app.revanced.patches.photomath.detection.signature.`Signature detection` +import app.revanced.patches.photomath.detection.signature.signatureDetectionPatch @Suppress("unused") val `Hide update popup` by creatingBytecodePatch( description = "Prevents the update popup from showing up.", ) { - dependsOn(`Signature detection`) + dependsOn(signatureDetectionPatch) compatibleWith("com.microblink.photomath") diff --git a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/UnlockPlusPatch.kt b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/UnlockPlusPatch.kt index ac5b87517..77d32d815 100644 --- a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/UnlockPlusPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/UnlockPlusPatch.kt @@ -2,12 +2,12 @@ package app.revanced.patches.photomath.misc.unlock.plus import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.patch.creatingBytecodePatch -import app.revanced.patches.photomath.detection.signature.`Signature detection` +import app.revanced.patches.photomath.detection.signature.signatureDetectionPatch import app.revanced.patches.photomath.misc.unlock.bookpoint.enableBookpointPatch @Suppress("unused") val `Unlock plus` by creatingBytecodePatch { - dependsOn(`Signature detection`, enableBookpointPatch) + dependsOn(signatureDetectionPatch, enableBookpointPatch) compatibleWith("com.microblink.photomath") diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/ad/comments/HideCommentAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/ad/comments/HideCommentAdsPatch.kt index 0a19d4146..9ebbf78ba 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/ad/comments/HideCommentAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/ad/comments/HideCommentAdsPatch.kt @@ -2,10 +2,9 @@ package app.revanced.patches.reddit.ad.comments import app.revanced.patcher.extensions.replaceInstructions import app.revanced.patcher.patch.bytecodePatch -import app.revanced.patcher.patch.creatingBytecodePatch -@Suppress("unused", "ObjectPropertyName") -val `Hide comment ads` by creatingBytecodePatch( +@Suppress("unused") +val hideCommentAdsPatch = bytecodePatch( description = "Removes ads in the comments." ) { diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/ad/general/HideAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/ad/general/HideAdsPatch.kt index 84d0fa250..73509f543 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/ad/general/HideAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/ad/general/HideAdsPatch.kt @@ -3,7 +3,7 @@ package app.revanced.patches.reddit.ad.general import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.removeInstruction import app.revanced.patcher.patch.creatingBytecodePatch -import app.revanced.patches.reddit.ad.comments.`Hide comment ads` +import app.revanced.patches.reddit.ad.comments.hideCommentAdsPatch import app.revanced.patches.reddit.misc.extension.sharedExtensionPatch import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstruction @@ -15,7 +15,7 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference @Suppress("unused", "ObjectPropertyName") val `Hide ads` by creatingBytecodePatch { - dependsOn(`Hide comment ads`, sharedExtensionPatch) + dependsOn(hideCommentAdsPatch, sharedExtensionPatch) compatibleWith("com.reddit.frontpage") diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/FixRedgifsApiPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/FixRedgifsApiPatch.kt index f83711051..fabb9b9b0 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/FixRedgifsApiPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/FixRedgifsApiPatch.kt @@ -7,7 +7,7 @@ import app.revanced.patcher.patch.bytecodePatch const val INSTALL_NEW_CLIENT_METHOD = "install(Lokhttp3/OkHttpClient${'$'}Builder;)Lokhttp3/OkHttpClient;" const val CREATE_NEW_CLIENT_METHOD = "createClient()Lokhttp3/OkHttpClient;" -fun fixRedgifsApi( +fun fixRedgifsApiPatch( extensionPatch: Patch, block: BytecodePatchBuilder.() -> Unit = {}, ) = bytecodePatch("Fix Redgifs API") { diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/FixSLinksPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/FixSLinksPatch.kt index 3b8d63251..106e1ba23 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/FixSLinksPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/FixSLinksPatch.kt @@ -10,9 +10,7 @@ const val SET_ACCESS_TOKEN_METHOD = "patchSetAccessToken(Ljava/lang/String;)V" fun fixSLinksPatch( extensionPatch: Patch, block: BytecodePatchBuilder.() -> Unit = {}, -) = bytecodePatch( - "Fix /s/ links", -) { +) = bytecodePatch("Fix /s/ links") { dependsOn(extensionPatch) block() diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/fix/redgifs/FixRedgifsApiPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/fix/redgifs/FixRedgifsApiPatch.kt index 74f206c38..2ffc07ecd 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/fix/redgifs/FixRedgifsApiPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/fix/redgifs/FixRedgifsApiPatch.kt @@ -3,7 +3,7 @@ package app.revanced.patches.reddit.customclients.baconreader.fix.redgifs import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.removeInstructions import app.revanced.patcher.extensions.replaceInstruction -import app.revanced.patches.reddit.customclients.fixRedgifsApi +import app.revanced.patches.reddit.customclients.fixRedgifsApiPatch import app.revanced.patches.reddit.customclients.INSTALL_NEW_CLIENT_METHOD import app.revanced.patches.reddit.customclients.baconreader.misc.extension.sharedExtensionPatch import app.revanced.util.getReference @@ -16,7 +16,7 @@ import com.android.tools.smali.dexlib2.iface.reference.TypeReference internal const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/baconreader/FixRedgifsApiPatch;" @Suppress("unused") -val fixRedgifsApi = fixRedgifsApi( +val fixRedgifsApi = fixRedgifsApiPatch( extensionPatch = sharedExtensionPatch ) { compatibleWith( diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/redgifs/FixRedgifsApiPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/redgifs/FixRedgifsApiPatch.kt index a9abcacff..ec5b904c8 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/redgifs/FixRedgifsApiPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/redgifs/FixRedgifsApiPatch.kt @@ -3,14 +3,14 @@ package app.revanced.patches.reddit.customclients.boostforreddit.fix.redgifs import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patches.reddit.customclients.CREATE_NEW_CLIENT_METHOD -import app.revanced.patches.reddit.customclients.fixRedgifsApi +import app.revanced.patches.reddit.customclients.fixRedgifsApiPatch import app.revanced.patches.reddit.customclients.boostforreddit.misc.extension.sharedExtensionPatch import app.revanced.util.indexOfFirstInstructionOrThrow private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/boostforreddit/FixRedgifsApiPatch;" @Suppress("unused") -val fixRedgifsApi = fixRedgifsApi( +val fixRedgifsApi = fixRedgifsApiPatch( extensionPatch = sharedExtensionPatch ) { compatibleWith("com.rubenmayayo.reddit") diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/DisableAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/DisableAdsPatch.kt index b95f72fbe..ef8a73e51 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/DisableAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/DisableAdsPatch.kt @@ -1,12 +1,12 @@ package app.revanced.patches.reddit.customclients.joeyforreddit.ads import app.revanced.patcher.patch.creatingBytecodePatch -import app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.`Disable piracy detection` +import app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.disablePiracyDetectionPatch import app.revanced.util.returnEarly @Suppress("unused", "ObjectPropertyName") val `Disable ads` by creatingBytecodePatch { - dependsOn(`Disable piracy detection`) + dependsOn(disablePiracyDetectionPatch) compatibleWith("o.o.joey") diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/DisablePiracyDetectionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/DisablePiracyDetectionPatch.kt index 5ad24d59f..85a9ed8d1 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/DisablePiracyDetectionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/DisablePiracyDetectionPatch.kt @@ -1,10 +1,10 @@ package app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy import app.revanced.patcher.extensions.addInstruction -import app.revanced.patcher.patch.creatingBytecodePatch +import app.revanced.patcher.patch.bytecodePatch -@Suppress("unused", "ObjectPropertyName") -val `Disable piracy detection` by creatingBytecodePatch { +@Suppress("unused") +val disablePiracyDetectionPatch = bytecodePatch { apply { piracyDetectionMethod.addInstruction(0, "return-void") } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/redgifs/FixRedgifsApiPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/redgifs/FixRedgifsApiPatch.kt index 40bbcda74..9d6454198 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/redgifs/FixRedgifsApiPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/redgifs/FixRedgifsApiPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patches.reddit.customclients.INSTALL_NEW_CLIENT_METHOD -import app.revanced.patches.reddit.customclients.fixRedgifsApi +import app.revanced.patches.reddit.customclients.fixRedgifsApiPatch import app.revanced.patches.reddit.customclients.sync.syncforreddit.extension.sharedExtensionPatch import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow @@ -14,7 +14,7 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference internal const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/syncforreddit/FixRedgifsApiPatch;" @Suppress("unused") -val fixRedgifsApi = fixRedgifsApi( +val fixRedgifsApi = fixRedgifsApiPatch( extensionPatch = sharedExtensionPatch ) { compatibleWith( diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/misc/tracking/url/SanitizeUrlQueryPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/misc/tracking/url/SanitizeUrlQueryPatch.kt index b5b813d21..30c444ae7 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/misc/tracking/url/SanitizeUrlQueryPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/misc/tracking/url/SanitizeUrlQueryPatch.kt @@ -1,11 +1,10 @@ package app.revanced.patches.reddit.misc.tracking.url import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch -@Suppress("unused") -val sanitizeUrlQueryPatch = bytecodePatch( - name = "Sanitize sharing links", +@Suppress("unused", "ObjectPropertyName") +val `Sanitize sharing links` by creatingBytecodePatch( description = "Removes the tracking query parameters from shared links.", ) { compatibleWith("com.reddit.frontpage") diff --git a/patches/src/main/kotlin/app/revanced/patches/serviceportalbund/detection/root/RootDetectionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/serviceportalbund/detection/root/RootDetectionPatch.kt index 52ac9dd7c..62d1bb81b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/serviceportalbund/detection/root/RootDetectionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/serviceportalbund/detection/root/RootDetectionPatch.kt @@ -1,11 +1,10 @@ package app.revanced.patches.serviceportalbund.detection.root import app.revanced.patcher.extensions.addInstruction -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch -@Suppress("unused") -val rootDetectionPatch = bytecodePatch( - name = "Remove root detection", +@Suppress("unused", "ObjectPropertyName") +val `Remove root detection` by creatingBytecodePatch( description = "Removes the check for root permissions and unlocked bootloader." ) { compatibleWith("at.gv.bka.serviceportal") diff --git a/patches/src/main/kotlin/app/revanced/patches/spotify/misc/privacy/SanitizeSharingLinksPatch.kt b/patches/src/main/kotlin/app/revanced/patches/spotify/misc/privacy/SanitizeSharingLinksPatch.kt index 2a2c65377..c7057a69d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/spotify/misc/privacy/SanitizeSharingLinksPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/spotify/misc/privacy/SanitizeSharingLinksPatch.kt @@ -3,6 +3,7 @@ package app.revanced.patches.spotify.misc.privacy import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.patches.spotify.misc.extension.sharedExtensionPatch import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow @@ -13,9 +14,8 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/spotify/misc/privacy/SanitizeSharingLinksPatch;" -@Suppress("unused") -val sanitizeSharingLinksPatch = bytecodePatch( - name = "Sanitize sharing links", +@Suppress("unused", "ObjectPropertyName") +val `Sanitize sharing links` by creatingBytecodePatch( description = "Removes the tracking query parameters from shared links.", ) { compatibleWith("com.spotify.music") diff --git a/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/share/SanitizeShareUrlsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/share/SanitizeShareUrlsPatch.kt index dbe1537e5..6e5612a9d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/share/SanitizeShareUrlsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/share/SanitizeShareUrlsPatch.kt @@ -2,7 +2,7 @@ package app.revanced.patches.tiktok.misc.share import app.revanced.patcher.extensions.addInstructionsWithLabels import app.revanced.patcher.extensions.getInstruction -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.patches.tiktok.misc.extension.sharedExtensionPatch import app.revanced.util.findFreeRegister import app.revanced.util.getReference @@ -15,9 +15,8 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/tiktok/share/ShareUrlSanitizer;" -@Suppress("unused") -val sanitizeShareUrlsPatch = bytecodePatch( - name = "Sanitize sharing links", +@Suppress("unused", "ObjectPropertyName") +val `Sanitize sharing links` by creatingBytecodePatch( description = "Removes the tracking query parameters from shared links.", ) { dependsOn(sharedExtensionPatch) diff --git a/patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/SanitizeSharingLinksPatch.kt b/patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/SanitizeSharingLinksPatch.kt index 90a78eb7f..6ca6e5142 100644 --- a/patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/SanitizeSharingLinksPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/SanitizeSharingLinksPatch.kt @@ -1,11 +1,10 @@ package app.revanced.patches.twitter.misc.links import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch -@Suppress("unused") -val sanitizeSharingLinksPatch = bytecodePatch( - name = "Sanitize sharing links", +@Suppress("unused", "ObjectPropertyName") +val `Sanitize sharing links` by creatingBytecodePatch( description = "Removes the tracking query parameters from shared links.", ) { compatibleWith( diff --git a/patches/src/main/kotlin/app/revanced/patches/viber/misc/navbar/HideNavigationButtons.kt b/patches/src/main/kotlin/app/revanced/patches/viber/misc/navbar/HideNavigationButtons.kt index 030001b5b..b64e63fb4 100644 --- a/patches/src/main/kotlin/app/revanced/patches/viber/misc/navbar/HideNavigationButtons.kt +++ b/patches/src/main/kotlin/app/revanced/patches/viber/misc/navbar/HideNavigationButtons.kt @@ -2,12 +2,11 @@ package app.revanced.patches.viber.misc.navbar import app.revanced.patcher.extensions.addInstructionsWithLabels import app.revanced.patcher.patch.booleanOption -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch import java.util.logging.Logger -@Suppress("unused") -val hideNavigationButtonsPatch = bytecodePatch( - name = "Hide navigation buttons", +@Suppress("unused", "ObjectPropertyName") +val `Hide navigation buttons` by creatingBytecodePatch( description = "Permanently hides navigation bar buttons, such as Explore and Marketplace.", use = false ) { From e7d2d7d62baa0611ea0932942805bee237cecc41 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sat, 17 Jan 2026 18:27:26 +0100 Subject: [PATCH 55/55] some more fixes --- .../patches/pandora/ads/DisableAudioAdsPatch.kt | 4 +--- .../infinityforreddit/subscription/Fingerprints.kt | 2 +- .../detection/piracy/DisablePiracyDetectionPatch.kt | 4 ++-- .../joeyforreddit/detection/piracy/Fingerprints.kt | 8 ++++++-- .../detection/piracy/DisablePiracyDetectionPatch.kt | 4 ++-- .../sync/detection/piracy/Fingerprints.kt | 10 +++++++--- .../startup/DisableSyncForLemmyBottomSheetPatch.kt | 7 +++---- 7 files changed, 22 insertions(+), 17 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/pandora/ads/DisableAudioAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/pandora/ads/DisableAudioAdsPatch.kt index 8c92c7421..cb038a579 100644 --- a/patches/src/main/kotlin/app/revanced/patches/pandora/ads/DisableAudioAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/pandora/ads/DisableAudioAdsPatch.kt @@ -4,9 +4,7 @@ import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.util.returnEarly @Suppress("unused", "ObjectPropertyName") -val `Disable Audio Ads` by creatingBytecodePatch( - description = "Disable audio ads" -) { +val `Disable Audio Ads` by creatingBytecodePatch { compatibleWith("com.pandora.android") apply { diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/Fingerprints.kt index 8bfa18fec..49e7e6c70 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/Fingerprints.kt @@ -2,8 +2,8 @@ package app.revanced.patches.reddit.customclients.infinityforreddit.subscription import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethod import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.InstructionMatchingFunctions.invoke import app.revanced.patcher.instructions -import app.revanced.patcher.invoke import app.revanced.patcher.patch.BytecodePatchContext internal val BytecodePatchContext.billingClientOnServiceConnectedMethod by gettingFirstMutableMethod("Billing service connected") diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/DisablePiracyDetectionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/DisablePiracyDetectionPatch.kt index 85a9ed8d1..d037f1895 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/DisablePiracyDetectionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/DisablePiracyDetectionPatch.kt @@ -1,11 +1,11 @@ package app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy -import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.patch.bytecodePatch +import app.revanced.util.returnEarly @Suppress("unused") val disablePiracyDetectionPatch = bytecodePatch { apply { - piracyDetectionMethod.addInstruction(0, "return-void") + detectPiracyMethod.returnEarly() } } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/Fingerprints.kt index d64d1e195..b2688168e 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/Fingerprints.kt @@ -1,12 +1,16 @@ package app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy -import app.revanced.patcher.* import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.InstructionMatchingFunctions.invoke +import app.revanced.patcher.accessFlags +import app.revanced.patcher.definingClass +import app.revanced.patcher.instructions import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode -internal val BytecodePatchContext.piracyDetectionMethod by gettingFirstMutableMethodDeclaratively { +internal val BytecodePatchContext.detectPiracyMethod by gettingFirstMutableMethodDeclaratively { accessFlags(AccessFlags.PRIVATE, AccessFlags.STATIC) returnType("V") instructions( diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/DisablePiracyDetectionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/DisablePiracyDetectionPatch.kt index 17c7cb492..bd90bd127 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/DisablePiracyDetectionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/DisablePiracyDetectionPatch.kt @@ -1,7 +1,7 @@ package app.revanced.patches.reddit.customclients.sync.detection.piracy -import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.patch.bytecodePatch +import app.revanced.util.returnEarly val disablePiracyDetectionPatch = bytecodePatch( description = "Disables detection of modified versions.", @@ -10,6 +10,6 @@ val disablePiracyDetectionPatch = bytecodePatch( apply { // Do not throw an error if the fingerprint is not resolved. // This is fine because new versions of the target app do not need this patch. - piracyDetectionMethod.addInstruction(0, "return-void") + detectPiracyMethodOrNull?.returnEarly() } } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/Fingerprints.kt index b3cf7e98d..34a2aba72 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/Fingerprints.kt @@ -1,14 +1,18 @@ package app.revanced.patches.reddit.customclients.sync.detection.piracy -import app.revanced.patcher.* -import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclarativelyOrNull +import app.revanced.patcher.InstructionMatchingFunctions.invoke +import app.revanced.patcher.accessFlags +import app.revanced.patcher.custom import app.revanced.patcher.extensions.instructions import app.revanced.patcher.extensions.reference +import app.revanced.patcher.instructions import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode -internal val BytecodePatchContext.piracyDetectionMethod by gettingFirstMutableMethodDeclaratively( +internal val BytecodePatchContext.detectPiracyMethodOrNull by gettingFirstMutableMethodDeclarativelyOrNull( "Lcom/github/javiersantos/piracychecker/PiracyChecker;" ) { accessFlags(AccessFlags.PRIVATE, AccessFlags.FINAL) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/annoyances/startup/DisableSyncForLemmyBottomSheetPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/annoyances/startup/DisableSyncForLemmyBottomSheetPatch.kt index a3ebe101a..cd43c2374 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/annoyances/startup/DisableSyncForLemmyBottomSheetPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/annoyances/startup/DisableSyncForLemmyBottomSheetPatch.kt @@ -1,5 +1,6 @@ package app.revanced.patches.reddit.customclients.sync.syncforreddit.annoyances.startup +import app.revanced.patcher.extensions.instructions import app.revanced.patcher.extensions.removeInstruction import app.revanced.patcher.patch.creatingBytecodePatch @@ -14,10 +15,8 @@ val `Disable Sync for Lemmy bottom sheet` = creatingBytecodePatch( ) apply { - mainActivityOnCreateMethod.apply { - val showBottomSheetIndex = implementation!!.instructions.lastIndex - 1 + val showBottomSheetIndex = mainActivityOnCreateMethod.instructions.lastIndex - 1 - removeInstruction(showBottomSheetIndex) - } + mainActivityOnCreateMethod.removeInstruction(showBottomSheetIndex) } }