diff --git a/src/main/kotlin/app/revanced/patches/twitch/ad/audio/annotations/AudioAdsCompatibility.kt b/src/main/kotlin/app/revanced/patches/twitch/ad/audio/annotations/AudioAdsCompatibility.kt index 042c4c1d53..b0b80ec497 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/ad/audio/annotations/AudioAdsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/ad/audio/annotations/AudioAdsCompatibility.kt @@ -3,20 +3,7 @@ package app.revanced.patches.twitch.ad.audio.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility( - [ - Package( - "tv.twitch.android.app", arrayOf( - "14.3.3", - "14.4.0", - "14.5.0", - "14.5.2", - "14.6.0", - "14.6.1" - ) - ) - ] -) +@Compatibility([Package("tv.twitch.android.app", arrayOf("15.4.1"))]) @Target(AnnotationTarget.CLASS) internal annotation class AudioAdsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/annotations/EmbeddedAdsCompatibility.kt b/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/annotations/EmbeddedAdsCompatibility.kt index 6f86e64113..95a60c5b45 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/annotations/EmbeddedAdsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/annotations/EmbeddedAdsCompatibility.kt @@ -3,20 +3,7 @@ package app.revanced.patches.twitch.ad.embedded.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility( - [ - Package( - "tv.twitch.android.app", arrayOf( - "14.3.3", - "14.4.0", - "14.5.0", - "14.5.2", - "14.6.0", - "14.6.1" - ) - ) - ] -) +@Compatibility([Package("tv.twitch.android.app", arrayOf("15.4.1"))]) @Target(AnnotationTarget.CLASS) internal annotation class EmbeddedAdsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/twitch/ad/video/annotations/VideoAdsCompatibility.kt b/src/main/kotlin/app/revanced/patches/twitch/ad/video/annotations/VideoAdsCompatibility.kt index 8bda487dbc..a8d1f45825 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/ad/video/annotations/VideoAdsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/ad/video/annotations/VideoAdsCompatibility.kt @@ -3,20 +3,7 @@ package app.revanced.patches.twitch.ad.video.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility( - [ - Package( - "tv.twitch.android.app", arrayOf( - "14.3.3", - "14.4.0", - "14.5.0", - "14.5.2", - "14.6.0", - "14.6.1" - ) - ) - ] -) +@Compatibility([Package("tv.twitch.android.app", arrayOf("15.4.1"))]) @Target(AnnotationTarget.CLASS) internal annotation class VideoAdsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/twitch/ad/video/fingerprints/CheckAdEligibilityLambdaFingerprint.kt b/src/main/kotlin/app/revanced/patches/twitch/ad/video/fingerprints/CheckAdEligibilityLambdaFingerprint.kt index 31ea27485e..c85dec1971 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/ad/video/fingerprints/CheckAdEligibilityLambdaFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/ad/video/fingerprints/CheckAdEligibilityLambdaFingerprint.kt @@ -1,15 +1,12 @@ package app.revanced.patches.twitch.ad.video.fingerprints -import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import org.jf.dexlib2.AccessFlags object CheckAdEligibilityLambdaFingerprint : MethodFingerprint( - "L", - AccessFlags.PRIVATE or AccessFlags.FINAL or AccessFlags.STATIC, - listOf("L", "L", "L"), + returnType = "Lio/reactivex/Single;", + parameters = listOf("L"), customFingerprint = { method, _ -> - method.definingClass.endsWith("AdEligibilityFetcher;") && - method.name.contains("shouldRequestAd") + method.definingClass.endsWith("/AdEligibilityFetcher;") + && method.name == "shouldRequestAd" } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/twitch/ad/video/fingerprints/ContentConfigShowAdsFingerprint.kt b/src/main/kotlin/app/revanced/patches/twitch/ad/video/fingerprints/ContentConfigShowAdsFingerprint.kt index f64ba6ffef..166e63b740 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/ad/video/fingerprints/ContentConfigShowAdsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/ad/video/fingerprints/ContentConfigShowAdsFingerprint.kt @@ -1,10 +1,11 @@ package app.revanced.patches.twitch.ad.video.fingerprints - import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint object ContentConfigShowAdsFingerprint : MethodFingerprint( + returnType = "Z", + parameters = listOf(), customFingerprint = { method, _ -> - method.definingClass.endsWith("ContentConfigData;") && method.name == "getShowAds" + method.definingClass.endsWith("/ContentConfigData;") && method.name == "getShowAds" } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/twitch/ad/video/fingerprints/GetReadyToShowAdFingerprint.kt b/src/main/kotlin/app/revanced/patches/twitch/ad/video/fingerprints/GetReadyToShowAdFingerprint.kt index 0f7b2454ce..8987b21930 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/ad/video/fingerprints/GetReadyToShowAdFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/ad/video/fingerprints/GetReadyToShowAdFingerprint.kt @@ -3,6 +3,8 @@ package app.revanced.patches.twitch.ad.video.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint object GetReadyToShowAdFingerprint : MethodFingerprint( + returnType = "Ltv/twitch/android/core/mvp/presenter/StateAndAction;", + parameters = listOf("L", "L"), customFingerprint = { method, _ -> method.definingClass.endsWith("/StreamDisplayAdsPresenter;") && method.name == "getReadyToShowAdOrAbort" } diff --git a/src/main/kotlin/app/revanced/patches/twitch/ad/video/patch/VideoAdsPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/ad/video/patch/VideoAdsPatch.kt index 11096a21d0..50bd3e1b35 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/ad/video/patch/VideoAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/ad/video/patch/VideoAdsPatch.kt @@ -1,5 +1,6 @@ package app.revanced.patches.twitch.ad.video.patch +import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version @@ -86,7 +87,7 @@ class VideoAdsPatch : AbstractAdPatch( ) // Pretend our player is ineligible for all ads - with(CheckAdEligibilityLambdaFingerprint.result!!) { + CheckAdEligibilityLambdaFingerprint.result?.apply { mutableMethod.addInstructionsWithLabels( 0, """ @@ -98,9 +99,9 @@ class VideoAdsPatch : AbstractAdPatch( """, ExternalLabel(skipLabelName, mutableMethod.getInstruction(0)) ) - } + } ?: return CheckAdEligibilityLambdaFingerprint.toErrorResult() - with(GetReadyToShowAdFingerprint.result!!) { + GetReadyToShowAdFingerprint.result?.apply { val adFormatDeclined = "Ltv/twitch/android/shared/display/ads/theatre/StreamDisplayAdsPresenter\$Action\$AdFormatDeclined;" mutableMethod.addInstructionsWithLabels( 0, @@ -113,10 +114,10 @@ class VideoAdsPatch : AbstractAdPatch( """, ExternalLabel(skipLabelName, mutableMethod.getInstruction(0)) ) - } + } ?: return GetReadyToShowAdFingerprint.toErrorResult() // Spoof showAds JSON field - with(ContentConfigShowAdsFingerprint.result!!) { + ContentConfigShowAdsFingerprint.result?.apply { mutableMethod.addInstructions(0, """ ${createConditionInstructions()} const/4 v0, 0 @@ -124,7 +125,7 @@ class VideoAdsPatch : AbstractAdPatch( return v0 """ ) - } + } ?: return ContentConfigShowAdsFingerprint.toErrorResult() SettingsPatch.PreferenceScreen.ADS.CLIENT_SIDE.addPreferences( SwitchPreference( diff --git a/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/annotations/ShowDeletedMessagesCompatibility.kt b/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/annotations/ShowDeletedMessagesCompatibility.kt index 1a54cf9178..7e864e55a0 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/annotations/ShowDeletedMessagesCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/annotations/ShowDeletedMessagesCompatibility.kt @@ -3,7 +3,7 @@ package app.revanced.patches.twitch.chat.antidelete.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("tv.twitch.android.app")]) +@Compatibility([Package("tv.twitch.android.app", arrayOf("15.4.1"))]) @Target(AnnotationTarget.CLASS) internal annotation class ShowDeletedMessagesCompatibility diff --git a/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/patch/ShowDeletedMessagesPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/patch/ShowDeletedMessagesPatch.kt index 7d3b841c66..f5f713954e 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/patch/ShowDeletedMessagesPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/patch/ShowDeletedMessagesPatch.kt @@ -1,5 +1,6 @@ package app.revanced.patches.twitch.chat.antidelete.patch +import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version @@ -44,7 +45,7 @@ class ShowDeletedMessagesPatch : BytecodePatch( override fun execute(context: BytecodeContext): PatchResult { // Spoiler mode: Force set hasModAccess member to true in constructor - DeletedMessageClickableSpanCtorFingerprint.result!!.mutableMethod.apply { + DeletedMessageClickableSpanCtorFingerprint.result?.mutableMethod?.apply { addInstructionsWithLabels( implementation!!.instructions.lastIndex, /* place in front of return-void */ """ @@ -54,14 +55,14 @@ class ShowDeletedMessagesPatch : BytecodePatch( """, ExternalLabel("no_spoiler", getInstruction(implementation!!.instructions.lastIndex)) ) - } + } ?: return DeletedMessageClickableSpanCtorFingerprint.toErrorResult() // Spoiler mode: Disable setHasModAccess setter - SetHasModAccessFingerprint.result!!.mutableMethod.addInstruction(0, "return-void") - + SetHasModAccessFingerprint.result?.mutableMethod?.addInstruction(0, "return-void") + ?: return SetHasModAccessFingerprint.toErrorResult() // Cross-out mode: Reformat span of deleted message - ChatUtilCreateDeletedSpanFingerprint.result!!.mutableMethod.apply { + ChatUtilCreateDeletedSpanFingerprint.result?.mutableMethod?.apply { addInstructionsWithLabels( 0, """ @@ -72,7 +73,7 @@ class ShowDeletedMessagesPatch : BytecodePatch( """, ExternalLabel("no_reformat", getInstruction(0)) ) - } + } ?: return ChatUtilCreateDeletedSpanFingerprint.toErrorResult() SettingsPatch.PreferenceScreen.CHAT.GENERAL.addPreferences( ListPreference( diff --git a/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/annotations/AutoClaimChannelPointsCompatibility.kt b/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/annotations/AutoClaimChannelPointsCompatibility.kt index 30473cf3ac..2efc511bf5 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/annotations/AutoClaimChannelPointsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/annotations/AutoClaimChannelPointsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.twitch.chat.autoclaim.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("tv.twitch.android.app")]) +@Compatibility([Package("tv.twitch.android.app", arrayOf("15.4.1"))]) @Target(AnnotationTarget.CLASS) internal annotation class AutoClaimChannelPointsCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/patch/AutoClaimChannelPointsPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/patch/AutoClaimChannelPointsPatch.kt index e77b2b5801..4859299e63 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/patch/AutoClaimChannelPointsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/patch/AutoClaimChannelPointsPatch.kt @@ -65,6 +65,7 @@ class AutoClaimChannelPointPatch : BytecodePatch( ExternalLabel("auto_claim", getInstruction(lastIndex)) ) } ?: return CommunityPointsButtonViewDelegateFingerprint.toErrorResult() + return PatchResultSuccess() } } diff --git a/src/main/kotlin/app/revanced/patches/twitch/debug/fingerprints/IsDebugConfigEnabledFingerprint.kt b/src/main/kotlin/app/revanced/patches/twitch/debug/fingerprints/IsDebugConfigEnabledFingerprint.kt index 145bc06be2..efb6effd10 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/debug/fingerprints/IsDebugConfigEnabledFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/debug/fingerprints/IsDebugConfigEnabledFingerprint.kt @@ -1,10 +1,9 @@ package app.revanced.patches.twitch.debug.fingerprints - import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint object IsDebugConfigEnabledFingerprint : MethodFingerprint( customFingerprint = { methodDef, _ -> - methodDef.definingClass.endsWith("BuildConfigUtil;") && methodDef.name == "isDebugConfigEnabled" + methodDef.definingClass.endsWith("/BuildConfigUtil;") && methodDef.name == "isDebugConfigEnabled" } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/twitch/debug/fingerprints/IsOmVerificationEnabledFingerprint.kt b/src/main/kotlin/app/revanced/patches/twitch/debug/fingerprints/IsOmVerificationEnabledFingerprint.kt index ab50280a5f..99894998a8 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/debug/fingerprints/IsOmVerificationEnabledFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/debug/fingerprints/IsOmVerificationEnabledFingerprint.kt @@ -1,10 +1,9 @@ package app.revanced.patches.twitch.debug.fingerprints - import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint object IsOmVerificationEnabledFingerprint : MethodFingerprint( customFingerprint = { methodDef, _ -> - methodDef.definingClass.endsWith("BuildConfigUtil;") && methodDef.name == "isOmVerificationEnabled" + methodDef.definingClass.endsWith("/BuildConfigUtil;") && methodDef.name == "isOmVerificationEnabled" } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/twitch/debug/fingerprints/ShouldShowDebugOptionsFingerprint.kt b/src/main/kotlin/app/revanced/patches/twitch/debug/fingerprints/ShouldShowDebugOptionsFingerprint.kt index e9a77cc3bb..9c91695e01 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/debug/fingerprints/ShouldShowDebugOptionsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/debug/fingerprints/ShouldShowDebugOptionsFingerprint.kt @@ -1,10 +1,9 @@ package app.revanced.patches.twitch.debug.fingerprints - import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint object ShouldShowDebugOptionsFingerprint : MethodFingerprint( customFingerprint = { methodDef, _ -> - methodDef.definingClass.endsWith("BuildConfigUtil;") && methodDef.name == "shouldShowDebugOptions" + methodDef.definingClass.endsWith("/BuildConfigUtil;") && methodDef.name == "shouldShowDebugOptions" } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/twitch/debug/patch/DebugModePatch.kt b/src/main/kotlin/app/revanced/patches/twitch/debug/patch/DebugModePatch.kt index 749c073630..4316879482 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/debug/patch/DebugModePatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/debug/patch/DebugModePatch.kt @@ -1,5 +1,6 @@ package app.revanced.patches.twitch.debug.patch +import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version @@ -38,18 +39,16 @@ class DebugModePatch : BytecodePatch( IsOmVerificationEnabledFingerprint, ShouldShowDebugOptionsFingerprint ).forEach { - with(it.result!!) { - with(mutableMethod) { - addInstructions( - 0, - """ - invoke-static {}, Lapp/revanced/twitch/patches/DebugModePatch;->isDebugModeEnabled()Z - move-result v0 - return v0 - """ - ) - } - } + it.result?.mutableMethod?.apply { + addInstructions( + 0, + """ + invoke-static {}, Lapp/revanced/twitch/patches/DebugModePatch;->isDebugModeEnabled()Z + move-result v0 + return v0 + """ + ) + } ?: return it.toErrorResult() } SettingsPatch.PreferenceScreen.MISC.OTHER.addPreferences( diff --git a/src/main/kotlin/app/revanced/patches/twitch/misc/settings/bytecode/patch/SettingsPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/misc/settings/bytecode/patch/SettingsPatch.kt index ef114798bc..767b5c8ec2 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/misc/settings/bytecode/patch/SettingsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/misc/settings/bytecode/patch/SettingsPatch.kt @@ -1,5 +1,6 @@ package app.revanced.patches.twitch.misc.settings.bytecode.patch +import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version @@ -45,7 +46,7 @@ class SettingsPatch : BytecodePatch( ) { override fun execute(context: BytecodeContext): PatchResult { // Hook onCreate to handle fragment creation - with(SettingsActivityOnCreateFingerprint.result!!) { + SettingsActivityOnCreateFingerprint.result?.apply { val insertIndex = mutableMethod.implementation!!.instructions.size - 2 mutableMethod.addInstructionsWithLabels( insertIndex, @@ -57,20 +58,20 @@ class SettingsPatch : BytecodePatch( """, ExternalLabel("no_rv_settings_init", mutableMethod.getInstruction(insertIndex)) ) - } + } ?: return SettingsActivityOnCreateFingerprint.toErrorResult() // Create new menu item for settings menu - with(SettingsMenuItemEnumFingerprint.result!!) { + SettingsMenuItemEnumFingerprint.result?.apply { injectMenuItem( REVANCED_SETTINGS_MENU_ITEM_NAME, REVANCED_SETTINGS_MENU_ITEM_ID, REVANCED_SETTINGS_MENU_ITEM_TITLE_RES, REVANCED_SETTINGS_MENU_ITEM_ICON_RES ) - } + } ?: return SettingsMenuItemEnumFingerprint.toErrorResult() // Intercept settings menu creation and add new menu item - with(MenuGroupsUpdatedFingerprint.result!!) { + MenuGroupsUpdatedFingerprint.result?.apply { mutableMethod.addInstructions( 0, """ @@ -79,10 +80,10 @@ class SettingsPatch : BytecodePatch( move-result-object p1 """ ) - } + } ?: return MenuGroupsUpdatedFingerprint.toErrorResult() // Intercept onclick events for the settings menu - with(MenuGroupsOnClickFingerprint.result!!) { + MenuGroupsOnClickFingerprint.result?.apply { val insertIndex = 0 mutableMethod.addInstructionsWithLabels( insertIndex, @@ -96,7 +97,7 @@ class SettingsPatch : BytecodePatch( """, ExternalLabel("no_rv_settings_onclick", mutableMethod.getInstruction(insertIndex)) ) - } + } ?: return MenuGroupsOnClickFingerprint.toErrorResult() addString("revanced_settings", "ReVanced Settings", false) addString("revanced_reboot_message", "Twitch needs to restart to apply your changes. Restart now?", false)