From eecfbb7122a9072e55e687f2c003f63108654888 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sat, 14 Dec 2024 08:33:27 +0100 Subject: [PATCH] feat(Twitch): Make patches compatible with latest versions (#4099) --- .../patches/twitch/ad/audio/AudioAdsPatch.kt | 2 +- .../patches/twitch/ad/embedded/EmbeddedAdsPatch.kt | 2 +- .../patches/twitch/ad/embedded/Fingerprints.kt | 2 +- .../patches/twitch/ad/video/VideoAdsPatch.kt | 13 +++++++------ .../chat/antidelete/ShowDeletedMessagesPatch.kt | 2 +- .../chat/autoclaim/AutoClaimChannelPointsPatch.kt | 2 +- .../patches/twitch/misc/settings/SettingsPatch.kt | 8 +------- 7 files changed, 13 insertions(+), 18 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/twitch/ad/audio/AudioAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/twitch/ad/audio/AudioAdsPatch.kt index f35397f72f..c55e15e26e 100644 --- a/patches/src/main/kotlin/app/revanced/patches/twitch/ad/audio/AudioAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/twitch/ad/audio/AudioAdsPatch.kt @@ -21,7 +21,7 @@ val audioAdsPatch = bytecodePatch( addResourcesPatch, ) - compatibleWith("tv.twitch.android.app"("15.4.1", "16.1.0", "16.9.1")) + compatibleWith("tv.twitch.android.app") execute { addResources("twitch", "ad.audio.audioAdsPatch") diff --git a/patches/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/EmbeddedAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/EmbeddedAdsPatch.kt index 45a688081d..969554de57 100644 --- a/patches/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/EmbeddedAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/EmbeddedAdsPatch.kt @@ -19,7 +19,7 @@ val embeddedAdsPatch = bytecodePatch( settingsPatch, ) - compatibleWith("tv.twitch.android.app"("15.4.1", "16.1.0", "16.9.1")) + compatibleWith("tv.twitch.android.app") execute { addResources("twitch", "ad.embedded.embeddedAdsPatch") diff --git a/patches/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/Fingerprints.kt index cbf8174693..3e9853bd61 100644 --- a/patches/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/Fingerprints.kt @@ -4,6 +4,6 @@ import app.revanced.patcher.fingerprint internal val createsUsherClientFingerprint = fingerprint { custom { method, _ -> - method.definingClass.endsWith("Ltv/twitch/android/network/OkHttpClientFactory;") && method.name == "buildOkHttpClient" + method.name == "buildOkHttpClient" && method.definingClass.endsWith("Ltv/twitch/android/network/OkHttpClientFactory;") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/twitch/ad/video/VideoAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/twitch/ad/video/VideoAdsPatch.kt index 49b715fce7..bec14e63d5 100644 --- a/patches/src/main/kotlin/app/revanced/patches/twitch/ad/video/VideoAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/twitch/ad/video/VideoAdsPatch.kt @@ -141,14 +141,15 @@ val videoAdsPatch = bytecodePatch( ) // Spoof showAds JSON field. - contentConfigShowAdsFingerprint.method.addInstructions( + // Late versions of the app don't have the method anymore. + contentConfigShowAdsFingerprint.methodOrNull?.addInstructions( 0, """ - ${createConditionInstructions("v0")} - const/4 v0, 0 - :$skipLabelName - return v0 - """, + ${createConditionInstructions("v0")} + const/4 v0, 0 + :$skipLabelName + return v0 + """, ) } }, diff --git a/patches/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/ShowDeletedMessagesPatch.kt b/patches/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/ShowDeletedMessagesPatch.kt index 4fcc870f76..47ad12dc67 100644 --- a/patches/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/ShowDeletedMessagesPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/ShowDeletedMessagesPatch.kt @@ -22,7 +22,7 @@ val showDeletedMessagesPatch = bytecodePatch( addResourcesPatch, ) - compatibleWith("tv.twitch.android.app"("15.4.1", "16.1.0", "16.9.1")) + compatibleWith("tv.twitch.android.app") fun createSpoilerConditionInstructions(register: String = "v0") = """ invoke-static {}, Lapp/revanced/extension/twitch/patches/ShowDeletedMessagesPatch;->shouldUseSpoiler()Z diff --git a/patches/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/AutoClaimChannelPointsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/AutoClaimChannelPointsPatch.kt index 15f3dc8429..cb6879e86d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/AutoClaimChannelPointsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/AutoClaimChannelPointsPatch.kt @@ -20,7 +20,7 @@ val autoClaimChannelPointsPatch = bytecodePatch( addResourcesPatch, ) - compatibleWith("tv.twitch.android.app"("15.4.1", "16.1.0", "16.9.1")) + compatibleWith("tv.twitch.android.app") execute { addResources("twitch", "chat.autoclaim.autoClaimChannelPointsPatch") diff --git a/patches/src/main/kotlin/app/revanced/patches/twitch/misc/settings/SettingsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/twitch/misc/settings/SettingsPatch.kt index 7d14e7adb6..d41f86a4ba 100644 --- a/patches/src/main/kotlin/app/revanced/patches/twitch/misc/settings/SettingsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/twitch/misc/settings/SettingsPatch.kt @@ -48,13 +48,7 @@ val settingsPatch = bytecodePatch( settingsPatch(preferences = preferences), ) - compatibleWith( - "tv.twitch.android.app"( - "15.4.1", - "16.1.0", - "16.9.1", - ), - ) + compatibleWith("tv.twitch.android.app") execute { addResources("twitch", "misc.settings.settingsPatch")