feat(twitch): 15.4.1 support (#2462)

This commit is contained in:
LisoUseInAIKyrios 2023-06-21 22:04:00 +04:00 committed by GitHub
parent becb033dc9
commit 826ed49c7c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 52 additions and 91 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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"
}
)

View file

@ -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"
}
)

View file

@ -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"
}

View file

@ -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(

View file

@ -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

View file

@ -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(

View file

@ -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

View file

@ -65,6 +65,7 @@ class AutoClaimChannelPointPatch : BytecodePatch(
ExternalLabel("auto_claim", getInstruction(lastIndex))
)
} ?: return CommunityPointsButtonViewDelegateFingerprint.toErrorResult()
return PatchResultSuccess()
}
}

View file

@ -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"
}
)

View file

@ -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"
}
)

View file

@ -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"
}
)

View file

@ -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(

View file

@ -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)