diff --git a/src/main/kotlin/app/revanced/patches/microg/layout/branding/icon/patch/CustomBrandingIconRevancifyBluePatch.kt b/src/main/kotlin/app/revanced/patches/microg/layout/branding/icon/patch/CustomBrandingIconRevancifyBluePatch.kt index 98d4395e2..ffd88a491 100644 --- a/src/main/kotlin/app/revanced/patches/microg/layout/branding/icon/patch/CustomBrandingIconRevancifyBluePatch.kt +++ b/src/main/kotlin/app/revanced/patches/microg/layout/branding/icon/patch/CustomBrandingIconRevancifyBluePatch.kt @@ -4,9 +4,11 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.ResourceContext -import app.revanced.patcher.patch.* +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.MicroGCompatibility +import app.revanced.patches.microg.utils.annotations.MicroGCompatibility import app.revanced.util.resources.MicroGResourceUtils.copyFiles @Patch(false) diff --git a/src/main/kotlin/app/revanced/patches/microg/layout/branding/icon/patch/CustomBrandingIconRevancifyRedPatch.kt b/src/main/kotlin/app/revanced/patches/microg/layout/branding/icon/patch/CustomBrandingIconRevancifyRedPatch.kt index 60e9c831d..4c41cf6f0 100644 --- a/src/main/kotlin/app/revanced/patches/microg/layout/branding/icon/patch/CustomBrandingIconRevancifyRedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/microg/layout/branding/icon/patch/CustomBrandingIconRevancifyRedPatch.kt @@ -4,9 +4,11 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.ResourceContext -import app.revanced.patcher.patch.* +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.MicroGCompatibility +import app.revanced.patches.microg.utils.annotations.MicroGCompatibility import app.revanced.util.resources.MicroGResourceUtils.copyFiles @Patch diff --git a/src/main/kotlin/app/revanced/patches/microg/layout/branding/name/patch/CustomBrandingNamePatch.kt b/src/main/kotlin/app/revanced/patches/microg/layout/branding/name/patch/CustomBrandingNamePatch.kt index 8a07caf34..0e34b981f 100644 --- a/src/main/kotlin/app/revanced/patches/microg/layout/branding/name/patch/CustomBrandingNamePatch.kt +++ b/src/main/kotlin/app/revanced/patches/microg/layout/branding/name/patch/CustomBrandingNamePatch.kt @@ -5,9 +5,14 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.ResourceContext -import app.revanced.patcher.patch.* +import app.revanced.patcher.patch.OptionsContainer +import app.revanced.patcher.patch.PatchOption +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultError +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.MicroGCompatibility +import app.revanced.patches.microg.utils.annotations.MicroGCompatibility import org.w3c.dom.Element @Patch @@ -25,7 +30,8 @@ class CustomBrandingNamePatch : ResourcePatch { if (!it.name.startsWithAny(*resourceFileNames)) return@forEach context.xmlEditor[it.absolutePath].use { editor -> - val resourcesNode = editor.file.getElementsByTagName("resources").item(0) as Element + val resourcesNode = + editor.file.getElementsByTagName("resources").item(0) as Element var label = "" for (i in 0 until resourcesNode.childNodes.length) { @@ -42,7 +48,7 @@ class CustomBrandingNamePatch : ResourcePatch { element.textContent = appName } - "gms_settings_name"-> element.textContent = appName + "gms_settings_name" -> element.textContent = appName else -> continue } @@ -62,10 +68,11 @@ class CustomBrandingNamePatch : ResourcePatch { } } - }?: return PatchResultError("No app name provided") + } ?: return PatchResultError("No app name provided") return PatchResultSuccess() } + companion object : OptionsContainer() { var MicroGAppName: String? by option( PatchOption.StringOption( diff --git a/src/main/kotlin/app/revanced/patches/microg/layout/hideicon/patch/HideIconPatch.kt b/src/main/kotlin/app/revanced/patches/microg/layout/hideicon/patch/HideIconPatch.kt index fb98329bc..29042353d 100644 --- a/src/main/kotlin/app/revanced/patches/microg/layout/hideicon/patch/HideIconPatch.kt +++ b/src/main/kotlin/app/revanced/patches/microg/layout/hideicon/patch/HideIconPatch.kt @@ -9,7 +9,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.MicroGCompatibility +import app.revanced.patches.microg.utils.annotations.MicroGCompatibility import org.w3c.dom.Element @Patch(false) diff --git a/src/main/kotlin/app/revanced/patches/shared/annotation/MicroGCompatibility.kt b/src/main/kotlin/app/revanced/patches/microg/utils/annotations/MicroGCompatibility.kt similarity index 81% rename from src/main/kotlin/app/revanced/patches/shared/annotation/MicroGCompatibility.kt rename to src/main/kotlin/app/revanced/patches/microg/utils/annotations/MicroGCompatibility.kt index 538d99b60..e6dec1d6d 100644 --- a/src/main/kotlin/app/revanced/patches/shared/annotation/MicroGCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/microg/utils/annotations/MicroGCompatibility.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.annotation +package app.revanced.patches.microg.utils.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package @@ -6,4 +6,3 @@ import app.revanced.patcher.annotation.Package @Compatibility([Package("com.mgoogle.android.gms")]) @Target(AnnotationTarget.CLASS) internal annotation class MicroGCompatibility - diff --git a/src/main/kotlin/app/revanced/patches/music/ads/video/patch/MusicVideoAdsPatch.kt b/src/main/kotlin/app/revanced/patches/music/ads/video/patch/MusicVideoAdsPatch.kt index b5266297d..068a48549 100644 --- a/src/main/kotlin/app/revanced/patches/music/ads/video/patch/MusicVideoAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/ads/video/patch/MusicVideoAdsPatch.kt @@ -8,9 +8,9 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.utils.litho.patch.MusicLithoFilterPatch import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.patch.videoads.AbstractVideoAdsPatch import app.revanced.util.enum.CategoryType import app.revanced.util.integrations.Constants.MUSIC_ADS_PATH @@ -24,7 +24,7 @@ import app.revanced.util.integrations.Constants.MUSIC_ADS_PATH MusicSettingsPatch::class ] ) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class MusicVideoAdsPatch : AbstractVideoAdsPatch( "$MUSIC_ADS_PATH/HideMusicAdsPatch;->hideMusicAds()Z" diff --git a/src/main/kotlin/app/revanced/patches/music/layout/amoled/patch/AmoledPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/amoled/patch/AmoledPatch.kt index 2212e9a93..c99e0c4e9 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/amoled/patch/AmoledPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/amoled/patch/AmoledPatch.kt @@ -8,13 +8,13 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility +import app.revanced.patches.music.utils.annotations.MusicCompatibility import org.w3c.dom.Element @Patch @Name("amoled") @Description("Applies pure black theme in flyout panels.") -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class AmoledPatch : ResourcePatch { override fun execute(context: ResourceContext): PatchResult { diff --git a/src/main/kotlin/app/revanced/patches/music/layout/autocaptions/patch/DisableAutoCaptionsPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/autocaptions/patch/DisableAutoCaptionsPatch.kt index 91584c6a8..756ce0276 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/autocaptions/patch/DisableAutoCaptionsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/autocaptions/patch/DisableAutoCaptionsPatch.kt @@ -12,9 +12,9 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility -import app.revanced.patches.shared.fingerprints.SubtitleTrackFingerprint +import app.revanced.patches.shared.fingerprints.captions.SubtitleTrackFingerprint import app.revanced.util.enum.CategoryType import app.revanced.util.integrations.Constants.MUSIC_LAYOUT import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @@ -23,7 +23,7 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @Name("disable-auto-captions") @Description("Disable forced captions from automatically enabling in video player.") @DependsOn([MusicSettingsPatch::class]) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class DisableAutoCaptionsPatch : BytecodePatch( listOf(SubtitleTrackFingerprint) @@ -44,7 +44,11 @@ class DisableAutoCaptionsPatch : BytecodePatch( } } ?: return SubtitleTrackFingerprint.toErrorResult() - MusicSettingsPatch.addMusicPreference(CategoryType.LAYOUT, "revanced_disable_auto_captions", "false") + MusicSettingsPatch.addMusicPreference( + CategoryType.LAYOUT, + "revanced_disable_auto_captions", + "false" + ) return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/music/layout/blacknavbar/patch/BlackNavbarPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/blacknavbar/patch/BlackNavbarPatch.kt index 9a94d8f06..9e87e10c9 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/blacknavbar/patch/BlackNavbarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/blacknavbar/patch/BlackNavbarPatch.kt @@ -12,10 +12,10 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.layout.blacknavbar.fingerprints.TabLayoutFingerprint import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.util.enum.CategoryType import app.revanced.util.integrations.Constants.MUSIC_LAYOUT import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @@ -29,7 +29,7 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction SharedResourceIdPatch::class ] ) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class BlackNavbarPatch : BytecodePatch( listOf(TabLayoutFingerprint) @@ -50,7 +50,11 @@ class BlackNavbarPatch : BytecodePatch( } } ?: return TabLayoutFingerprint.toErrorResult() - MusicSettingsPatch.addMusicPreference(CategoryType.LAYOUT, "revanced_enable_black_navbar", "true") + MusicSettingsPatch.addMusicPreference( + CategoryType.LAYOUT, + "revanced_enable_black_navbar", + "true" + ) return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/patch/CustomBrandingMusicIconMMTPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/patch/CustomBrandingMusicIconMMTPatch.kt index 54dfbed77..dfa3ea653 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/patch/CustomBrandingMusicIconMMTPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/patch/CustomBrandingMusicIconMMTPatch.kt @@ -4,16 +4,18 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.ResourceContext -import app.revanced.patcher.patch.* +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.util.resources.IconHelper.customIconMusic import app.revanced.util.resources.IconHelper.customIconMusicAdditional @Patch(false) @Name("custom-branding-music-mmt") @Description("Changes the YouTube Music launcher icon to MMT.") -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class CustomBrandingMusicIconMMTPatch : ResourcePatch { override fun execute(context: ResourceContext): PatchResult { diff --git a/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/patch/CustomBrandingMusicIconRevancifyBluePatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/patch/CustomBrandingMusicIconRevancifyBluePatch.kt index 85374eaf7..f6941f1b2 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/patch/CustomBrandingMusicIconRevancifyBluePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/patch/CustomBrandingMusicIconRevancifyBluePatch.kt @@ -4,15 +4,17 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.ResourceContext -import app.revanced.patcher.patch.* +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.util.resources.IconHelper.customIconMusic @Patch @Name("custom-branding-music-revancify-blue") @Description("Changes the YouTube Music launcher icon to Revancify Blue.") -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class CustomBrandingMusicIconRevancifyBluePatch : ResourcePatch { override fun execute(context: ResourceContext): PatchResult { diff --git a/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/patch/CustomBrandingMusicIconRevancifyRedPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/patch/CustomBrandingMusicIconRevancifyRedPatch.kt index c97de3432..f83d827fe 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/patch/CustomBrandingMusicIconRevancifyRedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/patch/CustomBrandingMusicIconRevancifyRedPatch.kt @@ -4,15 +4,17 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.ResourceContext -import app.revanced.patcher.patch.* +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.util.resources.IconHelper.customIconMusic @Patch(false) @Name("custom-branding-music-revancify-red") @Description("Changes the YouTube Music launcher icon to Revancify Red.") -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class CustomBrandingMusicIconRevancifyRedPatch : ResourcePatch { override fun execute(context: ResourceContext): PatchResult { diff --git a/src/main/kotlin/app/revanced/patches/music/layout/branding/name/patch/CustomBrandingMusicNamePatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/branding/name/patch/CustomBrandingMusicNamePatch.kt index bb7e4399c..889e21c33 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/branding/name/patch/CustomBrandingMusicNamePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/branding/name/patch/CustomBrandingMusicNamePatch.kt @@ -5,15 +5,19 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.ResourceContext -import app.revanced.patcher.patch.* +import app.revanced.patcher.patch.OptionsContainer +import app.revanced.patcher.patch.PatchOption +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility +import app.revanced.patches.music.utils.annotations.MusicCompatibility import org.w3c.dom.Element @Patch(false) @Name("custom-branding-music-name") @Description("Changes the Music launcher name to your choice (defaults to YTM Extended, ReVanced Music Extended).") -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class CustomBrandingMusicNamePatch : ResourcePatch { override fun execute(context: ResourceContext): PatchResult { @@ -27,7 +31,7 @@ class CustomBrandingMusicNamePatch : ResourcePatch { if (!it.name.startsWithAny(*resourceFileNames)) return@forEach context.xmlEditor[it.absolutePath].use { editor -> - val resourcesNode = editor.file.getElementsByTagName("resources").item(0) as Element + val resourcesNode = editor.file.getElementsByTagName("resources").item(0) as Element for (i in 0 until resourcesNode.childNodes.length) { val node = resourcesNode.childNodes.item(i) @@ -45,6 +49,7 @@ class CustomBrandingMusicNamePatch : ResourcePatch { return PatchResultSuccess() } + companion object : OptionsContainer() { var MusicLongName: String? by option( PatchOption.StringOption( diff --git a/src/main/kotlin/app/revanced/patches/music/layout/buttonshelf/patch/HideButtonShelfPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/buttonshelf/patch/HideButtonShelfPatch.kt index adef62d01..c9b54270e 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/buttonshelf/patch/HideButtonShelfPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/buttonshelf/patch/HideButtonShelfPatch.kt @@ -9,9 +9,9 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.utils.litho.patch.MusicLithoFilterPatch import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.util.enum.CategoryType @Patch @@ -23,12 +23,16 @@ import app.revanced.util.enum.CategoryType MusicSettingsPatch::class ] ) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class HideButtonShelfPatch : BytecodePatch() { override fun execute(context: BytecodeContext): PatchResult { - MusicSettingsPatch.addMusicPreference(CategoryType.LAYOUT, "revanced_hide_button_shelf", "false") + MusicSettingsPatch.addMusicPreference( + CategoryType.LAYOUT, + "revanced_hide_button_shelf", + "false" + ) return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/music/layout/carouselshelf/patch/HideCarouselShelfPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/carouselshelf/patch/HideCarouselShelfPatch.kt index da098b562..1771169ab 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/carouselshelf/patch/HideCarouselShelfPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/carouselshelf/patch/HideCarouselShelfPatch.kt @@ -9,9 +9,9 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.utils.litho.patch.MusicLithoFilterPatch import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.util.enum.CategoryType @Patch @@ -23,12 +23,16 @@ import app.revanced.util.enum.CategoryType MusicSettingsPatch::class ] ) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class HideCarouselShelfPatch : BytecodePatch() { override fun execute(context: BytecodeContext): PatchResult { - MusicSettingsPatch.addMusicPreference(CategoryType.LAYOUT, "revanced_hide_carousel_shelf", "false") + MusicSettingsPatch.addMusicPreference( + CategoryType.LAYOUT, + "revanced_hide_carousel_shelf", + "false" + ) return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/music/layout/castbutton/fingerprints/HideCastButtonFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/layout/castbutton/fingerprints/HideCastButtonFingerprint.kt index 562ec18a0..efc276163 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/castbutton/fingerprints/HideCastButtonFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/castbutton/fingerprints/HideCastButtonFingerprint.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.AccessFlags -object HideCastButtonFingerprint : MethodFingerprint ( +object HideCastButtonFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, parameters = listOf("I") diff --git a/src/main/kotlin/app/revanced/patches/music/layout/castbutton/fingerprints/HideCastButtonParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/layout/castbutton/fingerprints/HideCastButtonParentFingerprint.kt index 833feff70..6bf9041b4 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/castbutton/fingerprints/HideCastButtonParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/castbutton/fingerprints/HideCastButtonParentFingerprint.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.AccessFlags -object HideCastButtonParentFingerprint : MethodFingerprint ( +object HideCastButtonParentFingerprint : MethodFingerprint( returnType = "Z", accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL, strings = listOf("MediaRouteButton") diff --git a/src/main/kotlin/app/revanced/patches/music/layout/castbutton/patch/HideCastButtonPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/castbutton/patch/HideCastButtonPatch.kt index 62521af8f..28db0c80c 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/castbutton/patch/HideCastButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/castbutton/patch/HideCastButtonPatch.kt @@ -12,17 +12,18 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.layout.castbutton.fingerprints.HideCastButtonFingerprint import app.revanced.patches.music.layout.castbutton.fingerprints.HideCastButtonParentFingerprint import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.util.enum.CategoryType import app.revanced.util.integrations.Constants.MUSIC_LAYOUT + @Patch @Name("hide-music-cast-button") @Description("Hides the cast button in the video player and header.") @DependsOn([MusicSettingsPatch::class]) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class HideCastButtonPatch : BytecodePatch( listOf(HideCastButtonParentFingerprint) @@ -30,7 +31,12 @@ class HideCastButtonPatch : BytecodePatch( override fun execute(context: BytecodeContext): PatchResult { HideCastButtonParentFingerprint.result?.let { parentResult -> - HideCastButtonFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.addInstructions( + HideCastButtonFingerprint.also { + it.resolve( + context, + parentResult.classDef + ) + }.result?.mutableMethod?.addInstructions( 0, """ invoke-static {p1}, $MUSIC_LAYOUT->hideCastButton(I)I move-result p1 @@ -38,7 +44,11 @@ class HideCastButtonPatch : BytecodePatch( ) ?: return HideCastButtonFingerprint.toErrorResult() } ?: return HideCastButtonParentFingerprint.toErrorResult() - MusicSettingsPatch.addMusicPreference(CategoryType.LAYOUT, "revanced_hide_cast_button", "true") + MusicSettingsPatch.addMusicPreference( + CategoryType.LAYOUT, + "revanced_hide_cast_button", + "true" + ) return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/music/layout/categorybar/patch/CategoryBarPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/categorybar/patch/CategoryBarPatch.kt index 74e7a99a1..cc8ba612e 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/categorybar/patch/CategoryBarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/categorybar/patch/CategoryBarPatch.kt @@ -12,10 +12,10 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.layout.categorybar.fingerprints.ChipCloudFingerprint import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.util.enum.CategoryType import app.revanced.util.integrations.Constants.MUSIC_LAYOUT import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @@ -29,7 +29,7 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction MusicSettingsPatch::class ] ) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class CategoryBarPatch : BytecodePatch( listOf(ChipCloudFingerprint) @@ -47,7 +47,11 @@ class CategoryBarPatch : BytecodePatch( } } ?: return ChipCloudFingerprint.toErrorResult() - MusicSettingsPatch.addMusicPreference(CategoryType.LAYOUT, "revanced_hide_category_bar", "true") + MusicSettingsPatch.addMusicPreference( + CategoryType.LAYOUT, + "revanced_hide_category_bar", + "true" + ) return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/music/layout/colormatchplayer/patch/ColorMatchPlayerPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/colormatchplayer/patch/ColorMatchPlayerPatch.kt index 257d69349..fa371d37e 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/colormatchplayer/patch/ColorMatchPlayerPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/colormatchplayer/patch/ColorMatchPlayerPatch.kt @@ -16,10 +16,10 @@ import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.smali.ExternalLabel +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.layout.colormatchplayer.fingerprints.ColorMatchPlayerFingerprint import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility -import app.revanced.patches.shared.fingerprints.ColorMatchPlayerParentFingerprint +import app.revanced.patches.music.utils.fingerprints.ColorMatchPlayerParentFingerprint import app.revanced.util.enum.CategoryType import app.revanced.util.integrations.Constants.MUSIC_LAYOUT import org.jf.dexlib2.iface.instruction.Instruction @@ -29,7 +29,7 @@ import org.jf.dexlib2.iface.instruction.ReferenceInstruction @Name("enable-color-match-player") @Description("Matches the fullscreen player color with the minimized one.") @DependsOn([MusicSettingsPatch::class]) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class ColorMatchPlayerPatch : BytecodePatch( listOf(ColorMatchPlayerParentFingerprint) @@ -37,7 +37,12 @@ class ColorMatchPlayerPatch : BytecodePatch( override fun execute(context: BytecodeContext): PatchResult { ColorMatchPlayerParentFingerprint.result?.let { parentResult -> - ColorMatchPlayerFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let { + ColorMatchPlayerFingerprint.also { + it.resolve( + context, + parentResult.classDef + ) + }.result?.let { it.mutableMethod.apply { targetMethod = parentResult.mutableMethod @@ -72,10 +77,15 @@ class ColorMatchPlayerPatch : BytecodePatch( } ?: return ColorMatchPlayerFingerprint.toErrorResult() } ?: return ColorMatchPlayerParentFingerprint.toErrorResult() - MusicSettingsPatch.addMusicPreference(CategoryType.LAYOUT, "revanced_enable_color_match_player", "true") + MusicSettingsPatch.addMusicPreference( + CategoryType.LAYOUT, + "revanced_enable_color_match_player", + "true" + ) return PatchResultSuccess() } + private companion object { private lateinit var targetMethod: MutableMethod diff --git a/src/main/kotlin/app/revanced/patches/music/layout/compactdialog/patch/CompactDialogPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/compactdialog/patch/CompactDialogPatch.kt index 840bcf911..426204ac1 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/compactdialog/patch/CompactDialogPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/compactdialog/patch/CompactDialogPatch.kt @@ -13,10 +13,10 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.layout.compactdialog.fingerprints.DialogSolidFingerprint import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.util.enum.CategoryType import app.revanced.util.integrations.Constants.MUSIC_LAYOUT @@ -30,17 +30,18 @@ import app.revanced.util.integrations.Constants.MUSIC_LAYOUT SharedResourceIdPatch::class ] ) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class CompactDialogPatch : BytecodePatch( listOf(DialogSolidFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { DialogSolidFingerprint.result?.let { - with(context - .toMethodWalker(it.method) - .nextMethod(it.scanResult.patternScanResult!!.endIndex, true) - .getMethod() as MutableMethod + with( + context + .toMethodWalker(it.method) + .nextMethod(it.scanResult.patternScanResult!!.endIndex, true) + .getMethod() as MutableMethod ) { addInstructions( 2, """ @@ -51,7 +52,11 @@ class CompactDialogPatch : BytecodePatch( } } ?: return DialogSolidFingerprint.toErrorResult() - MusicSettingsPatch.addMusicPreference(CategoryType.LAYOUT, "revanced_enable_compact_dialog", "true") + MusicSettingsPatch.addMusicPreference( + CategoryType.LAYOUT, + "revanced_enable_compact_dialog", + "true" + ) return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/music/layout/dismissqueue/patch/DismissQueuePatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/dismissqueue/patch/DismissQueuePatch.kt index 1d7366b5c..49bd7501e 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/dismissqueue/patch/DismissQueuePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/dismissqueue/patch/DismissQueuePatch.kt @@ -12,9 +12,9 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.layout.dismissqueue.fingerprints.DismissQueueFingerprint import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.util.enum.CategoryType import app.revanced.util.integrations.Constants.MUSIC_LAYOUT import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @@ -23,7 +23,7 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @Name("enable-dismiss-queue") @Description("Add dismiss queue to flyout menu. (YT Music v6.04.51+)") @DependsOn([MusicSettingsPatch::class]) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class DismissQueuePatch : BytecodePatch( listOf(DismissQueueFingerprint) @@ -44,7 +44,11 @@ class DismissQueuePatch : BytecodePatch( } } ?: return DismissQueueFingerprint.toErrorResult() - MusicSettingsPatch.addMusicPreference(CategoryType.LAYOUT, "revanced_enable_dismiss_queue", "true") + MusicSettingsPatch.addMusicPreference( + CategoryType.LAYOUT, + "revanced_enable_dismiss_queue", + "true" + ) return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/music/layout/floatingbutton/patch/NewPlaylistButtonPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/floatingbutton/patch/NewPlaylistButtonPatch.kt index 128d48316..13e09c212 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/floatingbutton/patch/NewPlaylistButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/floatingbutton/patch/NewPlaylistButtonPatch.kt @@ -14,11 +14,11 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.smali.ExternalLabel +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.layout.floatingbutton.fingerprints.FloatingButtonFingerprint import app.revanced.patches.music.layout.floatingbutton.fingerprints.FloatingButtonParentFingerprint import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.util.enum.CategoryType import app.revanced.util.integrations.Constants.MUSIC_LAYOUT @@ -31,7 +31,7 @@ import app.revanced.util.integrations.Constants.MUSIC_LAYOUT SharedResourceIdPatch::class ] ) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class NewPlaylistButtonPatch : BytecodePatch( listOf(FloatingButtonParentFingerprint) @@ -39,7 +39,12 @@ class NewPlaylistButtonPatch : BytecodePatch( override fun execute(context: BytecodeContext): PatchResult { FloatingButtonParentFingerprint.result?.let { parentResult -> - FloatingButtonFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let { + FloatingButtonFingerprint.also { + it.resolve( + context, + parentResult.classDef + ) + }.result?.let { it.mutableMethod.apply { addInstructionsWithLabels( 1, """ @@ -53,7 +58,11 @@ class NewPlaylistButtonPatch : BytecodePatch( } ?: return FloatingButtonFingerprint.toErrorResult() } ?: return FloatingButtonParentFingerprint.toErrorResult() - MusicSettingsPatch.addMusicPreference(CategoryType.LAYOUT, "revanced_hide_new_playlist_button", "false") + MusicSettingsPatch.addMusicPreference( + CategoryType.LAYOUT, + "revanced_hide_new_playlist_button", + "false" + ) return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/music/layout/landscapemode/patch/LandScapeModePatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/landscapemode/patch/LandScapeModePatch.kt index 4106242cd..a73d90c88 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/landscapemode/patch/LandScapeModePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/landscapemode/patch/LandScapeModePatch.kt @@ -11,10 +11,10 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.layout.landscapemode.fingerprints.TabletIdentifierFingerprint import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.util.enum.CategoryType import app.revanced.util.integrations.Constants.MUSIC_LAYOUT @@ -27,7 +27,7 @@ import app.revanced.util.integrations.Constants.MUSIC_LAYOUT SharedResourceIdPatch::class ] ) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class LandScapeModePatch : BytecodePatch( listOf(TabletIdentifierFingerprint) @@ -42,7 +42,11 @@ class LandScapeModePatch : BytecodePatch( ) } ?: return TabletIdentifierFingerprint.toErrorResult() - MusicSettingsPatch.addMusicPreference(CategoryType.LAYOUT, "revanced_enable_landscape_mode", "true") + MusicSettingsPatch.addMusicPreference( + CategoryType.LAYOUT, + "revanced_enable_landscape_mode", + "true" + ) return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayer/patch/MinimizedPlayerPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayer/patch/MinimizedPlayerPatch.kt index 08be9a18c..7f9911136 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayer/patch/MinimizedPlayerPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayer/patch/MinimizedPlayerPatch.kt @@ -11,9 +11,9 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.layout.minimizedplayer.fingerprints.MinimizedPlayerFingerprint import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.util.enum.CategoryType import app.revanced.util.integrations.Constants.MUSIC_LAYOUT import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @@ -22,7 +22,7 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @Name("enable-force-minimized-player") @Description("Permanently keep player minimized even if another track is played.") @DependsOn([MusicSettingsPatch::class]) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class MinimizedPlayerPatch : BytecodePatch( listOf(MinimizedPlayerFingerprint) @@ -30,9 +30,10 @@ class MinimizedPlayerPatch : BytecodePatch( override fun execute(context: BytecodeContext): PatchResult { MinimizedPlayerFingerprint.result?.let { - with (it.mutableMethod) { + with(it.mutableMethod) { val index = it.scanResult.patternScanResult!!.endIndex - val register = (implementation!!.instructions[index] as OneRegisterInstruction).registerA + val register = + (implementation!!.instructions[index] as OneRegisterInstruction).registerA addInstructions( index, """ @@ -43,7 +44,11 @@ class MinimizedPlayerPatch : BytecodePatch( } } ?: return MinimizedPlayerFingerprint.toErrorResult() - MusicSettingsPatch.addMusicPreference(CategoryType.LAYOUT, "revanced_enable_force_minimized_player", "true") + MusicSettingsPatch.addMusicPreference( + CategoryType.LAYOUT, + "revanced_enable_force_minimized_player", + "true" + ) return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/music/layout/navigationlabel/patch/NavigationLabelPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/navigationlabel/patch/NavigationLabelPatch.kt index cafdadeb3..53eb139b0 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/navigationlabel/patch/NavigationLabelPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/navigationlabel/patch/NavigationLabelPatch.kt @@ -13,12 +13,12 @@ import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.layout.navigationlabel.fingerprints.TabLayoutTextFingerprint import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch.Companion.Text1 import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch.Companion.contexts -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.util.bytecode.getWideLiteralIndex import app.revanced.util.enum.CategoryType import app.revanced.util.integrations.Constants.MUSIC_LAYOUT @@ -34,7 +34,7 @@ import org.jf.dexlib2.iface.instruction.ReferenceInstruction MusicSettingsPatch::class ] ) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class NavigationLabelPatch : BytecodePatch( listOf(TabLayoutTextFingerprint) @@ -68,10 +68,15 @@ class NavigationLabelPatch : BytecodePatch( } } - MusicSettingsPatch.addMusicPreference(CategoryType.LAYOUT, "revanced_hide_navigation_label", "false") + MusicSettingsPatch.addMusicPreference( + CategoryType.LAYOUT, + "revanced_hide_navigation_label", + "false" + ) return PatchResultSuccess() } + private companion object { const val FLAG = "android:layout_weight" const val RESOURCE_FILE_PATH = "res/layout/image_with_text_tab.xml" diff --git a/src/main/kotlin/app/revanced/patches/music/layout/newlayout/patch/NewLayoutPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/newlayout/patch/NewLayoutPatch.kt index ee5b7cd55..24923e3d1 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/newlayout/patch/NewLayoutPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/newlayout/patch/NewLayoutPatch.kt @@ -12,9 +12,9 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.layout.newlayout.fingerprints.NewLayoutFingerprint import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.util.enum.CategoryType import app.revanced.util.integrations.Constants.MUSIC_LAYOUT import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @@ -23,7 +23,7 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @Name("enable-new-layout") @Description("Enable new player layouts. (YT Music v5.47.51+)") @DependsOn([MusicSettingsPatch::class]) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class NewLayoutPatch : BytecodePatch( listOf(NewLayoutFingerprint) @@ -44,7 +44,11 @@ class NewLayoutPatch : BytecodePatch( } } ?: return NewLayoutFingerprint.toErrorResult() - MusicSettingsPatch.addMusicPreference(CategoryType.LAYOUT, "revanced_enable_new_layout", "false") + MusicSettingsPatch.addMusicPreference( + CategoryType.LAYOUT, + "revanced_enable_new_layout", + "false" + ) return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/music/layout/oldstyleminiplayer/fingerprints/NextButtonVisibilityFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/layout/oldstyleminiplayer/fingerprints/NextButtonVisibilityFingerprint.kt index 6010eafcb..e4508bfdb 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/oldstyleminiplayer/fingerprints/NextButtonVisibilityFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/oldstyleminiplayer/fingerprints/NextButtonVisibilityFingerprint.kt @@ -4,6 +4,7 @@ import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode + object NextButtonVisibilityFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, diff --git a/src/main/kotlin/app/revanced/patches/music/layout/oldstyleminiplayer/patch/OldStyleMiniPlayerPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/oldstyleminiplayer/patch/OldStyleMiniPlayerPatch.kt index 6ccce974c..4ec3acdd5 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/oldstyleminiplayer/patch/OldStyleMiniPlayerPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/oldstyleminiplayer/patch/OldStyleMiniPlayerPatch.kt @@ -13,11 +13,11 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.layout.oldstyleminiplayer.fingerprints.NextButtonVisibilityFingerprint import app.revanced.patches.music.layout.oldstyleminiplayer.fingerprints.SwipeToCloseFingerprint import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility -import app.revanced.patches.shared.fingerprints.ColorMatchPlayerParentFingerprint +import app.revanced.patches.music.utils.fingerprints.ColorMatchPlayerParentFingerprint import app.revanced.util.enum.CategoryType import app.revanced.util.integrations.Constants.MUSIC_LAYOUT import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @@ -26,7 +26,7 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @Name("enable-old-style-miniplayer") @Description("Return the miniplayers to old style. (for YT Music v5.55.53+)") @DependsOn([MusicSettingsPatch::class]) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class OldStyleMiniPlayerPatch : BytecodePatch( listOf( @@ -37,10 +37,16 @@ class OldStyleMiniPlayerPatch : BytecodePatch( override fun execute(context: BytecodeContext): PatchResult { ColorMatchPlayerParentFingerprint.result?.let { parentResult -> - NextButtonVisibilityFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let { + NextButtonVisibilityFingerprint.also { + it.resolve( + context, + parentResult.classDef + ) + }.result?.let { it.mutableMethod.apply { val targetIndex = it.scanResult.patternScanResult!!.startIndex + 1 - val targetRegister = getInstruction(targetIndex).registerA + val targetRegister = + getInstruction(targetIndex).registerA addInstructions( targetIndex + 1, """ @@ -66,7 +72,11 @@ class OldStyleMiniPlayerPatch : BytecodePatch( } } ?: return SwipeToCloseFingerprint.toErrorResult() - MusicSettingsPatch.addMusicPreference(CategoryType.LAYOUT, "revanced_enable_old_style_mini_player", "false") + MusicSettingsPatch.addMusicPreference( + CategoryType.LAYOUT, + "revanced_enable_old_style_mini_player", + "false" + ) return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/music/layout/playlistcard/patch/HidePlaylistCardPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/playlistcard/patch/HidePlaylistCardPatch.kt index d35ecfd4d..19645b00c 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/playlistcard/patch/HidePlaylistCardPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/playlistcard/patch/HidePlaylistCardPatch.kt @@ -9,9 +9,9 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.utils.litho.patch.MusicLithoFilterPatch import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.util.enum.CategoryType @Patch @@ -23,12 +23,16 @@ import app.revanced.util.enum.CategoryType MusicSettingsPatch::class ] ) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class HidePlaylistCardPatch : BytecodePatch() { override fun execute(context: BytecodeContext): PatchResult { - MusicSettingsPatch.addMusicPreference(CategoryType.LAYOUT, "revanced_hide_playlist_card", "false") + MusicSettingsPatch.addMusicPreference( + CategoryType.LAYOUT, + "revanced_hide_playlist_card", + "false" + ) return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/music/layout/sleeptimer/patch/SleepTimerPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/sleeptimer/patch/SleepTimerPatch.kt index b8ac5c03a..86b0510f3 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/sleeptimer/patch/SleepTimerPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/sleeptimer/patch/SleepTimerPatch.kt @@ -12,9 +12,9 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.layout.sleeptimer.fingerprints.SleepTimerFingerprint import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.util.enum.CategoryType import app.revanced.util.integrations.Constants.MUSIC_LAYOUT import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @@ -23,7 +23,7 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @Name("enable-sleep-timer") @Description("Add sleep timer to flyout menu.") @DependsOn([MusicSettingsPatch::class]) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class SleepTimerPatch : BytecodePatch( listOf(SleepTimerFingerprint) @@ -44,7 +44,11 @@ class SleepTimerPatch : BytecodePatch( } } ?: return SleepTimerFingerprint.toErrorResult() - MusicSettingsPatch.addMusicPreference(CategoryType.LAYOUT, "revanced_enable_sleep_timer", "true") + MusicSettingsPatch.addMusicPreference( + CategoryType.LAYOUT, + "revanced_enable_sleep_timer", + "true" + ) return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/music/layout/zenmode/patch/ZenModePatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/zenmode/patch/ZenModePatch.kt index f8e48477d..a6a442420 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/zenmode/patch/ZenModePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/zenmode/patch/ZenModePatch.kt @@ -14,10 +14,10 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.layout.zenmode.fingerprints.ZenModeFingerprint import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility -import app.revanced.patches.shared.fingerprints.ColorMatchPlayerParentFingerprint +import app.revanced.patches.music.utils.fingerprints.ColorMatchPlayerParentFingerprint import app.revanced.util.enum.CategoryType import app.revanced.util.integrations.Constants.MUSIC_LAYOUT import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @@ -27,7 +27,7 @@ import org.jf.dexlib2.iface.instruction.ReferenceInstruction @Name("enable-zen-mode") @Description("Adds a grey tint to the video player to reduce eye strain.") @DependsOn([MusicSettingsPatch::class]) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class ZenModePatch : BytecodePatch( listOf(ColorMatchPlayerParentFingerprint) @@ -40,11 +40,13 @@ class ZenModePatch : BytecodePatch( val startIndex = it.scanResult.patternScanResult!!.startIndex val firstRegister = getInstruction(startIndex).registerA - val secondRegister = getInstruction(startIndex + 2).registerA + val secondRegister = + getInstruction(startIndex + 2).registerA val dummyRegister = secondRegister + 1 val referenceIndex = it.scanResult.patternScanResult!!.endIndex + 1 - val targetReference = getInstruction(referenceIndex).reference.toString() + val targetReference = + getInstruction(referenceIndex).reference.toString() val insertIndex = referenceIndex + 1 @@ -66,7 +68,11 @@ class ZenModePatch : BytecodePatch( } ?: return ZenModeFingerprint.toErrorResult() } ?: return ColorMatchPlayerParentFingerprint.toErrorResult() - MusicSettingsPatch.addMusicPreference(CategoryType.LAYOUT, "revanced_enable_zen_mode", "false") + MusicSettingsPatch.addMusicPreference( + CategoryType.LAYOUT, + "revanced_enable_zen_mode", + "false" + ) return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/music/misc/backgroundplay/patch/BackgroundPlayPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/backgroundplay/patch/BackgroundPlayPatch.kt index 74539399f..84aebe806 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/backgroundplay/patch/BackgroundPlayPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/backgroundplay/patch/BackgroundPlayPatch.kt @@ -12,26 +12,25 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.misc.backgroundplay.fingerprints.BackgroundPlaybackParentFingerprint -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility @Patch @Name("background-play") @Description("Enables playing music in the background.") -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class BackgroundPlayPatch : BytecodePatch( - listOf( - BackgroundPlaybackParentFingerprint - ) + listOf(BackgroundPlaybackParentFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { BackgroundPlaybackParentFingerprint.result?.let { - with(context - .toMethodWalker(it.method) - .nextMethod(it.scanResult.patternScanResult!!.startIndex, true) - .getMethod() as MutableMethod + with( + context + .toMethodWalker(it.method) + .nextMethod(it.scanResult.patternScanResult!!.startIndex, true) + .getMethod() as MutableMethod ) { addInstructions( 0, """ diff --git a/src/main/kotlin/app/revanced/patches/music/misc/bitrate/patch/BitrateDefaultValuePatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/bitrate/patch/BitrateDefaultValuePatch.kt index 4fcb54e9d..3c4af3b40 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/bitrate/patch/BitrateDefaultValuePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/bitrate/patch/BitrateDefaultValuePatch.kt @@ -8,17 +8,18 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility +import app.revanced.patches.music.utils.annotations.MusicCompatibility @Patch @Name("bitrate-default-value") @Description("Set the audio quality to 'Always High' when you first install the app.") -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class BitrateDefaultValuePatch : ResourcePatch { override fun execute(context: ResourceContext): PatchResult { context.xmlEditor[RESOURCE_FILE_PATH].use { editor -> - editor.file.getElementsByTagName("com.google.android.apps.youtube.music.ui.preference.PreferenceCategoryCompat").item(0).childNodes.apply { + editor.file.getElementsByTagName("com.google.android.apps.youtube.music.ui.preference.PreferenceCategoryCompat") + .item(0).childNodes.apply { arrayOf("BitrateAudioMobile", "BitrateAudioWiFi").forEach { for (i in 1 until length) { val view = item(i) @@ -26,7 +27,8 @@ class BitrateDefaultValuePatch : ResourcePatch { view.hasAttributes() && view.attributes.getNamedItem("android:key").nodeValue.endsWith(it) ) { - view.attributes.getNamedItem("android:defaultValue").nodeValue = "Always High" + view.attributes.getNamedItem("android:defaultValue").nodeValue = + "Always High" break } } diff --git a/src/main/kotlin/app/revanced/patches/music/misc/codecs/patch/CodecsUnlockPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/codecs/patch/CodecsUnlockPatch.kt index df08d8a62..4050a8c19 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/codecs/patch/CodecsUnlockPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/codecs/patch/CodecsUnlockPatch.kt @@ -8,8 +8,8 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.patch.opus.AbstractOpusCodecsPatch import app.revanced.util.enum.CategoryType import app.revanced.util.integrations.Constants.MUSIC_MISC_PATH @@ -18,7 +18,7 @@ import app.revanced.util.integrations.Constants.MUSIC_MISC_PATH @Name("enable-opus-codec") @Description("Enable opus codec when playing audio.") @DependsOn([MusicSettingsPatch::class]) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class CodecsUnlockPatch : AbstractOpusCodecsPatch( "$MUSIC_MISC_PATH/OpusCodecPatch;->enableOpusCodec()Z" @@ -26,7 +26,11 @@ class CodecsUnlockPatch : AbstractOpusCodecsPatch( override fun execute(context: BytecodeContext): PatchResult { super.execute(context) - MusicSettingsPatch.addMusicPreference(CategoryType.MISC, "revanced_enable_opus_codec", "true") + MusicSettingsPatch.addMusicPreference( + CategoryType.MISC, + "revanced_enable_opus_codec", + "true" + ) return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/music/misc/exclusiveaudio/fingerprints/AudioOnlyEnablerFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/misc/exclusiveaudio/fingerprints/AudioOnlyEnablerFingerprint.kt index 66e3b3dea..98c2a5afa 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/exclusiveaudio/fingerprints/AudioOnlyEnablerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/exclusiveaudio/fingerprints/AudioOnlyEnablerFingerprint.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -object AudioOnlyEnablerFingerprint: MethodFingerprint( +object AudioOnlyEnablerFingerprint : MethodFingerprint( returnType = "Z", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, parameters = listOf(), diff --git a/src/main/kotlin/app/revanced/patches/music/misc/exclusiveaudio/patch/ExclusiveAudioPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/exclusiveaudio/patch/ExclusiveAudioPatch.kt index e960dfb59..368f9ddd8 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/exclusiveaudio/patch/ExclusiveAudioPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/exclusiveaudio/patch/ExclusiveAudioPatch.kt @@ -11,13 +11,13 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.misc.exclusiveaudio.fingerprints.AudioOnlyEnablerFingerprint -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility @Patch @Name("exclusive-audio-playback") @Description("Enables the option to play music without video.") -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class ExclusiveAudioPatch : BytecodePatch( listOf(AudioOnlyEnablerFingerprint) diff --git a/src/main/kotlin/app/revanced/patches/music/misc/minimizedplayback/patch/MinimizedPlaybackPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/minimizedplayback/patch/MinimizedPlaybackPatch.kt index 440a97d6e..9d33027f8 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/minimizedplayback/patch/MinimizedPlaybackPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/minimizedplayback/patch/MinimizedPlaybackPatch.kt @@ -10,13 +10,13 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.misc.minimizedplayback.fingerprints.MinimizedPlaybackManagerFingerprint -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility @Patch @Name("minimized-playback-music") @Description("Enables minimized playback on Kids music.") -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class MinimizedPlaybackPatch : BytecodePatch( listOf(MinimizedPlaybackManagerFingerprint) diff --git a/src/main/kotlin/app/revanced/patches/music/misc/optimizeresource/patch/OptimizeResourcePatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/optimizeresource/patch/OptimizeResourcePatch.kt index 35ec8b2bb..827cd2163 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/optimizeresource/patch/OptimizeResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/optimizeresource/patch/OptimizeResourcePatch.kt @@ -8,14 +8,14 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility +import app.revanced.patches.music.utils.annotations.MusicCompatibility import java.nio.file.Files import java.nio.file.StandardCopyOption @Patch @Name("optimize-resource-music") @Description("Remove unnecessary resources.") -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class OptimizeResourcePatch : ResourcePatch { override fun execute(context: ResourceContext): PatchResult { @@ -27,7 +27,7 @@ class OptimizeResourcePatch : ResourcePatch { context["res"].resolve(relativePath).toPath(), StandardCopyOption.REPLACE_EXISTING ) - + return PatchResultSuccess() } } diff --git a/src/main/kotlin/app/revanced/patches/music/misc/premium/patch/HideGetPremiumPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/premium/patch/HideGetPremiumPatch.kt index b2980867a..bb4d2569a 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/premium/patch/HideGetPremiumPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/premium/patch/HideGetPremiumPatch.kt @@ -14,11 +14,11 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.misc.premium.fingerprints.AccountMenuFooterFingerprint import app.revanced.patches.music.misc.premium.fingerprints.HideGetPremiumFingerprint import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch.Companion.PrivacyTosFooter -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.util.bytecode.getWideLiteralIndex import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @@ -30,7 +30,7 @@ import org.jf.dexlib2.iface.reference.Reference @Name("hide-get-premium") @Description("Removes all \"Get Premium\" evidences from the avatar menu.") @DependsOn([SharedResourceIdPatch::class]) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class HideGetPremiumPatch : BytecodePatch( listOf( @@ -58,17 +58,19 @@ class HideGetPremiumPatch : BytecodePatch( val targetIndex = getWideLiteralIndex(PrivacyTosFooter) + 4 targetReference = getInstruction(targetIndex + 1).reference - with (context - .toMethodWalker(this) - .nextMethod(targetIndex, true) - .getMethod() as MutableMethod + with( + context + .toMethodWalker(this) + .nextMethod(targetIndex, true) + .getMethod() as MutableMethod ) { this.implementation!!.instructions.apply { for ((index, instruction) in withIndex()) { if (instruction.opcode != Opcode.IGET_OBJECT) continue if (getInstruction(index).reference == targetReference) { - val targetRegister = getInstruction(index + 2).registerA + val targetRegister = + getInstruction(index + 2).registerA addInstruction( index, @@ -85,7 +87,8 @@ class HideGetPremiumPatch : BytecodePatch( return PatchResultSuccess() } - private companion object{ + + private companion object { lateinit var targetReference: Reference } } diff --git a/src/main/kotlin/app/revanced/patches/music/misc/quality/fingerprints/MusicVideoQualitySettingsParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/misc/quality/fingerprints/MusicVideoQualitySettingsParentFingerprint.kt index dd0a2a94c..79d08ce12 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/quality/fingerprints/MusicVideoQualitySettingsParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/quality/fingerprints/MusicVideoQualitySettingsParentFingerprint.kt @@ -8,7 +8,7 @@ import org.jf.dexlib2.AccessFlags object MusicVideoQualitySettingsParentFingerprint : MethodFingerprint( returnType = "V", - accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, + accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, parameters = listOf("L"), - customFingerprint = { it, _ -> it.isWideLiteralExists(QualityTitle)} + customFingerprint = { it, _ -> it.isWideLiteralExists(QualityTitle) } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/music/misc/quality/patch/VideoQualityPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/quality/patch/VideoQualityPatch.kt index e50b76095..ea1a52c36 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/quality/patch/VideoQualityPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/quality/patch/VideoQualityPatch.kt @@ -15,13 +15,13 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.misc.quality.fingerprints.MusicVideoQualitySettingsFingerprint import app.revanced.patches.music.misc.quality.fingerprints.MusicVideoQualitySettingsParentFingerprint import app.revanced.patches.music.misc.quality.fingerprints.UserQualityChangeFingerprint import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch import app.revanced.patches.music.utils.videoid.patch.MusicVideoIdPatch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.util.enum.CategoryType import app.revanced.util.integrations.Constants.MUSIC_MISC_PATH import org.jf.dexlib2.Opcode @@ -41,7 +41,7 @@ import org.jf.dexlib2.iface.reference.Reference SharedResourceIdPatch::class ] ) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class VideoQualityPatch : BytecodePatch( listOf( @@ -55,8 +55,10 @@ class VideoQualityPatch : BytecodePatch( it.mutableMethod.apply { val endIndex = it.scanResult.patternScanResult!!.endIndex val qualityChangedClass = - context.findClass((getInstruction(endIndex)) - .reference.toString())!! + context.findClass( + (getInstruction(endIndex)) + .reference.toString() + )!! .mutableClass for (method in qualityChangedClass.methods) { @@ -65,8 +67,10 @@ class VideoQualityPatch : BytecodePatch( for ((index, instruction) in implementation!!.instructions.withIndex()) { if (instruction.opcode != Opcode.INVOKE_INTERFACE) continue - qualityReference = getInstruction(index - 1).reference - qIndexMethodName = ((getInstruction(index).reference) as MethodReference).name + qualityReference = + getInstruction(index - 1).reference + qIndexMethodName = + ((getInstruction(index).reference) as MethodReference).name addInstruction( 0, @@ -81,7 +85,12 @@ class VideoQualityPatch : BytecodePatch( } ?: return UserQualityChangeFingerprint.toErrorResult() MusicVideoQualitySettingsParentFingerprint.result?.let { parentResult -> - MusicVideoQualitySettingsFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.addInstructions( + MusicVideoQualitySettingsFingerprint.also { + it.resolve( + context, + parentResult.classDef + ) + }.result?.mutableMethod?.addInstructions( 0, """ const-string v0, "$qIndexMethodName" sput-object v0, $INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR->qIndexMethod:Ljava/lang/String; @@ -93,10 +102,15 @@ class VideoQualityPatch : BytecodePatch( } ?: return MusicVideoQualitySettingsParentFingerprint.toErrorResult() MusicVideoIdPatch.injectCall("$INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR->newVideoStarted(Ljava/lang/String;)V") - MusicSettingsPatch.addMusicPreference(CategoryType.MISC, "revanced_enable_save_video_quality", "true") + MusicSettingsPatch.addMusicPreference( + CategoryType.MISC, + "revanced_enable_save_video_quality", + "true" + ) return PatchResultSuccess() } + private companion object { const val INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR = "$MUSIC_MISC_PATH/MusicVideoQualityPatch;" diff --git a/src/main/kotlin/app/revanced/patches/music/misc/sharebuttonhook/fingerprints/ShowToastFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/misc/sharebuttonhook/fingerprints/ShowToastFingerprint.kt index 119a7c560..0e25fef79 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/sharebuttonhook/fingerprints/ShowToastFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/sharebuttonhook/fingerprints/ShowToastFingerprint.kt @@ -5,6 +5,6 @@ import org.jf.dexlib2.Opcode object ShowToastFingerprint : MethodFingerprint( returnType = "V", - parameters = listOf("Landroid/content/Context;","Ljava/lang/CharSequence;","I"), + parameters = listOf("Landroid/content/Context;", "Ljava/lang/CharSequence;", "I"), opcodes = listOf(Opcode.IF_EQZ) ) diff --git a/src/main/kotlin/app/revanced/patches/music/misc/sharebuttonhook/patch/ShareButtonHookPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/sharebuttonhook/patch/ShareButtonHookPatch.kt index 95234d399..2e60169fc 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/sharebuttonhook/patch/ShareButtonHookPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/sharebuttonhook/patch/ShareButtonHookPatch.kt @@ -15,10 +15,13 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.smali.ExternalLabel +import app.revanced.patches.music.utils.annotations.MusicCompatibility +import app.revanced.patches.music.misc.sharebuttonhook.fingerprints.ConnectionTrackerFingerprint +import app.revanced.patches.music.misc.sharebuttonhook.fingerprints.FullStackTraceActivityFingerprint +import app.revanced.patches.music.misc.sharebuttonhook.fingerprints.SharePanelFingerprint +import app.revanced.patches.music.misc.sharebuttonhook.fingerprints.ShowToastFingerprint import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch -import app.revanced.patches.music.misc.sharebuttonhook.fingerprints.* import app.revanced.patches.music.utils.videoid.patch.MusicVideoIdPatch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.util.enum.CategoryType import app.revanced.util.integrations.Constants.MUSIC_INTEGRATIONS_PATH import app.revanced.util.integrations.Constants.MUSIC_MISC_PATH @@ -32,7 +35,7 @@ import app.revanced.util.integrations.Constants.MUSIC_MISC_PATH MusicVideoIdPatch::class ] ) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class ShareButtonHookPatch : BytecodePatch( listOf( @@ -48,7 +51,7 @@ class ShareButtonHookPatch : BytecodePatch( val targetIndex = it.scanResult.patternScanResult!!.startIndex addInstructionsWithLabels( - targetIndex,""" + targetIndex, """ invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->overrideSharePanel()Z move-result p1 if-eqz p1, :default @@ -64,24 +67,33 @@ class ShareButtonHookPatch : BytecodePatch( ) ?: return ConnectionTrackerFingerprint.toErrorResult() ShowToastFingerprint.result?.mutableMethod?.addInstructions( - 0,""" + 0, """ invoke-static {p0}, $INTEGRATIONS_CLASS_DESCRIPTOR->dismissContext(Landroid/content/Context;)Landroid/content/Context; move-result-object p0 """ ) ?: return ShowToastFingerprint.toErrorResult() FullStackTraceActivityFingerprint.result?.mutableMethod?.addInstructions( - 1,""" + 1, """ invoke-static {p0}, $MUSIC_INTEGRATIONS_PATH/settingsmenu/SharedPreferenceChangeListener;->initializeSettings(Landroid/app/Activity;)V return-void """ ) ?: return FullStackTraceActivityFingerprint.toErrorResult() - MusicSettingsPatch.addMusicPreference(CategoryType.MISC, "revanced_hook_share_button", "false") - MusicSettingsPatch.addMusicPreferenceWithIntent(CategoryType.MISC, "revanced_default_downloader", "revanced_hook_share_button") + MusicSettingsPatch.addMusicPreference( + CategoryType.MISC, + "revanced_hook_share_button", + "false" + ) + MusicSettingsPatch.addMusicPreferenceWithIntent( + CategoryType.MISC, + "revanced_default_downloader", + "revanced_hook_share_button" + ) return PatchResultSuccess() } + private companion object { const val INTEGRATIONS_CLASS_DESCRIPTOR = "$MUSIC_MISC_PATH/HookShareButtonPatch;" } diff --git a/src/main/kotlin/app/revanced/patches/music/misc/shuffle/patch/EnforceShufflePatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/shuffle/patch/EnforceShufflePatch.kt index cb55f6f29..521c0c6f1 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/shuffle/patch/EnforceShufflePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/shuffle/patch/EnforceShufflePatch.kt @@ -19,10 +19,12 @@ import app.revanced.patcher.util.TypeUtil.traverseClassHierarchy import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable import app.revanced.patcher.util.smali.toInstructions +import app.revanced.patches.music.utils.annotations.MusicCompatibility +import app.revanced.patches.music.misc.shuffle.fingerprints.MusicPlaybackControlsFingerprint +import app.revanced.patches.music.misc.shuffle.fingerprints.ShuffleClassFingerprint +import app.revanced.patches.music.misc.shuffle.fingerprints.ShuffleClassReferenceFingerprint import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch -import app.revanced.patches.music.misc.shuffle.fingerprints.* -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.util.enum.CategoryType import app.revanced.util.integrations.Constants.MUSIC_MISC_PATH import org.jf.dexlib2.AccessFlags @@ -44,7 +46,7 @@ import org.jf.dexlib2.immutable.ImmutableMethodParameter SharedResourceIdPatch::class ] ) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class EnforceShufflePatch : BytecodePatch( listOf( @@ -163,7 +165,11 @@ class EnforceShufflePatch : BytecodePatch( } } ?: return MusicPlaybackControlsFingerprint.toErrorResult() - MusicSettingsPatch.addMusicPreference(CategoryType.MISC, "revanced_enable_force_shuffle", "true") + MusicSettingsPatch.addMusicPreference( + CategoryType.MISC, + "revanced_enable_force_shuffle", + "true" + ) return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/music/misc/tastebuilder/patch/RemoveTasteBuilderPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/tastebuilder/patch/RemoveTasteBuilderPatch.kt index 2d516796e..d5fdf7e0a 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/tastebuilder/patch/RemoveTasteBuilderPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/tastebuilder/patch/RemoveTasteBuilderPatch.kt @@ -11,14 +11,14 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.misc.tastebuilder.fingerprints.TasteBuilderConstructorFingerprint -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction @Patch @Name("hide-taste-builder") @Description("Removes the \"Tell us which artists you like\" card from the home screen.") -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class RemoveTasteBuilderPatch : BytecodePatch( listOf(TasteBuilderConstructorFingerprint) diff --git a/src/main/kotlin/app/revanced/patches/music/misc/translations/patch/MusicTranslationsPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/translations/patch/MusicTranslationsPatch.kt index 23b3a0219..05f614239 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/translations/patch/MusicTranslationsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/translations/patch/MusicTranslationsPatch.kt @@ -9,15 +9,15 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.util.resources.ResourceHelper.addTranslations @Patch @Name("translations-music") @Description("Add Crowdin translations for YouTube Music.") @DependsOn([MusicSettingsPatch::class]) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class MusicTranslationsPatch : ResourcePatch { override fun execute(context: ResourceContext): PatchResult { diff --git a/src/main/kotlin/app/revanced/patches/music/misc/upgradebutton/fingerprints/NotifierShelfFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/misc/upgradebutton/fingerprints/NotifierShelfFingerprint.kt index 01293342a..47c21538c 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/upgradebutton/fingerprints/NotifierShelfFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/upgradebutton/fingerprints/NotifierShelfFingerprint.kt @@ -16,6 +16,6 @@ object NotifierShelfFingerprint : MethodFingerprint( Opcode.INVOKE_STATIC, Opcode.MOVE_RESULT_OBJECT ), - customFingerprint = { it, _ -> it.isWideLiteralExists(MusicNotifierShelf)} + customFingerprint = { it, _ -> it.isWideLiteralExists(MusicNotifierShelf) } ) diff --git a/src/main/kotlin/app/revanced/patches/music/misc/upgradebutton/patch/RemoveUpgradeButtonPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/upgradebutton/patch/RemoveUpgradeButtonPatch.kt index ca647904c..40be5ca4a 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/upgradebutton/patch/RemoveUpgradeButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/upgradebutton/patch/RemoveUpgradeButtonPatch.kt @@ -14,11 +14,11 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.music.utils.annotations.MusicCompatibility +import app.revanced.patches.music.misc.upgradebutton.fingerprints.NotifierShelfFingerprint +import app.revanced.patches.music.misc.upgradebutton.fingerprints.PivotBarConstructorFingerprint import app.revanced.patches.music.utils.integrations.patch.MusicIntegrationsPatch import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.music.misc.upgradebutton.fingerprints.* -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility -import app.revanced.util.integrations.Constants.INTEGRATIONS_PATH import org.jf.dexlib2.iface.instruction.OneRegisterInstruction import org.jf.dexlib2.iface.instruction.ReferenceInstruction import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction @@ -32,7 +32,7 @@ import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction SharedResourceIdPatch::class ] ) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class RemoveUpgradeButtonPatch : BytecodePatch( listOf( @@ -47,14 +47,15 @@ class RemoveUpgradeButtonPatch : BytecodePatch( val targetRegisterA = getInstruction(targetIndex).registerA val targetRegisterB = getInstruction(targetIndex).registerB - val replaceReference = getInstruction(targetIndex).reference.toString() + val replaceReference = + getInstruction(targetIndex).reference.toString() replaceInstruction( targetIndex, "invoke-interface {v$targetRegisterA}, Ljava/util/List;->size()I" ) addInstructionsWithLabels( - targetIndex + 1,""" + targetIndex + 1, """ move-result v1 const/4 v2, 0x3 if-le v1, v2, :dismiss diff --git a/src/main/kotlin/app/revanced/patches/music/misc/versionspoof/patch/SpoofAppVersionPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/versionspoof/patch/SpoofAppVersionPatch.kt index 891923ec6..5fcba9e17 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/versionspoof/patch/SpoofAppVersionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/versionspoof/patch/SpoofAppVersionPatch.kt @@ -8,8 +8,8 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.patch.versionspoof.AbstractVersionSpoofPatch import app.revanced.util.enum.CategoryType import app.revanced.util.integrations.Constants.MUSIC_MISC_PATH @@ -18,14 +18,18 @@ import app.revanced.util.integrations.Constants.MUSIC_MISC_PATH @Name("spoof-app-version") @Description("Spoof the YouTube Music client version.") @DependsOn([MusicSettingsPatch::class]) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class SpoofAppVersionPatch : AbstractVersionSpoofPatch( "$MUSIC_MISC_PATH/SpoofAppVersionPatch;->getVersionOverride(Ljava/lang/String;)Ljava/lang/String;" ) { override fun execute(context: BytecodeContext): PatchResult { - MusicSettingsPatch.addMusicPreference(CategoryType.MISC, "revanced_spoof_app_version", "false") + MusicSettingsPatch.addMusicPreference( + CategoryType.MISC, + "revanced_spoof_app_version", + "false" + ) return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/shared/annotation/YouTubeMusicCompatibility.kt b/src/main/kotlin/app/revanced/patches/music/utils/annotations/MusicCompatibility.kt similarity index 66% rename from src/main/kotlin/app/revanced/patches/shared/annotation/YouTubeMusicCompatibility.kt rename to src/main/kotlin/app/revanced/patches/music/utils/annotations/MusicCompatibility.kt index 05cf3bd43..d3d8b94a2 100644 --- a/src/main/kotlin/app/revanced/patches/shared/annotation/YouTubeMusicCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/annotations/MusicCompatibility.kt @@ -1,9 +1,8 @@ -package app.revanced.patches.shared.annotation +package app.revanced.patches.music.utils.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package @Compatibility([Package("com.google.android.apps.youtube.music")]) @Target(AnnotationTarget.CLASS) -internal annotation class YouTubeMusicCompatibility - +internal annotation class MusicCompatibility diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/ColorMatchPlayerParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/utils/fingerprints/ColorMatchPlayerParentFingerprint.kt similarity index 92% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/ColorMatchPlayerParentFingerprint.kt rename to src/main/kotlin/app/revanced/patches/music/utils/fingerprints/ColorMatchPlayerParentFingerprint.kt index 6b3e4e0fc..638dc93bf 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/ColorMatchPlayerParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/fingerprints/ColorMatchPlayerParentFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints +package app.revanced.patches.music.utils.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/music/utils/fix/androidauto/patch/AndroidAutoCertificatePatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/fix/androidauto/patch/AndroidAutoCertificatePatch.kt index de407da7c..a2a338715 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/fix/androidauto/patch/AndroidAutoCertificatePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/fix/androidauto/patch/AndroidAutoCertificatePatch.kt @@ -10,13 +10,13 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.utils.fix.androidauto.fingerprints.CertificateCheckFingerprint -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility @Patch @Name("certificate-spoof") @Description("Spoofs the YouTube Music certificate for Android Auto.") -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class AndroidAutoCertificatePatch : BytecodePatch( listOf(CertificateCheckFingerprint) diff --git a/src/main/kotlin/app/revanced/patches/music/utils/fix/clientspoof/patch/ClientSpoofMusicPatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/fix/clientspoof/patch/ClientSpoofMusicPatch.kt index 3a243ace6..67731186e 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/fix/clientspoof/patch/ClientSpoofMusicPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/fix/clientspoof/patch/ClientSpoofMusicPatch.kt @@ -10,14 +10,14 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.utils.fix.clientspoof.fingerprints.UserAgentHeaderBuilderFingerprint import app.revanced.patches.music.utils.microg.shared.Constants.MUSIC_PACKAGE_NAME -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction @Name("client-spoof-music") @Description("Spoofs the YouTube Music client.") -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class ClientSpoofMusicPatch : BytecodePatch( listOf(UserAgentHeaderBuilderFingerprint) @@ -27,7 +27,8 @@ class ClientSpoofMusicPatch : BytecodePatch( UserAgentHeaderBuilderFingerprint.result?.let { it.mutableMethod.apply { val insertIndex = it.scanResult.patternScanResult!!.endIndex - 1 - val packageNameRegister = getInstruction(insertIndex).registerD + val packageNameRegister = + getInstruction(insertIndex).registerD addInstruction( insertIndex, diff --git a/src/main/kotlin/app/revanced/patches/music/utils/integrations/patch/MusicIntegrationsPatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/integrations/patch/MusicIntegrationsPatch.kt index 55f41be7d..a94967f1b 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/integrations/patch/MusicIntegrationsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/integrations/patch/MusicIntegrationsPatch.kt @@ -2,13 +2,13 @@ package app.revanced.patches.music.utils.integrations.patch import app.revanced.patcher.annotation.Name import app.revanced.patcher.patch.annotations.RequiresIntegrations +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.utils.integrations.fingerprints.InitFingerprint import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.util.integrations.Constants.MUSIC_INTEGRATIONS_PATH @Name("music-integrations") -@YouTubeMusicCompatibility +@MusicCompatibility @RequiresIntegrations class MusicIntegrationsPatch : AbstractIntegrationsPatch( "$MUSIC_INTEGRATIONS_PATH/utils/ReVancedUtils;", diff --git a/src/main/kotlin/app/revanced/patches/music/utils/litho/patch/MusicLithoFilterPatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/litho/patch/MusicLithoFilterPatch.kt index 1c1752774..97b9556e0 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/litho/patch/MusicLithoFilterPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/litho/patch/MusicLithoFilterPatch.kt @@ -6,14 +6,14 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility -import app.revanced.patches.shared.fingerprints.IdentifierFingerprint +import app.revanced.patches.music.utils.annotations.MusicCompatibility +import app.revanced.patches.shared.fingerprints.litho.IdentifierFingerprint import app.revanced.patches.shared.patch.litho.ComponentParserPatch import app.revanced.patches.shared.patch.litho.ComponentParserPatch.Companion.identifierHook import app.revanced.util.integrations.Constants.MUSIC_ADS_PATH @DependsOn([ComponentParserPatch::class]) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class MusicLithoFilterPatch : BytecodePatch( listOf(IdentifierFingerprint) diff --git a/src/main/kotlin/app/revanced/patches/music/utils/microg/bytecode/patch/MusicMicroGBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/microg/bytecode/patch/MusicMicroGBytecodePatch.kt index a9d45ad9d..932640d21 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/microg/bytecode/patch/MusicMicroGBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/microg/bytecode/patch/MusicMicroGBytecodePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.music.misc.microg.bytecode.patch +package app.revanced.patches.music.utils.microg.bytecode.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -9,17 +9,17 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.utils.fix.clientspoof.patch.ClientSpoofMusicPatch -import app.revanced.patches.music.utils.microg.resource.patch.MusicMicroGResourcePatch -import app.revanced.patches.music.utils.microg.shared.Constants.MUSIC_PACKAGE_NAME -import app.revanced.patches.music.utils.microg.shared.Constants.YOUTUBE_PACKAGE_NAME import app.revanced.patches.music.utils.microg.bytecode.fingerprints.CastContextFetchFingerprint import app.revanced.patches.music.utils.microg.bytecode.fingerprints.CastDynamiteModuleFingerprint import app.revanced.patches.music.utils.microg.bytecode.fingerprints.CastDynamiteModuleV2Fingerprint import app.revanced.patches.music.utils.microg.bytecode.fingerprints.GooglePlayUtilityFingerprint import app.revanced.patches.music.utils.microg.bytecode.fingerprints.PrimeFingerprint import app.revanced.patches.music.utils.microg.bytecode.fingerprints.ServiceCheckFingerprint -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility +import app.revanced.patches.music.utils.microg.resource.patch.MusicMicroGResourcePatch +import app.revanced.patches.music.utils.microg.shared.Constants.MUSIC_PACKAGE_NAME +import app.revanced.patches.music.utils.microg.shared.Constants.YOUTUBE_PACKAGE_NAME import app.revanced.patches.shared.patch.packagename.PackageNamePatch import app.revanced.util.microg.MicroGBytecodeHelper @@ -33,7 +33,7 @@ import app.revanced.util.microg.MicroGBytecodeHelper ) @Name("music-microg-support") @Description("Allows ReVanced Music to run without root and under a different package name with MicroG.") -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.2") class MusicMicroGBytecodePatch : BytecodePatch( listOf( diff --git a/src/main/kotlin/app/revanced/patches/music/utils/microg/resource/patch/MusicMicroGResourcePatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/microg/resource/patch/MusicMicroGResourcePatch.kt index fae7059ed..6dd4eff52 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/microg/resource/patch/MusicMicroGResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/microg/resource/patch/MusicMicroGResourcePatch.kt @@ -8,10 +8,10 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.utils.microg.shared.Constants.MUSIC_PACKAGE_NAME import app.revanced.patches.music.utils.microg.shared.Constants.SPOOFED_PACKAGE_NAME import app.revanced.patches.music.utils.microg.shared.Constants.SPOOFED_PACKAGE_SIGNATURE -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.patch.packagename.PackageNamePatch import app.revanced.util.microg.MicroGManifestHelper.addSpoofingMetadata import app.revanced.util.microg.MicroGResourceHelper.patchManifest @@ -20,7 +20,7 @@ import app.revanced.util.resources.MusicResourceHelper.setMicroG @Name("music-microg-resource-patch") @Description("Resource patch to allow YouTube Music ReVanced to run without root and under a different package name.") @DependsOn([PackageNamePatch::class]) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.2") class MusicMicroGResourcePatch : ResourcePatch { override fun execute(context: ResourceContext): PatchResult { diff --git a/src/main/kotlin/app/revanced/patches/music/utils/resourceid/patch/SharedResourceIdPatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/resourceid/patch/SharedResourceIdPatch.kt index 7f9ad1677..ef3b16292 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/resourceid/patch/SharedResourceIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/resourceid/patch/SharedResourceIdPatch.kt @@ -8,14 +8,20 @@ import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch import app.revanced.util.enum.ResourceType -import app.revanced.util.enum.ResourceType.* +import app.revanced.util.enum.ResourceType.BOOL +import app.revanced.util.enum.ResourceType.COLOR +import app.revanced.util.enum.ResourceType.DIMEN +import app.revanced.util.enum.ResourceType.ID +import app.revanced.util.enum.ResourceType.LAYOUT +import app.revanced.util.enum.ResourceType.STRING +import app.revanced.util.enum.ResourceType.STYLE @Name("music-resource-id") @DependsOn([ResourceMappingPatch::class]) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class SharedResourceIdPatch : ResourcePatch { internal companion object { diff --git a/src/main/kotlin/app/revanced/patches/music/utils/settings/bytecode/patch/MusicSettingsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/settings/bytecode/patch/MusicSettingsBytecodePatch.kt index ac795bf92..928cee565 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/settings/bytecode/patch/MusicSettingsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/settings/bytecode/patch/MusicSettingsBytecodePatch.kt @@ -10,17 +10,17 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.utils.integrations.patch.MusicIntegrationsPatch import app.revanced.patches.music.utils.settings.bytecode.fingerprints.PreferenceFingerprint import app.revanced.patches.music.utils.settings.bytecode.fingerprints.SettingsHeadersFragmentFingerprint -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.util.integrations.Constants.MUSIC_INTEGRATIONS_PATH import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @Name("music-settings-bytecode-patch") @DependsOn([MusicIntegrationsPatch::class]) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class MusicSettingsBytecodePatch : BytecodePatch( listOf( @@ -57,6 +57,7 @@ class MusicSettingsBytecodePatch : BytecodePatch( return PatchResultSuccess() } + companion object { const val INTEGRATIONS_CLASS_DESCRIPTOR = "$MUSIC_INTEGRATIONS_PATH/settingsmenu/SharedPreferenceChangeListener;" diff --git a/src/main/kotlin/app/revanced/patches/music/utils/settings/resource/patch/MusicSettingsPatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/settings/resource/patch/MusicSettingsPatch.kt index f8dcdd309..d9b89e664 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/settings/resource/patch/MusicSettingsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/settings/resource/patch/MusicSettingsPatch.kt @@ -8,8 +8,8 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.utils.settings.bytecode.patch.MusicSettingsBytecodePatch -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.patch.settings.AbstractSettingsResourcePatch import app.revanced.util.enum.CategoryType import app.revanced.util.resources.IconHelper @@ -29,7 +29,7 @@ import java.nio.file.Paths @Name("music-settings") @Description("Adds settings for ReVanced to YouTube Music.") @DependsOn([MusicSettingsBytecodePatch::class]) -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class MusicSettingsPatch : AbstractSettingsResourcePatch( "music/settings", @@ -67,8 +67,11 @@ class MusicSettingsPatch : AbstractSettingsResourcePatch( if (File(targetDirectory).exists()) { fun copyResources(resourceGroups: List) { - try { context.copyFiles(resourceGroups, iconPath) } - catch (_: Exception) { context.makeDirectoryAndCopyFiles(resourceGroups, iconPath) } + try { + context.copyFiles(resourceGroups, iconPath) + } catch (_: Exception) { + context.makeDirectoryAndCopyFiles(resourceGroups, iconPath) + } } val iconResourceFileNames = @@ -88,6 +91,7 @@ class MusicSettingsPatch : AbstractSettingsResourcePatch( return PatchResultSuccess() } + companion object { lateinit var contexts: ResourceContext diff --git a/src/main/kotlin/app/revanced/patches/music/utils/videoid/fingerprint/MusicVideoIdFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/utils/videoid/fingerprint/MusicVideoIdFingerprint.kt index 2ffe48cba..2c4a90dbd 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/videoid/fingerprint/MusicVideoIdFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/videoid/fingerprint/MusicVideoIdFingerprint.kt @@ -12,5 +12,5 @@ object MusicVideoIdFingerprint : MethodFingerprint( Opcode.INVOKE_INTERFACE, Opcode.MOVE_RESULT_OBJECT ), - customFingerprint = { it, _ -> it.definingClass.endsWith("SubtitlesOverlayPresenter;") && it.name == "handleVideoStageEvent" } + customFingerprint = { it, _ -> it.definingClass.endsWith("SubtitlesOverlayPresenter;") && it.name == "handleVideoStageEvent" } ) diff --git a/src/main/kotlin/app/revanced/patches/music/utils/videoid/patch/MusicVideoIdPatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/videoid/patch/MusicVideoIdPatch.kt index 56154314c..9ab1ca93d 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/videoid/patch/MusicVideoIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/videoid/patch/MusicVideoIdPatch.kt @@ -11,14 +11,14 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod +import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.utils.videoid.fingerprint.MusicVideoIdFingerprint -import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.util.integrations.Constants.MUSIC_UTILS_PATH import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @Name("music-video-id-hook") @Description("Hook to detect when the video id changes.") -@YouTubeMusicCompatibility +@MusicCompatibility @Version("0.0.1") class MusicVideoIdPatch : BytecodePatch( listOf(MusicVideoIdFingerprint) @@ -33,7 +33,7 @@ class MusicVideoIdPatch : BytecodePatch( } offset++ // offset so setVideoId is called before any injected call } ?: return MusicVideoIdFingerprint.toErrorResult() - + injectCall("$INTEGRATIONS_CLASS_DESCRIPTOR->setVideoId(Ljava/lang/String;)V") return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/SubtitleTrackFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/fingerprints/captions/SubtitleTrackFingerprint.kt similarity index 85% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/SubtitleTrackFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/fingerprints/captions/SubtitleTrackFingerprint.kt index 56140c38d..4d9b3ae19 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/SubtitleTrackFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/fingerprints/captions/SubtitleTrackFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints +package app.revanced.patches.shared.fingerprints.captions import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/ByteBufferHookFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/fingerprints/litho/ByteBufferHookFingerprint.kt similarity index 86% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/ByteBufferHookFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/fingerprints/litho/ByteBufferHookFingerprint.kt index fb7d87241..fa487e94e 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/ByteBufferHookFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/fingerprints/litho/ByteBufferHookFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints +package app.revanced.patches.shared.fingerprints.litho import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/EmptyComponentBuilderFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/fingerprints/litho/EmptyComponentBuilderFingerprint.kt similarity index 89% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/EmptyComponentBuilderFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/fingerprints/litho/EmptyComponentBuilderFingerprint.kt index e4467ce53..4ba18f4cc 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/EmptyComponentBuilderFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/fingerprints/litho/EmptyComponentBuilderFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints +package app.revanced.patches.shared.fingerprints.litho import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/IdentifierFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/fingerprints/litho/IdentifierFingerprint.kt similarity index 89% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/IdentifierFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/fingerprints/litho/IdentifierFingerprint.kt index 14d634486..60618d03b 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/IdentifierFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/fingerprints/litho/IdentifierFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints +package app.revanced.patches.shared.fingerprints.litho import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/CodecReferenceFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/fingerprints/opus/CodecReferenceFingerprint.kt similarity index 88% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/CodecReferenceFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/fingerprints/opus/CodecReferenceFingerprint.kt index a52b395cf..d821301f3 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/CodecReferenceFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/fingerprints/opus/CodecReferenceFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints +package app.revanced.patches.shared.fingerprints.opus import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/CodecSelectorFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/fingerprints/opus/CodecSelectorFingerprint.kt similarity index 90% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/CodecSelectorFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/fingerprints/opus/CodecSelectorFingerprint.kt index 8fd0539d5..7268851ba 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/CodecSelectorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/fingerprints/opus/CodecSelectorFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints +package app.revanced.patches.shared.fingerprints.opus import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/ClientInfoFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/fingerprints/versionspoof/ClientInfoFingerprint.kt similarity index 85% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/ClientInfoFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/fingerprints/versionspoof/ClientInfoFingerprint.kt index e618e50aa..402287e7e 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/ClientInfoFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/fingerprints/versionspoof/ClientInfoFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints +package app.revanced.patches.shared.fingerprints.versionspoof import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/ClientInfoParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/fingerprints/versionspoof/ClientInfoParentFingerprint.kt similarity index 75% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/ClientInfoParentFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/fingerprints/versionspoof/ClientInfoParentFingerprint.kt index 0f59f4b00..9b559c555 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/ClientInfoParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/fingerprints/versionspoof/ClientInfoParentFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints +package app.revanced.patches.shared.fingerprints.versionspoof import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/LegacyVideoAdsFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/fingerprints/videoads/LegacyVideoAdsFingerprint.kt similarity index 86% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/LegacyVideoAdsFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/fingerprints/videoads/LegacyVideoAdsFingerprint.kt index 26814e667..745f616b1 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/LegacyVideoAdsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/fingerprints/videoads/LegacyVideoAdsFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints +package app.revanced.patches.shared.fingerprints.videoads import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint @@ -8,7 +8,7 @@ import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction object LegacyVideoAdsFingerprint : MethodFingerprint( returnType = "V", - accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, parameters = listOf(), opcodes = listOf( Opcode.CONST_WIDE_16, diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/MainstreamVideoAdsFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/fingerprints/videoads/MainstreamVideoAdsFingerprint.kt similarity index 78% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/MainstreamVideoAdsFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/fingerprints/videoads/MainstreamVideoAdsFingerprint.kt index 681c2250d..357286815 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/MainstreamVideoAdsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/fingerprints/videoads/MainstreamVideoAdsFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints +package app.revanced.patches.shared.fingerprints.videoads import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/integrations/AbstractIntegrationsPatch.kt b/src/main/kotlin/app/revanced/patches/shared/patch/integrations/AbstractIntegrationsPatch.kt index 0376838e8..14f898830 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/integrations/AbstractIntegrationsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/patch/integrations/AbstractIntegrationsPatch.kt @@ -10,6 +10,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint.RegisterResolver import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.ClassDef import org.jf.dexlib2.iface.Method diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/litho/ComponentParserPatch.kt b/src/main/kotlin/app/revanced/patches/shared/patch/litho/ComponentParserPatch.kt index 711150257..a24350147 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/litho/ComponentParserPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/patch/litho/ComponentParserPatch.kt @@ -16,9 +16,9 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMut import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.shared.annotation.RVXCompatibility -import app.revanced.patches.shared.fingerprints.ByteBufferHookFingerprint -import app.revanced.patches.shared.fingerprints.EmptyComponentBuilderFingerprint -import app.revanced.patches.shared.fingerprints.IdentifierFingerprint +import app.revanced.patches.shared.fingerprints.litho.ByteBufferHookFingerprint +import app.revanced.patches.shared.fingerprints.litho.EmptyComponentBuilderFingerprint +import app.revanced.patches.shared.fingerprints.litho.IdentifierFingerprint import app.revanced.util.bytecode.getStringIndex import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @@ -45,8 +45,10 @@ class ComponentParserPatch : BytecodePatch( EmptyComponentBuilderFingerprint.result?.let { it.mutableMethod.apply { val targetIndex = getStringIndex("Failed to convert Element to Flatbuffers: %s") + 2 - val builderMethodDescriptor = getInstruction(targetIndex).reference - val emptyComponentFieldDescriptor = getInstruction(targetIndex + 2).reference + val builderMethodDescriptor = + getInstruction(targetIndex).reference + val emptyComponentFieldDescriptor = + getInstruction(targetIndex + 2).reference emptyComponentLabel = """ move-object/from16 v0, p1 @@ -75,14 +77,15 @@ class ComponentParserPatch : BytecodePatch( .toMethodWalker(it.method) .nextMethod(it.scanResult.patternScanResult!!.endIndex, true) .getMethod() as MutableMethod - ).apply { - val methodName = EmptyComponentBuilderFingerprint.result!!.mutableMethod.definingClass + ).apply { + val methodName = + EmptyComponentBuilderFingerprint.result!!.mutableMethod.definingClass - addInstruction( - 0, - "sput-object p2, $methodName->buffer:Ljava/nio/ByteBuffer;" - ) - } + addInstruction( + 0, + "sput-object p2, $methodName->buffer:Ljava/nio/ByteBuffer;" + ) + } } ?: return ByteBufferHookFingerprint.toErrorResult() IdentifierFingerprint.result?.let { @@ -91,7 +94,8 @@ class ComponentParserPatch : BytecodePatch( val stringBuilderIndex = implementation!!.instructions.indexOfFirst { instruction -> - val fieldReference = (instruction as? ReferenceInstruction)?.reference as? FieldReference + val fieldReference = + (instruction as? ReferenceInstruction)?.reference as? FieldReference fieldReference?.let { reference -> reference.type == "Ljava/lang/StringBuilder;" } == true } @@ -101,8 +105,10 @@ class ComponentParserPatch : BytecodePatch( instruction.opcode == Opcode.CONST } - stringBuilderRegister = getInstruction(stringBuilderIndex).registerA - identifierRegister = getInstruction(identifierIndex).registerA + stringBuilderRegister = + getInstruction(stringBuilderIndex).registerA + identifierRegister = + getInstruction(identifierIndex).registerA objectRegister = getInstruction(objectIndex).registerC freeRegister = getInstruction(freeIndex).registerA @@ -129,12 +135,14 @@ class ComponentParserPatch : BytecodePatch( ) { insertMethod.apply { addInstructionsWithLabels( - insertIndex, """ + insertIndex, + """ sget-object v$freeRegister, $definingClass->buffer:Ljava/nio/ByteBuffer; invoke-static {v$stringBuilderRegister, v$identifierRegister, v$objectRegister, v$freeRegister}, $descriptor(Ljava/lang/StringBuilder;Ljava/lang/String;Ljava/lang/Object;Ljava/nio/ByteBuffer;)Z move-result v$freeRegister if-eqz v$freeRegister, :not_an_ad - """ + emptyComponentLabel, ExternalLabel("not_an_ad", getInstruction(insertIndex)) + """ + emptyComponentLabel, + ExternalLabel("not_an_ad", getInstruction(insertIndex)) ) } } @@ -144,11 +152,13 @@ class ComponentParserPatch : BytecodePatch( ) { insertMethod.apply { addInstructionsWithLabels( - insertIndex, """ + insertIndex, + """ invoke-static {v$stringBuilderRegister, v$identifierRegister}, $descriptor(Ljava/lang/StringBuilder;Ljava/lang/String;)Z move-result v$freeRegister if-eqz v$freeRegister, :not_an_ad - """ + emptyComponentLabel, ExternalLabel("not_an_ad", getInstruction(insertIndex)) + """ + emptyComponentLabel, + ExternalLabel("not_an_ad", getInstruction(insertIndex)) ) } } diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/mapping/ResourceMappingPatch.kt b/src/main/kotlin/app/revanced/patches/shared/patch/mapping/ResourceMappingPatch.kt index 00d3ebe6c..0e6e1e76f 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/mapping/ResourceMappingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/patch/mapping/ResourceMappingPatch.kt @@ -8,7 +8,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import org.w3c.dom.Element -import java.util.* +import java.util.Collections import java.util.concurrent.Executors import java.util.concurrent.TimeUnit diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/opus/AbstractOpusCodecsPatch.kt b/src/main/kotlin/app/revanced/patches/shared/patch/opus/AbstractOpusCodecsPatch.kt index c4a51d5e3..5de352c1a 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/opus/AbstractOpusCodecsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/patch/opus/AbstractOpusCodecsPatch.kt @@ -11,8 +11,8 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.fingerprints.CodecReferenceFingerprint -import app.revanced.patches.shared.fingerprints.CodecSelectorFingerprint +import app.revanced.patches.shared.fingerprints.opus.CodecReferenceFingerprint +import app.revanced.patches.shared.fingerprints.opus.CodecSelectorFingerprint import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.OneRegisterInstruction import org.jf.dexlib2.iface.instruction.ReferenceInstruction diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/packagename/PackageNamePatch.kt b/src/main/kotlin/app/revanced/patches/shared/patch/packagename/PackageNamePatch.kt index 710c1753b..cb3a3988e 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/packagename/PackageNamePatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/patch/packagename/PackageNamePatch.kt @@ -4,8 +4,12 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.ResourceContext +import app.revanced.patcher.patch.OptionsContainer +import app.revanced.patcher.patch.PatchOption +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.* import app.revanced.patches.shared.annotation.RVXCompatibility @Patch diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/settings/AbstractSettingsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/shared/patch/settings/AbstractSettingsResourcePatch.kt index cf9f55777..ad2dc3109 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/settings/AbstractSettingsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/patch/settings/AbstractSettingsResourcePatch.kt @@ -27,7 +27,10 @@ abstract class AbstractSettingsResourcePatch( /* initialize ReVanced Settings */ if (isYouTube) - context.copyResources(sourceDirectory, ResourceUtils.ResourceGroup("xml", "revanced_prefs.xml")) + context.copyResources( + sourceDirectory, + ResourceUtils.ResourceGroup("xml", "revanced_prefs.xml") + ) return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/versionspoof/AbstractVersionSpoofPatch.kt b/src/main/kotlin/app/revanced/patches/shared/patch/versionspoof/AbstractVersionSpoofPatch.kt index 9672d5a8c..505380b61 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/versionspoof/AbstractVersionSpoofPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/patch/versionspoof/AbstractVersionSpoofPatch.kt @@ -9,8 +9,8 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion. import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patches.shared.fingerprints.ClientInfoFingerprint -import app.revanced.patches.shared.fingerprints.ClientInfoParentFingerprint +import app.revanced.patches.shared.fingerprints.versionspoof.ClientInfoFingerprint +import app.revanced.patches.shared.fingerprints.versionspoof.ClientInfoParentFingerprint import org.jf.dexlib2.Opcode import org.jf.dexlib2.dexbacked.reference.DexBackedFieldReference import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @@ -26,7 +26,12 @@ abstract class AbstractVersionSpoofPatch( override fun execute(context: BytecodeContext): PatchResult { ClientInfoParentFingerprint.result?.let { parentResult -> - ClientInfoFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.let { + ClientInfoFingerprint.also { + it.resolve( + context, + parentResult.classDef + ) + }.result?.mutableMethod?.let { it.apply { var insertIndex = 0 val insertInstructions = implementation!!.instructions @@ -35,7 +40,8 @@ abstract class AbstractVersionSpoofPatch( for ((index, instruction) in insertInstructions.withIndex()) { if (instruction.opcode != Opcode.SGET_OBJECT) continue - val indexString = ((instruction as? ReferenceInstruction)?.reference as? DexBackedFieldReference).toString() + val indexString = + ((instruction as? ReferenceInstruction)?.reference as? DexBackedFieldReference).toString() if (indexString != targetString) continue diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/videoads/AbstractVideoAdsPatch.kt b/src/main/kotlin/app/revanced/patches/shared/patch/videoads/AbstractVideoAdsPatch.kt index 9ff2e00d5..2f30763c2 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/videoads/AbstractVideoAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/patch/videoads/AbstractVideoAdsPatch.kt @@ -13,8 +13,8 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.fingerprints.LegacyVideoAdsFingerprint -import app.revanced.patches.shared.fingerprints.MainstreamVideoAdsFingerprint +import app.revanced.patches.shared.fingerprints.videoads.LegacyVideoAdsFingerprint +import app.revanced.patches.shared.fingerprints.videoads.MainstreamVideoAdsFingerprint @Name("abstract-video-ads-patch") @Version("0.0.1") @@ -31,12 +31,12 @@ abstract class AbstractVideoAdsPatch( (context.toMethodWalker(it.method) .nextMethod(13, true) .getMethod() as MutableMethod).apply { - addInstructions( - 0, """ + addInstructions( + 0, """ invoke-static {}, $descriptor move-result v1 """ - ) + ) } } ?: return LegacyVideoAdsFingerprint.toErrorResult() diff --git a/src/main/kotlin/app/revanced/patches/youtube/ads/general/bytecode/patch/GeneralAdsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ads/general/bytecode/patch/GeneralAdsBytecodePatch.kt index 21f87ff63..b169a1fcb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ads/general/bytecode/patch/GeneralAdsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ads/general/bytecode/patch/GeneralAdsBytecodePatch.kt @@ -38,7 +38,12 @@ class GeneralAdsBytecodePatch : BytecodePatch() { val viewRegister = getInstruction(insertIndex).registerC - this.implementation!!.injectHideCall(insertIndex, viewRegister, "ads/AdsFilter", "hideAdAttributionView") + this.implementation!!.injectHideCall( + insertIndex, + viewRegister, + "ads/AdsFilter", + "hideAdAttributionView" + ) } } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/ads/general/resource/patch/GeneralAdsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ads/general/resource/patch/GeneralAdsPatch.kt index 6801b215b..ebfd53ed0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ads/general/resource/patch/GeneralAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ads/general/resource/patch/GeneralAdsPatch.kt @@ -11,9 +11,9 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.youtube.ads.general.bytecode.patch.GeneralAdsBytecodePatch import app.revanced.patches.youtube.ads.getpremium.patch.HideGetPremiumPatch +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.litho.patch.LithoFilterPatch import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.resources.ResourceUtils.copyXmlNode diff --git a/src/main/kotlin/app/revanced/patches/youtube/ads/getpremium/patch/HideGetPremiumPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ads/getpremium/patch/HideGetPremiumPatch.kt index ff23fff3b..72e534ac9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ads/getpremium/patch/HideGetPremiumPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ads/getpremium/patch/HideGetPremiumPatch.kt @@ -24,8 +24,10 @@ class HideGetPremiumPatch : BytecodePatch( CompactYpcOfferModuleViewFingerprint.result?.let { it.mutableMethod.apply { val startIndex = it.scanResult.patternScanResult!!.startIndex - val measuredWidthRegister = getInstruction(startIndex).registerA - val measuredHeightInstruction = getInstruction(startIndex + 1) + val measuredWidthRegister = + getInstruction(startIndex).registerA + val measuredHeightInstruction = + getInstruction(startIndex + 1) val measuredHeightRegister = measuredHeightInstruction.registerA val tempRegister = measuredHeightInstruction.registerB diff --git a/src/main/kotlin/app/revanced/patches/youtube/ads/video/patch/VideoAdsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ads/video/patch/VideoAdsPatch.kt index 0511cdbad..cb918ad83 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ads/video/patch/VideoAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ads/video/patch/VideoAdsPatch.kt @@ -8,8 +8,8 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.shared.patch.videoads.AbstractVideoAdsPatch +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.ADS_PATH diff --git a/src/main/kotlin/app/revanced/patches/youtube/buttomplayer/buttoncontainer/patch/ButtonContainerPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/buttomplayer/buttoncontainer/patch/ButtonContainerPatch.kt index 642a15b00..fcceb3b31 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/buttomplayer/buttoncontainer/patch/ButtonContainerPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/buttomplayer/buttoncontainer/patch/ButtonContainerPatch.kt @@ -9,8 +9,8 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.shared.patch.litho.ComponentParserPatch.Companion.objectHook +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.litho.patch.LithoFilterPatch import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.BOTTOM_PLAYER diff --git a/src/main/kotlin/app/revanced/patches/youtube/buttomplayer/comment/patch/CommentComponentPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/buttomplayer/comment/patch/CommentComponentPatch.kt index 467a5ebeb..5ce320e7a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/buttomplayer/comment/patch/CommentComponentPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/buttomplayer/comment/patch/CommentComponentPatch.kt @@ -9,8 +9,8 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.youtube.ads.general.bytecode.patch.GeneralAdsBytecodePatch +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch @Patch diff --git a/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/flyoutpanel/patch/FlyoutPanelPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/flyoutpanel/patch/FlyoutPanelPatch.kt index 9014dee31..bbff9f24a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/flyoutpanel/patch/FlyoutPanelPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/flyoutpanel/patch/FlyoutPanelPatch.kt @@ -9,8 +9,8 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.youtube.ads.general.resource.patch.GeneralAdsPatch +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch @Patch diff --git a/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/oldqualitylayout/patch/OldQualityLayoutPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/oldqualitylayout/patch/OldQualityLayoutPatch.kt index 9707b279e..27947edaf 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/oldqualitylayout/patch/OldQualityLayoutPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/oldqualitylayout/patch/OldQualityLayoutPatch.kt @@ -12,7 +12,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.flyoutpanel.oldqualitylayout.fingerprints.QualityMenuViewInflateFingerprint import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/fullscreen/autoplaypreview/patch/HideAutoplayPreviewPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/autoplaypreview/patch/HideAutoplayPreviewPatch.kt index f2be5b5a1..802dcfca1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/fullscreen/autoplaypreview/patch/HideAutoplayPreviewPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/autoplaypreview/patch/HideAutoplayPreviewPatch.kt @@ -13,8 +13,8 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.shared.fingerprints.LayoutConstructorFingerprint +import app.revanced.patches.youtube.utils.fingerprints.LayoutConstructorFingerprint +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.AutoNavPreviewStub import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch @@ -45,12 +45,15 @@ class HideAutoplayPreviewPatch : BytecodePatch( it.mutableMethod.apply { val insertInstruction = implementation!!.instructions - val dummyRegister = getInstruction(getStringIndex("1.0x")).registerA + val dummyRegister = + getInstruction(getStringIndex("1.0x")).registerA val insertIndex = getWideLiteralIndex(AutoNavPreviewStub) - val branchIndex = insertInstruction.subList(insertIndex + 1, insertInstruction.size - 1).indexOfFirst { instruction -> - ((instruction as? ReferenceInstruction)?.reference as? FieldReference)?.type == "Lcom/google/android/apps/youtube/app/player/autonav/AutonavToggleController;" - } + 1 + val branchIndex = + insertInstruction.subList(insertIndex + 1, insertInstruction.size - 1) + .indexOfFirst { instruction -> + ((instruction as? ReferenceInstruction)?.reference as? FieldReference)?.type == "Lcom/google/android/apps/youtube/app/player/autonav/AutonavToggleController;" + } + 1 val jumpInstruction = getInstruction(insertIndex + branchIndex) diff --git a/src/main/kotlin/app/revanced/patches/youtube/fullscreen/compactcontrolsoverlay/fingerprints/YouTubeControlsOverlayFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/compactcontrolsoverlay/fingerprints/YouTubeControlsOverlayFingerprint.kt index 7a2a1b821..eba71f5e9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/fullscreen/compactcontrolsoverlay/fingerprints/YouTubeControlsOverlayFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/compactcontrolsoverlay/fingerprints/YouTubeControlsOverlayFingerprint.kt @@ -12,5 +12,9 @@ object YouTubeControlsOverlayFingerprint : MethodFingerprint( Opcode.MOVE_RESULT, Opcode.IF_EQZ ), - customFingerprint = { it, _ -> it.definingClass.endsWith("YouTubeControlsOverlay;") && it.isWideLiteralExists(YoutubeControlsOverlay) } + customFingerprint = { it, _ -> + it.definingClass.endsWith("YouTubeControlsOverlay;") && it.isWideLiteralExists( + YoutubeControlsOverlay + ) + } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/fullscreen/compactcontrolsoverlay/patch/CompactControlsOverlayPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/compactcontrolsoverlay/patch/CompactControlsOverlayPatch.kt index 8c4644ff5..885b13a62 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/fullscreen/compactcontrolsoverlay/patch/CompactControlsOverlayPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/compactcontrolsoverlay/patch/CompactControlsOverlayPatch.kt @@ -14,7 +14,7 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.fullscreen.compactcontrolsoverlay.fingerprints.YouTubeControlsOverlayFingerprint import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch @@ -38,10 +38,11 @@ class CompactControlsOverlayPatch : BytecodePatch( override fun execute(context: BytecodeContext): PatchResult { YouTubeControlsOverlayFingerprint.result?.let { - with (context - .toMethodWalker(it.method) - .nextMethod(it.scanResult.patternScanResult!!.startIndex, true) - .getMethod() as MutableMethod + with( + context + .toMethodWalker(it.method) + .nextMethod(it.scanResult.patternScanResult!!.startIndex, true) + .getMethod() as MutableMethod ) { val insertIndex = implementation!!.instructions.size - 1 val targetRegister = getInstruction(insertIndex).registerA diff --git a/src/main/kotlin/app/revanced/patches/youtube/fullscreen/endscreenoverlay/patch/HideEndScreenOverlayPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/endscreenoverlay/patch/HideEndScreenOverlayPatch.kt index f3a67338f..de47797b0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/fullscreen/endscreenoverlay/patch/HideEndScreenOverlayPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/endscreenoverlay/patch/HideEndScreenOverlayPatch.kt @@ -13,7 +13,7 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.fullscreen.endscreenoverlay.fingerprints.EndScreenResultsFingerprint import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/fullscreen/fullscreenpanels/fingerprints/FullscreenEngagementPanelFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/fullscreenpanels/fingerprints/FullscreenEngagementPanelFingerprint.kt index 48713e69b..a7f944574 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/fullscreen/fullscreenpanels/fingerprints/FullscreenEngagementPanelFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/fullscreenpanels/fingerprints/FullscreenEngagementPanelFingerprint.kt @@ -6,5 +6,9 @@ import app.revanced.util.bytecode.isWideLiteralExists object FullscreenEngagementPanelFingerprint : MethodFingerprint( returnType = "L", - customFingerprint = { it, _ -> it.definingClass.endsWith("FullscreenEngagementPanelOverlay;") && it.isWideLiteralExists(FullScreenEngagementPanel) } + customFingerprint = { it, _ -> + it.definingClass.endsWith("FullscreenEngagementPanelOverlay;") && it.isWideLiteralExists( + FullScreenEngagementPanel + ) + } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/fullscreen/fullscreenpanels/patch/HideFullscreenPanelsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/fullscreenpanels/patch/HideFullscreenPanelsPatch.kt index d62ecc42a..ff02fbf84 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/fullscreen/fullscreenpanels/patch/HideFullscreenPanelsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/fullscreenpanels/patch/HideFullscreenPanelsPatch.kt @@ -16,8 +16,8 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.shared.fingerprints.LayoutConstructorFingerprint +import app.revanced.patches.youtube.utils.fingerprints.LayoutConstructorFingerprint +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.fullscreen.fullscreenpanels.fingerprints.FullscreenEngagementPanelFingerprint import app.revanced.patches.youtube.fullscreen.fullscreenpanels.fingerprints.FullscreenViewAdderFingerprint import app.revanced.patches.youtube.utils.quickactionscontainer.patch.HideQuickActionsContainerPatch @@ -83,7 +83,8 @@ class HideFullscreenPanelsPatch : BytecodePatch( LayoutConstructorFingerprint.result?.let { it.mutableMethod.apply { - val dummyRegister = getInstruction(getStringIndex("1.0x")).registerA + val dummyRegister = + getInstruction(getStringIndex("1.0x")).registerA val invokeIndex = implementation!!.instructions.indexOfFirst { instruction -> instruction.opcode == Opcode.INVOKE_VIRTUAL && diff --git a/src/main/kotlin/app/revanced/patches/youtube/fullscreen/landscapemode/fingerprints/OrientationPrimaryFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/landscapemode/fingerprints/OrientationPrimaryFingerprint.kt index a651cfa4c..aeb620a40 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/fullscreen/landscapemode/fingerprints/OrientationPrimaryFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/landscapemode/fingerprints/OrientationPrimaryFingerprint.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -object OrientationPrimaryFingerprint : MethodFingerprint ( +object OrientationPrimaryFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, parameters = listOf("L"), @@ -13,5 +13,5 @@ object OrientationPrimaryFingerprint : MethodFingerprint ( Opcode.INVOKE_STATIC, Opcode.MOVE_RESULT ), - customFingerprint = { it, _ -> it.name == ""} + customFingerprint = { it, _ -> it.name == "" } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/fullscreen/landscapemode/fingerprints/OrientationSecondaryFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/landscapemode/fingerprints/OrientationSecondaryFingerprint.kt index 261aef324..ed052e714 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/fullscreen/landscapemode/fingerprints/OrientationSecondaryFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/landscapemode/fingerprints/OrientationSecondaryFingerprint.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -object OrientationSecondaryFingerprint : MethodFingerprint ( +object OrientationSecondaryFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, parameters = listOf("L"), diff --git a/src/main/kotlin/app/revanced/patches/youtube/fullscreen/landscapemode/patch/LandScapeModePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/landscapemode/patch/LandScapeModePatch.kt index 3263aa6dd..c75241307 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/fullscreen/landscapemode/patch/LandScapeModePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/landscapemode/patch/LandScapeModePatch.kt @@ -14,8 +14,10 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.fullscreen.landscapemode.fingerprints.* +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility +import app.revanced.patches.youtube.fullscreen.landscapemode.fingerprints.OrientationParentFingerprint +import app.revanced.patches.youtube.fullscreen.landscapemode.fingerprints.OrientationPrimaryFingerprint +import app.revanced.patches.youtube.fullscreen.landscapemode.fingerprints.OrientationSecondaryFingerprint import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.FULLSCREEN import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @@ -35,7 +37,8 @@ class LandScapeModePatch : BytecodePatch( OrientationPrimaryFingerprint, OrientationSecondaryFingerprint ).forEach { - it.also { it.resolve(context, classDef) }.result?.injectOverride() ?: return it.toErrorResult() + it.also { it.resolve(context, classDef) }.result?.injectOverride() + ?: return it.toErrorResult() } } ?: return OrientationParentFingerprint.toErrorResult() @@ -64,7 +67,7 @@ class LandScapeModePatch : BytecodePatch( val register = getInstruction(index).registerA addInstructions( - index +1, """ + index + 1, """ invoke-static {v$register}, $INTEGRATIONS_CLASS_DESCRIPTOR move-result v$register """ diff --git a/src/main/kotlin/app/revanced/patches/youtube/fullscreen/quickactions/patch/QuickActionsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/quickactions/patch/QuickActionsPatch.kt index 2135d3462..fb6003158 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/fullscreen/quickactions/patch/QuickActionsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/quickactions/patch/QuickActionsPatch.kt @@ -9,8 +9,8 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.youtube.ads.general.resource.patch.GeneralAdsPatch +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.quickactionscontainer.patch.HideQuickActionsContainerPatch import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/accountmenu/patch/AccountMenuPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/accountmenu/patch/AccountMenuPatch.kt index 3af7db96f..ef2f45a2c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/accountmenu/patch/AccountMenuPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/accountmenu/patch/AccountMenuPatch.kt @@ -13,7 +13,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.general.accountmenu.fingerprints.AccountMenuFingerprint import app.revanced.patches.youtube.general.accountmenu.fingerprints.AccountMenuParentFingerprint import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/autocaptions/patch/AutoCaptionsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/autocaptions/patch/AutoCaptionsPatch.kt index 9ea77f95e..f404cfcf2 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/autocaptions/patch/AutoCaptionsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/autocaptions/patch/AutoCaptionsPatch.kt @@ -15,9 +15,9 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.shared.fingerprints.SubtitleButtonControllerFingerprint -import app.revanced.patches.shared.fingerprints.SubtitleTrackFingerprint +import app.revanced.patches.youtube.utils.fingerprints.SubtitleButtonControllerFingerprint +import app.revanced.patches.shared.fingerprints.captions.SubtitleTrackFingerprint +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.general.autocaptions.fingerprints.StartVideoInformerFingerprint import app.revanced.patches.youtube.utils.playertype.patch.PlayerTypeHookPatch import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch @@ -51,7 +51,7 @@ class AutoCaptionsPatch : BytecodePatch( const/4 v0, ${status.value} sput-boolean v0, $GENERAL->captionsButtonStatus:Z """ - )?: return fingerprint.toErrorResult() + ) ?: return fingerprint.toErrorResult() } SubtitleTrackFingerprint.result?.let { diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/autopopuppanels/patch/PlayerPopupPanelsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/autopopuppanels/patch/PlayerPopupPanelsPatch.kt index aea06d0a0..799686033 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/autopopuppanels/patch/PlayerPopupPanelsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/autopopuppanels/patch/PlayerPopupPanelsPatch.kt @@ -13,7 +13,7 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.general.autopopuppanels.fingerprints.EngagementPanelControllerFingerprint import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.GENERAL diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/categorybar/patch/CategoryBarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/categorybar/patch/CategoryBarPatch.kt index 1a11f97a9..2bb70293e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/categorybar/patch/CategoryBarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/categorybar/patch/CategoryBarPatch.kt @@ -13,7 +13,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.general.categorybar.fingerprints.FilterBarHeightFingerprint import app.revanced.patches.youtube.general.categorybar.fingerprints.RelatedChipCloudFingerprint import app.revanced.patches.youtube.general.categorybar.fingerprints.SearchResultsChipBarFingerprint @@ -76,8 +76,9 @@ class CategoryBarPatch : BytecodePatch( return PatchResultSuccess() } + private companion object { - private fun MethodFingerprint.patch( + private fun MethodFingerprint.patch( insertIndexOffset: Int = 0, hookRegisterOffset: Int = 0, instructions: (Int) -> String @@ -87,7 +88,8 @@ class CategoryBarPatch : BytecodePatch( val endIndex = it.scanResult.patternScanResult!!.endIndex val insertIndex = endIndex + insertIndexOffset - val register = getInstruction(endIndex + hookRegisterOffset).registerA + val register = + getInstruction(endIndex + hookRegisterOffset).registerA addInstructions(insertIndex, instructions(register)) } diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/channellistsubmenu/patch/ChannelListSubMenuPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/channellistsubmenu/patch/ChannelListSubMenuPatch.kt index 9e3cbbf34..e45dd1eea 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/channellistsubmenu/patch/ChannelListSubMenuPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/channellistsubmenu/patch/ChannelListSubMenuPatch.kt @@ -12,7 +12,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.general.channellistsubmenu.fingerprints.ChannelListSubMenuFingerprint import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch @@ -42,7 +42,7 @@ class ChannelListSubMenuPatch : BytecodePatch( addInstruction( endIndex + 1, - "invoke-static {v$register}, $GENERAL->hideChannelListSubMenu(Landroid/view/View;)V" + "invoke-static {v$register}, $GENERAL->hideChannelListSubMenu(Landroid/view/View;)V" ) } } ?: return ChannelListSubMenuFingerprint.toErrorResult() diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/crowdfundingbox/patch/CrowdfundingBoxPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/crowdfundingbox/patch/CrowdfundingBoxPatch.kt index 64fa35be4..4eb4f4138 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/crowdfundingbox/patch/CrowdfundingBoxPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/crowdfundingbox/patch/CrowdfundingBoxPatch.kt @@ -12,7 +12,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.general.crowdfundingbox.fingerprints.CrowdfundingBoxFingerprint import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/floatingmicrophone/patch/FloatingMicrophonePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/floatingmicrophone/patch/FloatingMicrophonePatch.kt index b27c068ed..8f2688a2b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/floatingmicrophone/patch/FloatingMicrophonePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/floatingmicrophone/patch/FloatingMicrophonePatch.kt @@ -12,7 +12,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.general.floatingmicrophone.fingerprints.FloatingMicrophoneFingerprint import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/headerswitch/patch/HeaderSwitchPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/headerswitch/patch/HeaderSwitchPatch.kt index 6397c27c6..3c7e78d03 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/headerswitch/patch/HeaderSwitchPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/headerswitch/patch/HeaderSwitchPatch.kt @@ -12,7 +12,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.WordMarkHeader import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch @@ -45,7 +45,8 @@ class HeaderSwitchPatch : BytecodePatch() { .findMutableMethodOf(method) .apply { val targetIndex = getWideLiteralIndex(WordMarkHeader) - val targetRegister = getInstruction(targetIndex).registerA + val targetRegister = + getInstruction(targetIndex).registerA addInstructions( targetIndex + 1, """ diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/loadmorebutton/patch/LoadMoreButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/loadmorebutton/patch/LoadMoreButtonPatch.kt index 5cb643abc..80fd08b31 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/loadmorebutton/patch/LoadMoreButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/loadmorebutton/patch/LoadMoreButtonPatch.kt @@ -12,7 +12,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.general.loadmorebutton.fingerprints.LoadMoreButtonFingerprint import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch @@ -31,7 +31,7 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @YouTubeCompatibility @Version("0.0.1") class LoadMoreButtonPatch : BytecodePatch( - listOf(LoadMoreButtonFingerprint,) + listOf(LoadMoreButtonFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { LoadMoreButtonFingerprint.result?.let { @@ -43,7 +43,7 @@ class LoadMoreButtonPatch : BytecodePatch( "invoke-static {v$targetRegister}, $GENERAL->hideLoadMoreButton(Landroid/view/View;)V" ) } - }?: return LoadMoreButtonFingerprint.toErrorResult() + } ?: return LoadMoreButtonFingerprint.toErrorResult() /** * Add settings diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/mixplaylists/patch/MixPlaylistsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/mixplaylists/patch/MixPlaylistsPatch.kt index 02271d0b7..e02c27ea4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/mixplaylists/patch/MixPlaylistsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/mixplaylists/patch/MixPlaylistsPatch.kt @@ -14,8 +14,8 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.shared.fingerprints.EmptyComponentBuilderFingerprint +import app.revanced.patches.shared.fingerprints.litho.EmptyComponentBuilderFingerprint +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.general.mixplaylists.fingerprints.BottomPanelOverlayTextFingerprint import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.bytecode.getStringIndex diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/personalinformation/patch/HideEmailAddressPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/personalinformation/patch/HideEmailAddressPatch.kt index ae92332f5..2ef5e6c12 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/personalinformation/patch/HideEmailAddressPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/personalinformation/patch/HideEmailAddressPatch.kt @@ -12,7 +12,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.general.personalinformation.fingerprints.AccountSwitcherAccessibilityLabelFingerprint import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.GENERAL diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/searchterms/patch/SearchTermsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/searchterms/patch/SearchTermsPatch.kt index f6574f7c1..49687e02e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/searchterms/patch/SearchTermsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/searchterms/patch/SearchTermsPatch.kt @@ -13,7 +13,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.general.searchterms.fingerprints.SearchEndpointFingerprint import app.revanced.patches.youtube.general.searchterms.fingerprints.SearchEndpointParentFingerprint import app.revanced.patches.youtube.general.searchterms.fingerprints.SearchSuggestionEntryFingerprint @@ -44,10 +44,16 @@ class SearchTermsPatch : BytecodePatch( override fun execute(context: BytecodeContext): PatchResult { SearchEndpointParentFingerprint.result?.let { parentResult -> - SearchEndpointFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let { + SearchEndpointFingerprint.also { + it.resolve( + context, + parentResult.classDef + ) + }.result?.let { it.mutableMethod.apply { val targetIndex = it.scanResult.patternScanResult!!.startIndex + 1 - val targetRegister = getInstruction(targetIndex).registerA + val targetRegister = + getInstruction(targetIndex).registerA addInstruction( targetIndex + 1, diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/snackbar/patch/HideSnackBarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/snackbar/patch/HideSnackBarPatch.kt index c4b48b01b..5d3c16b06 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/snackbar/patch/HideSnackBarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/snackbar/patch/HideSnackBarPatch.kt @@ -13,7 +13,7 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.general.snackbar.fingerprints.HideSnackBarFingerprint import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.GENERAL diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/stories/patch/HideStoriesPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/stories/patch/HideStoriesPatch.kt index 8c3f59a62..0e6e4bd9e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/stories/patch/HideStoriesPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/stories/patch/HideStoriesPatch.kt @@ -12,8 +12,8 @@ import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.formats.Instruction22c @@ -40,7 +40,7 @@ class HideStoriesPatch : BytecodePatch() { ).map { name -> ResourceMappingPatch.resourceMappings.single { it.name == name }.id } - private var patchSuccessArray = Array(resourceIds.size) {false} + private var patchSuccessArray = Array(resourceIds.size) { false } override fun execute(context: BytecodeContext): PatchResult { context.classes.forEach { classDef -> @@ -55,10 +55,19 @@ class HideStoriesPatch : BytecodePatch() { val iPutInstruction = instructions.elementAt(insertIndex) if (iPutInstruction.opcode != Opcode.IPUT_OBJECT) return@forEachIndexed - val mutableMethod = context.proxy(classDef).mutableClass.findMutableMethodOf(method) + val mutableMethod = + context.proxy(classDef).mutableClass.findMutableMethodOf( + method + ) - val viewRegister = (iPutInstruction as Instruction22c).registerA - mutableMethod.implementation!!.injectHideCall(insertIndex, viewRegister, "layout/GeneralPatch", "hideStoriesShelf") + val viewRegister = + (iPutInstruction as Instruction22c).registerA + mutableMethod.implementation!!.injectHideCall( + insertIndex, + viewRegister, + "layout/GeneralPatch", + "hideStoriesShelf" + ) patchSuccessArray[0] = true patchSuccessArray[1] = true @@ -69,15 +78,25 @@ class HideStoriesPatch : BytecodePatch() { val iPutInstruction = instructions.elementAt(insertIndex) if (iPutInstruction.opcode != Opcode.IPUT_OBJECT) return@forEachIndexed - val mutableMethod = context.proxy(classDef).mutableClass.findMutableMethodOf(method) + val mutableMethod = + context.proxy(classDef).mutableClass.findMutableMethodOf( + method + ) - val viewRegister = (iPutInstruction as Instruction22c).registerA - mutableMethod.implementation!!.injectHideCall(insertIndex, viewRegister, "layout/GeneralPatch", "hideStoriesShelf") + val viewRegister = + (iPutInstruction as Instruction22c).registerA + mutableMethod.implementation!!.injectHideCall( + insertIndex, + viewRegister, + "layout/GeneralPatch", + "hideStoriesShelf" + ) patchSuccessArray[2] = true } } } + else -> return@forEachIndexed } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/suggestions/patch/SuggestionsShelfPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/suggestions/patch/SuggestionsShelfPatch.kt index f1b0217f4..e06f6c657 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/suggestions/patch/SuggestionsShelfPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/suggestions/patch/SuggestionsShelfPatch.kt @@ -12,7 +12,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.general.suggestions.fingerprints.BreakingNewsFingerprint import app.revanced.patches.youtube.utils.litho.patch.LithoFilterPatch import app.revanced.patches.youtube.utils.navbarindex.patch.NavBarIndexPatch @@ -49,6 +49,20 @@ class SuggestionsShelfPatch : BytecodePatch( } } ?: return BreakingNewsFingerprint.toErrorResult() + /* + SuggestionContentsBuilderFingerprint.result?.let { + it.mutableMethod.apply { + addInstructionsWithLabels( + 2, """ + invoke-static/range {p2 .. p2}, $GENERAL->hideSuggestionsShelf(Ljava/lang/Object;)Z + move-result v0 + if-eqz v0, :not_an_ad + """ + emptyComponentLabel, ExternalLabel("not_an_ad", getInstruction(2)) + ) + } + } ?: return SuggestionContentsBuilderFingerprint.toErrorResult() + */ + /** * Add settings diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/tabletminiplayer/patch/TabletMiniPlayerPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/tabletminiplayer/patch/TabletMiniPlayerPatch.kt index f2dfb8c7b..2d22ea984 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/tabletminiplayer/patch/TabletMiniPlayerPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/tabletminiplayer/patch/TabletMiniPlayerPatch.kt @@ -16,7 +16,7 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.general.tabletminiplayer.fingerprints.MiniPlayerDimensionsCalculatorFingerprint import app.revanced.patches.youtube.general.tabletminiplayer.fingerprints.MiniPlayerOverrideFingerprint import app.revanced.patches.youtube.general.tabletminiplayer.fingerprints.MiniPlayerOverrideNoContextFingerprint @@ -49,9 +49,17 @@ class TabletMiniPlayerPatch : BytecodePatch( override fun execute(context: BytecodeContext): PatchResult { MiniPlayerDimensionsCalculatorFingerprint.result?.let { parentResult -> - MiniPlayerOverrideNoContextFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let { result -> + MiniPlayerOverrideNoContextFingerprint.also { + it.resolve( + context, + parentResult.classDef + ) + }.result?.let { result -> val (method, _, parameterRegister) = result.addProxyCall() - method.insertOverride(method.implementation!!.instructions.size - 1, parameterRegister) + method.insertOverride( + method.implementation!!.instructions.size - 1, + parameterRegister + ) } ?: return MiniPlayerOverrideNoContextFingerprint.toErrorResult() } ?: return MiniPlayerDimensionsCalculatorFingerprint.toErrorResult() @@ -115,7 +123,8 @@ class TabletMiniPlayerPatch : BytecodePatch( fun MethodFingerprintResult.unwrap(): Triple { val scanIndex = this.scanResult.patternScanResult!!.endIndex val method = this.mutableMethod - val parameterRegister = method.getInstruction(scanIndex).registerA + val parameterRegister = + method.getInstruction(scanIndex).registerA return Triple(method, scanIndex, parameterRegister) } diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/widesearchbar/patch/WideSearchbarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/widesearchbar/patch/WideSearchbarPatch.kt index ea748525d..65ea46cdc 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/widesearchbar/patch/WideSearchbarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/widesearchbar/patch/WideSearchbarPatch.kt @@ -14,7 +14,7 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.general.widesearchbar.fingerprints.SetActionBarRingoFingerprint import app.revanced.patches.youtube.general.widesearchbar.fingerprints.SetToolBarPaddingFingerprint import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingIconMMTPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingIconMMTPatch.kt index 95ef4a69a..d0ddec8d3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingIconMMTPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingIconMMTPatch.kt @@ -9,7 +9,7 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.resources.IconHelper.customIcon import app.revanced.util.resources.ResourceHelper.updatePatchStatusIcon diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingIconRevancifyBluePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingIconRevancifyBluePatch.kt index 5058aeef0..fc8b45953 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingIconRevancifyBluePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingIconRevancifyBluePatch.kt @@ -9,7 +9,7 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.resources.IconHelper.customIcon import app.revanced.util.resources.ResourceHelper.updatePatchStatusIcon diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingIconRevancifyRedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingIconRevancifyRedPatch.kt index 3b0034876..6558f2db8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingIconRevancifyRedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingIconRevancifyRedPatch.kt @@ -9,7 +9,7 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.resources.IconHelper.customIcon import app.revanced.util.resources.ResourceHelper.updatePatchStatusIcon diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/branding/name/patch/CustomBrandingNamePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/name/patch/CustomBrandingNamePatch.kt index a3d0223d1..8ed047185 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/branding/name/patch/CustomBrandingNamePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/name/patch/CustomBrandingNamePatch.kt @@ -5,10 +5,14 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.ResourceContext -import app.revanced.patcher.patch.* +import app.revanced.patcher.patch.OptionsContainer +import app.revanced.patcher.patch.PatchOption +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.resources.ResourceHelper.updatePatchStatusLabel import org.w3c.dom.Element @@ -31,7 +35,7 @@ class CustomBrandingNamePatch : ResourcePatch { // for each file in the "layouts" directory replace all necessary attributes content context.xmlEditor[it.absolutePath].use { editor -> - val resourcesNode = editor.file.getElementsByTagName("resources").item(0) as Element + val resourcesNode = editor.file.getElementsByTagName("resources").item(0) as Element for (i in 0 until resourcesNode.childNodes.length) { val node = resourcesNode.childNodes.item(i) @@ -50,6 +54,7 @@ class CustomBrandingNamePatch : ResourcePatch { return PatchResultSuccess() } + companion object : OptionsContainer() { var YouTubeAppName: String? by option( PatchOption.StringOption( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/doubletapbackground/patch/DoubleTapOverlayBackgroundPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/doubletapbackground/patch/DoubleTapOverlayBackgroundPatch.kt index 81279fb26..4fc345f02 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/doubletapbackground/patch/DoubleTapOverlayBackgroundPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/doubletapbackground/patch/DoubleTapOverlayBackgroundPatch.kt @@ -9,7 +9,7 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch @Patch(false) @@ -30,14 +30,16 @@ class DoubleTapOverlayBackgroundPatch : ResourcePatch { view.attributes.getNamedItem("android:id").nodeValue.endsWith("tap_bloom_view") ) { attributes.forEach { attribute -> - view.attributes.getNamedItem("android:layout_$attribute").nodeValue = "0.0dip" + view.attributes.getNamedItem("android:layout_$attribute").nodeValue = + "0.0dip" } } if ( view.hasAttributes() && view.attributes.getNamedItem("android:id").nodeValue.endsWith("dark_background") ) { - view.attributes.getNamedItem("android:src").nodeValue = "@color/full_transparent" + view.attributes.getNamedItem("android:src").nodeValue = + "@color/full_transparent" break } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/doubletaplength/patch/DoubleTapLengthPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/doubletaplength/patch/DoubleTapLengthPatch.kt index 2ed31d7fc..38fdcbd26 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/doubletaplength/patch/DoubleTapLengthPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/doubletaplength/patch/DoubleTapLengthPatch.kt @@ -5,10 +5,14 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.OptionsContainer -import app.revanced.patcher.patch.* +import app.revanced.patcher.patch.PatchOption +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultError +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.resources.ResourceHelper.addEntryValues import app.revanced.util.resources.ResourceUtils @@ -40,7 +44,7 @@ class DoubleTapLengthPatch : ResourcePatch { val length = DoubleTapLengthArrays ?: return PatchResultError("Invalid double-tap length array.") - val splits = length.replace(" ","").split(",") + val splits = length.replace(" ", "").split(",") if (splits.isEmpty()) throw IllegalArgumentException("Invalid double-tap length elements") val lengthElements = splits.map { it } for (index in 0 until splits.count()) { diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/forcebackground/patch/PlayerButtonBackgroundPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/forcebackground/patch/PlayerButtonBackgroundPatch.kt index dc0091bd8..66be23553 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/forcebackground/patch/PlayerButtonBackgroundPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/forcebackground/patch/PlayerButtonBackgroundPatch.kt @@ -10,7 +10,7 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import org.w3c.dom.Element diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/forceheader/patch/PremiumHeadingPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/forceheader/patch/PremiumHeadingPatch.kt index f7aa1d37c..f48c8e560 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/forceheader/patch/PremiumHeadingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/forceheader/patch/PremiumHeadingPatch.kt @@ -10,7 +10,7 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import java.nio.file.Files import java.nio.file.StandardCopyOption diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/materialyou/patch/MaterialYouPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/materialyou/patch/MaterialYouPatch.kt index 3cfc33eee..5c58faf7b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/materialyou/patch/MaterialYouPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/materialyou/patch/MaterialYouPatch.kt @@ -9,7 +9,7 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.layout.theme.patch.GeneralThemePatch import app.revanced.patches.youtube.layout.theme.patch.GeneralThemePatch.Companion.isMonetPatchIncluded import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/optimize/patch/OptimizeResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/optimize/patch/OptimizeResourcePatch.kt index 74f9f3362..d076635cf 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/optimize/patch/OptimizeResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/optimize/patch/OptimizeResourcePatch.kt @@ -9,7 +9,7 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch @Patch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/optimize/patch/RedundantResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/optimize/patch/RedundantResourcePatch.kt index 8342744f9..d5a2a86af 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/optimize/patch/RedundantResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/optimize/patch/RedundantResourcePatch.kt @@ -7,7 +7,7 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.util.resources.ResourceUtils import app.revanced.util.resources.ResourceUtils.copyResources import java.io.File @@ -35,22 +35,23 @@ class RedundantResourcePatch : ResourcePatch { (WHITELIST_GENERAL + array).forEach { name -> try { Files.copy( - context["res"].resolve("$path/$name").toPath(), - context["res"].resolve("$tmpDirectory/$name").toPath(), - StandardCopyOption.REPLACE_EXISTING + context["res"].resolve("$path/$name").toPath(), + context["res"].resolve("$tmpDirectory/$name").toPath(), + StandardCopyOption.REPLACE_EXISTING ) - } catch (_: Exception) {} + } catch (_: Exception) { + } } val directoryPath = context["res"].resolve(path) Files.walk(directoryPath.toPath()) - .map(Path::toFile) - .sorted(Comparator.reverseOrder()) - .forEach(File::delete) + .map(Path::toFile) + .sorted(Comparator.reverseOrder()) + .forEach(File::delete) Files.move( - context["res"].resolve(tmpDirectory).toPath(), - context["res"].resolve(path).toPath() + context["res"].resolve(tmpDirectory).toPath(), + context["res"].resolve(path).toPath() ) } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/pipnotification/patch/PiPNotificationPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/pipnotification/patch/PiPNotificationPatch.kt index 504b2e09e..b421973f4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/pipnotification/patch/PiPNotificationPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/pipnotification/patch/PiPNotificationPatch.kt @@ -11,7 +11,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.layout.pipnotification.fingerprints.PrimaryPiPFingerprint import app.revanced.patches.youtube.layout.pipnotification.fingerprints.SecondaryPiPFingerprint import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/splashanimation/patch/AddSplashAnimationPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/splashanimation/patch/AddSplashAnimationPatch.kt index ad36b482d..75a2ffd00 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/splashanimation/patch/AddSplashAnimationPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/splashanimation/patch/AddSplashAnimationPatch.kt @@ -8,7 +8,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.util.resources.ResourceUtils import app.revanced.util.resources.ResourceUtils.copyResources import app.revanced.util.resources.ResourceUtils.copyXmlNode diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/patch/GeneralThemePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/patch/GeneralThemePatch.kt index 81349340e..19267a19a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/patch/GeneralThemePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/patch/GeneralThemePatch.kt @@ -40,7 +40,8 @@ class GeneralThemePatch : ResourcePatch { context.xmlEditor[stylesPath].use { editor -> val file = editor.file - val childNodes = (file.getElementsByTagName("resources").item(0) as Element).childNodes + val childNodes = + (file.getElementsByTagName("resources").item(0) as Element).childNodes for (i in 0 until childNodes.length) { val node = childNodes.item(i) as? Element ?: continue @@ -64,10 +65,12 @@ class GeneralThemePatch : ResourcePatch { "Base.Theme.YouTube.Launcher.Light" -> "@color/yt_white1" else -> "null" } + 1 -> when (nodeAttributeName) { "Base.Theme.YouTube.Launcher" -> "?attr/splashScreenColor" else -> "null" } + else -> "null" } ) @@ -91,6 +94,7 @@ class GeneralThemePatch : ResourcePatch { return PatchResultSuccess() } + internal companion object { var isMonetPatchIncluded: Boolean = false } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/patch/ThemePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/patch/ThemePatch.kt index 4173c7a05..bd93336a9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/patch/ThemePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/patch/ThemePatch.kt @@ -4,10 +4,14 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.ResourceContext -import app.revanced.patcher.patch.* +import app.revanced.patcher.patch.OptionsContainer +import app.revanced.patcher.patch.PatchOption +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.layout.theme.patch.GeneralThemePatch.Companion.isMonetPatchIncluded import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.resources.ResourceHelper.updatePatchStatusTheme diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/tooltip/patch/TooltipContentViewPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/tooltip/patch/TooltipContentViewPatch.kt index 670fb21e2..aac4766aa 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/tooltip/patch/TooltipContentViewPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/tooltip/patch/TooltipContentViewPatch.kt @@ -11,7 +11,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.layout.tooltip.fingerprints.TooltipContentViewFingerprint import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/ambientmode/patch/PowerSaveModePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/ambientmode/patch/PowerSaveModePatch.kt index f4b8b0b2b..9665b8c61 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/ambientmode/patch/PowerSaveModePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/ambientmode/patch/PowerSaveModePatch.kt @@ -13,7 +13,7 @@ import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.misc.ambientmode.fingerprints.PowerSaveModeFingerprint import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.MISC_PATH diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/patch/DebuggingPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/patch/DebuggingPatch.kt index 84f3fca43..770729167 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/patch/DebuggingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/patch/DebuggingPatch.kt @@ -9,7 +9,7 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch @Patch(false) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/patch/ExternalBrowserPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/patch/ExternalBrowserPatch.kt index 22d5ec649..4ceb64707 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/patch/ExternalBrowserPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/patch/ExternalBrowserPatch.kt @@ -12,8 +12,10 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.misc.externalbrowser.fingerprints.* +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility +import app.revanced.patches.youtube.misc.externalbrowser.fingerprints.ExternalBrowserPrimaryFingerprint +import app.revanced.patches.youtube.misc.externalbrowser.fingerprints.ExternalBrowserSecondaryFingerprint +import app.revanced.patches.youtube.misc.externalbrowser.fingerprints.ExternalBrowserTertiaryFingerprint import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.MISC_PATH import org.jf.dexlib2.iface.instruction.OneRegisterInstruction diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/forceopus/patch/ForceOpusCodecPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/forceopus/patch/ForceOpusCodecPatch.kt index 8f5d1919a..4cb85ec79 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/forceopus/patch/ForceOpusCodecPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/forceopus/patch/ForceOpusCodecPatch.kt @@ -8,8 +8,8 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.shared.patch.opus.AbstractOpusCodecsPatch +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.MISC_PATH diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/forcevp9/patch/ForceVP9CodecPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/forcevp9/patch/ForceVP9CodecPatch.kt index 5ad8d82e3..9ab79e03b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/forcevp9/patch/ForceVP9CodecPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/forcevp9/patch/ForceVP9CodecPatch.kt @@ -16,9 +16,14 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.shared.fingerprints.LayoutSwitchFingerprint -import app.revanced.patches.youtube.misc.forcevp9.fingerprints.* +import app.revanced.patches.youtube.utils.fingerprints.LayoutSwitchFingerprint +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility +import app.revanced.patches.youtube.misc.forcevp9.fingerprints.VideoCapabilitiesFingerprint +import app.revanced.patches.youtube.misc.forcevp9.fingerprints.VideoCapabilitiesParentFingerprint +import app.revanced.patches.youtube.misc.forcevp9.fingerprints.Vp9PrimaryFingerprint +import app.revanced.patches.youtube.misc.forcevp9.fingerprints.Vp9PropsFingerprint +import app.revanced.patches.youtube.misc.forcevp9.fingerprints.Vp9PropsParentFingerprint +import app.revanced.patches.youtube.misc.forcevp9.fingerprints.Vp9SecondaryFingerprint import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.MISC_PATH import org.jf.dexlib2.Opcode @@ -46,12 +51,18 @@ class ForceVP9CodecPatch : BytecodePatch( Vp9PrimaryFingerprint, Vp9SecondaryFingerprint ).forEach { fingerprint -> - fingerprint.also { it.resolve(context, classDef) }.result?.injectOverride() ?: return fingerprint.toErrorResult() + fingerprint.also { it.resolve(context, classDef) }.result?.injectOverride() + ?: return fingerprint.toErrorResult() } } ?: return LayoutSwitchFingerprint.toErrorResult() Vp9PropsParentFingerprint.result?.let { parentResult -> - Vp9PropsFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.let { + Vp9PropsFingerprint.also { + it.resolve( + context, + parentResult.classDef + ) + }.result?.mutableMethod?.let { mapOf( "MANUFACTURER" to "getManufacturer", "BRAND" to "getBrand", @@ -63,7 +74,12 @@ class ForceVP9CodecPatch : BytecodePatch( } ?: return Vp9PropsParentFingerprint.toErrorResult() VideoCapabilitiesParentFingerprint.result?.let { parentResult -> - VideoCapabilitiesFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let { + VideoCapabilitiesFingerprint.also { + it.resolve( + context, + parentResult.classDef + ) + }.result?.let { it.mutableMethod.apply { val insertIndex = it.scanResult.patternScanResult!!.startIndex @@ -143,7 +159,8 @@ class ForceVP9CodecPatch : BytecodePatch( for ((index, instruction) in implementation!!.instructions.withIndex()) { if (instruction.opcode != Opcode.SGET_OBJECT) continue - val indexString = ((instruction as? ReferenceInstruction)?.reference as? DexBackedFieldReference).toString() + val indexString = + ((instruction as? ReferenceInstruction)?.reference as? DexBackedFieldReference).toString() if (indexString != targetString) continue diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/language/patch/LanguageSelectorPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/language/patch/LanguageSelectorPatch.kt index 0fa7e79ec..6bd538e66 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/language/patch/LanguageSelectorPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/language/patch/LanguageSelectorPatch.kt @@ -12,7 +12,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.misc.language.fingerprints.GeneralPrefsFingerprint import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import org.jf.dexlib2.iface.instruction.OneRegisterInstruction diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/layoutswitch/patch/LayoutSwitchPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/layoutswitch/patch/LayoutSwitchPatch.kt index de5d07a7e..5429a3f31 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/layoutswitch/patch/LayoutSwitchPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/layoutswitch/patch/LayoutSwitchPatch.kt @@ -17,8 +17,8 @@ import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.shared.fingerprints.LayoutSwitchFingerprint +import app.revanced.patches.youtube.utils.fingerprints.LayoutSwitchFingerprint +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.misc.layoutswitch.fingerprints.ClientFormFactorFingerprint import app.revanced.patches.youtube.misc.layoutswitch.fingerprints.ClientFormFactorParentFingerprint import app.revanced.patches.youtube.misc.layoutswitch.fingerprints.ClientFormFactorWalkerFingerprint @@ -56,18 +56,23 @@ class LayoutSwitchPatch : BytecodePatch( mutableMethod.injectTabletLayout(scanResult.patternScanResult!!.startIndex + 1) } } catch (_: Exception) { - ClientFormFactorWalkerFingerprint.also { it.resolve(context, classDef) }.result?.let { + ClientFormFactorWalkerFingerprint.also { + it.resolve( + context, + classDef + ) + }.result?.let { (context .toMethodWalker(it.method) .nextMethod(it.scanResult.patternScanResult!!.startIndex, true) .getMethod() as MutableMethod).apply { - val jumpIndex = implementation!!.instructions.indexOfFirst { instruction -> - instruction.opcode == Opcode.RETURN_OBJECT - } - 1 + val jumpIndex = implementation!!.instructions.indexOfFirst { instruction -> + instruction.opcode == Opcode.RETURN_OBJECT + } - 1 injectTabletLayout(jumpIndex) - } + } } ?: return ClientFormFactorWalkerFingerprint.toErrorResult() } } ?: return ClientFormFactorParentFingerprint.toErrorResult() diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/patch/MinimizedPlaybackPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/patch/MinimizedPlaybackPatch.kt index c5d8e0462..8677c83d1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/patch/MinimizedPlaybackPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/patch/MinimizedPlaybackPatch.kt @@ -14,8 +14,10 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.misc.minimizedplayback.fingerprints.* +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility +import app.revanced.patches.youtube.misc.minimizedplayback.fingerprints.KidsMinimizedPlaybackPolicyControllerFingerprint +import app.revanced.patches.youtube.misc.minimizedplayback.fingerprints.MinimizedPlaybackManagerFingerprint +import app.revanced.patches.youtube.misc.minimizedplayback.fingerprints.MinimizedPlaybackSettingsFingerprint import app.revanced.patches.youtube.utils.integrations.patch.IntegrationsPatch import app.revanced.patches.youtube.utils.playertype.patch.PlayerTypeHookPatch import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch @@ -48,7 +50,7 @@ class MinimizedPlaybackPatch : BytecodePatch( MinimizedPlaybackManagerFingerprint, MinimizedPlaybackSettingsFingerprint ).map { - it.result?.mutableMethod?: return it.toErrorResult() + it.result?.mutableMethod ?: return it.toErrorResult() } methods[0].hookKidsMiniPlayer() @@ -88,8 +90,8 @@ class MinimizedPlaybackPatch : BytecodePatch( val booleanIndex = booleanCalls.elementAt(1).index val booleanMethod = context.toMethodWalker(this) - .nextMethod(booleanIndex, true) - .getMethod() as MutableMethod + .nextMethod(booleanIndex, true) + .getMethod() as MutableMethod booleanMethod.addInstructions( 0, """ diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/openlinksdirectly/patch/OpenLinksDirectlyPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/openlinksdirectly/patch/OpenLinksDirectlyPatch.kt index c13a8d086..2d0551e49 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/openlinksdirectly/patch/OpenLinksDirectlyPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/openlinksdirectly/patch/OpenLinksDirectlyPatch.kt @@ -12,8 +12,9 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.misc.openlinksdirectly.fingerprints.* +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility +import app.revanced.patches.youtube.misc.openlinksdirectly.fingerprints.OpenLinksDirectlyFingerprintPrimary +import app.revanced.patches.youtube.misc.openlinksdirectly.fingerprints.OpenLinksDirectlyFingerprintSecondary import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.MISC_PATH import org.jf.dexlib2.iface.instruction.formats.Instruction35c diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/quic/patch/QUICProtocolPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/quic/patch/QUICProtocolPatch.kt index b5e160491..6eba13004 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/quic/patch/QUICProtocolPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/quic/patch/QUICProtocolPatch.kt @@ -11,8 +11,9 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.misc.quic.fingerprints.* +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility +import app.revanced.patches.youtube.misc.quic.fingerprints.CronetEngineBuilderFingerprint +import app.revanced.patches.youtube.misc.quic.fingerprints.ExperimentalCronetEngineBuilderFingerprint import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.MISC_PATH @@ -39,7 +40,7 @@ class QUICProtocolPatch : BytecodePatch( invoke-static {p1}, $MISC_PATH/QUICProtocolPatch;->disableQUICProtocol(Z)Z move-result p1 """ - )?: return it.toErrorResult() + ) ?: return it.toErrorResult() } /** diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/splashanimation/patch/NewSplashAnimationPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/splashanimation/patch/NewSplashAnimationPatch.kt index 6af780a4c..e3b1469af 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/splashanimation/patch/NewSplashAnimationPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/splashanimation/patch/NewSplashAnimationPatch.kt @@ -12,9 +12,9 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.misc.splashanimation.fingerprints.SplashAnimationBuilderFingerprint +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.bytecode.getWide32LiteralIndex import app.revanced.util.integrations.Constants.MISC_PATH import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/spoofappversion/patch/SpoofAppVersionPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/spoofappversion/patch/SpoofAppVersionPatch.kt index 12f95ffc3..fdc8dcf8e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/spoofappversion/patch/SpoofAppVersionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/spoofappversion/patch/SpoofAppVersionPatch.kt @@ -8,8 +8,8 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.shared.patch.versionspoof.AbstractVersionSpoofPatch +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch.Companion.contexts import app.revanced.util.integrations.Constants.MISC_PATH diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/translations/patch/TranslationsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/translations/patch/TranslationsPatch.kt index bb91dcce8..9565782c0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/translations/patch/TranslationsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/translations/patch/TranslationsPatch.kt @@ -9,7 +9,7 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.resources.ResourceHelper.addTranslations diff --git a/src/main/kotlin/app/revanced/patches/youtube/navigation/homepage/patch/ChangeHomePagePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/navigation/homepage/patch/ChangeHomePagePatch.kt index 04710c608..c10accc84 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/navigation/homepage/patch/ChangeHomePagePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/navigation/homepage/patch/ChangeHomePagePatch.kt @@ -14,7 +14,7 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.navigation.homepage.fingerprints.IntentExceptionFingerprint import app.revanced.patches.youtube.navigation.homepage.fingerprints.LauncherActivityFingerprint import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/navigation/label/patch/NavigationLabelPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/navigation/label/patch/NavigationLabelPatch.kt index 273a54a11..5a6618534 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/navigation/label/patch/NavigationLabelPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/navigation/label/patch/NavigationLabelPatch.kt @@ -12,7 +12,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.navigation.label.fingerprints.PivotBarSetTextFingerprint import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.NAVIGATION @@ -33,7 +33,8 @@ class NavigationLabelPatch : BytecodePatch( PivotBarSetTextFingerprint.result?.let { it.mutableMethod.apply { val targetIndex = it.scanResult.patternScanResult!!.endIndex - 2 - val targetReference = getInstruction(targetIndex).reference.toString() + val targetReference = + getInstruction(targetIndex).reference.toString() val targetRegister = getInstruction(targetIndex).registerA if (targetReference != "Landroid/widget/TextView;") diff --git a/src/main/kotlin/app/revanced/patches/youtube/navigation/navigationbuttons/patch/NavigationButtonsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/navigation/navigationbuttons/patch/NavigationButtonsPatch.kt index 0ae3ec497..ce6001992 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/navigation/navigationbuttons/patch/NavigationButtonsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/navigation/navigationbuttons/patch/NavigationButtonsPatch.kt @@ -13,8 +13,8 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.shared.fingerprints.PivotBarCreateButtonViewFingerprint +import app.revanced.patches.youtube.utils.fingerprints.PivotBarCreateButtonViewFingerprint +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.navigation.navigationbuttons.fingerprints.AutoMotiveFingerprint import app.revanced.patches.youtube.navigation.navigationbuttons.fingerprints.PivotBarEnumFingerprint import app.revanced.patches.youtube.navigation.navigationbuttons.fingerprints.PivotBarShortsButtonViewFingerprint @@ -50,7 +50,7 @@ class NavigationButtonsPatch : BytecodePatch( /** * Home, Shorts, Subscriptions Button */ - with ( + with( arrayOf( PivotBarEnumFingerprint, PivotBarShortsButtonViewFingerprint @@ -125,20 +125,21 @@ class NavigationButtonsPatch : BytecodePatch( return PatchResultSuccess() } + private companion object { const val enumHook = "sput-object v$REGISTER_TEMPLATE_REPLACEMENT, $NAVIGATION" + - "->" + - "lastPivotTab:Ljava/lang/Enum;" + "->" + + "lastPivotTab:Ljava/lang/Enum;" const val buttonHook = "invoke-static { v$REGISTER_TEMPLATE_REPLACEMENT }, $NAVIGATION" + - "->" + - "hideNavigationButton(Landroid/view/View;)V" + "->" + + "hideNavigationButton(Landroid/view/View;)V" const val createButtonHook = "invoke-static { v$REGISTER_TEMPLATE_REPLACEMENT }, $NAVIGATION" + - "->" + - "hideCreateButton(Landroid/view/View;)V" + "->" + + "hideCreateButton(Landroid/view/View;)V" } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/navigation/shortsnavbar/patch/ShortsNavBarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/navigation/shortsnavbar/patch/ShortsNavBarPatch.kt index 5319bf672..068bc3c98 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/navigation/shortsnavbar/patch/ShortsNavBarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/navigation/shortsnavbar/patch/ShortsNavBarPatch.kt @@ -16,8 +16,8 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.shared.fingerprints.PivotBarCreateButtonViewFingerprint +import app.revanced.patches.youtube.utils.fingerprints.PivotBarCreateButtonViewFingerprint +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.navigation.shortsnavbar.fingerprints.NavigationEndpointFingerprint import app.revanced.patches.youtube.navigation.shortsnavbar.fingerprints.ReelWatchBundleFingerprint import app.revanced.patches.youtube.navigation.shortsnavbar.fingerprints.ReelWatchEndpointFingerprint @@ -64,16 +64,21 @@ class ShortsNavBarPatch : BytecodePatch( .toMethodWalker(it.method) .nextMethod(it.scanResult.patternScanResult!!.endIndex, true) .getMethod() as MutableMethod - ).apply { - addInstruction( - 0, - "invoke-static {}, $NAVIGATION->hideShortsPlayerNavBar()V" - ) - } + ).apply { + addInstruction( + 0, + "invoke-static {}, $NAVIGATION->hideShortsPlayerNavBar()V" + ) + } } ?: return ReelWatchBundleFingerprint.toErrorResult() ReelWatchEndpointParentFingerprint.result?.let { parentResult -> - ReelWatchEndpointFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.addInstruction( + ReelWatchEndpointFingerprint.also { + it.resolve( + context, + parentResult.classDef + ) + }.result?.mutableMethod?.addInstruction( 0, "sput-object p1, $NAVIGATION->shortsContext:Landroid/content/Context;" ) ?: return ReelWatchEndpointFingerprint.toErrorResult() @@ -82,7 +87,7 @@ class ShortsNavBarPatch : BytecodePatch( NavigationEndpointFingerprint.result?.let { result -> val navigationEndpointMethod = result.mutableMethod - with (navigationEndpointMethod.implementation!!.instructions) { + with(navigationEndpointMethod.implementation!!.instructions) { filter { instruction -> val fieldReference = (instruction as? ReferenceInstruction)?.reference as? FieldReference diff --git a/src/main/kotlin/app/revanced/patches/youtube/navigation/tabletnavbar/patch/TabletNavigationBarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/navigation/tabletnavbar/patch/TabletNavigationBarPatch.kt index a620584f8..cb6a80e4e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/navigation/tabletnavbar/patch/TabletNavigationBarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/navigation/tabletnavbar/patch/TabletNavigationBarPatch.kt @@ -13,7 +13,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.navigation.tabletnavbar.fingerprints.PivotBarChangedFingerprint import app.revanced.patches.youtube.navigation.tabletnavbar.fingerprints.PivotBarStyleFingerprint import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch @@ -40,7 +40,7 @@ class TabletNavigationBarPatch : BytecodePatch( ).forEach { it.result?.insertHook() ?: return it.toErrorResult() } - + /** * Add settings */ @@ -55,10 +55,12 @@ class TabletNavigationBarPatch : BytecodePatch( return PatchResultSuccess() } + companion object { private fun MethodFingerprintResult.insertHook() { val targetIndex = scanResult.patternScanResult!!.startIndex + 1 - val register = mutableMethod.getInstruction(targetIndex).registerA + val register = + mutableMethod.getInstruction(targetIndex).registerA mutableMethod.addInstructions( targetIndex + 1, """ diff --git a/src/main/kotlin/app/revanced/patches/youtube/overlaybutton/autorepeat/fingerprints/VideoEndFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/overlaybutton/autorepeat/fingerprints/VideoEndFingerprint.kt index 03ddeef5d..d92f9007b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/overlaybutton/autorepeat/fingerprints/VideoEndFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/overlaybutton/autorepeat/fingerprints/VideoEndFingerprint.kt @@ -8,5 +8,5 @@ object VideoEndFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, parameters = listOf(), - customFingerprint = { it, _ -> it.implementation!!.instructions.count() == 3 && it.annotations.isEmpty()} + customFingerprint = { it, _ -> it.implementation!!.instructions.count() == 3 && it.annotations.isEmpty() } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/overlaybutton/autorepeat/patch/AutoRepeatPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/overlaybutton/autorepeat/patch/AutoRepeatPatch.kt index b39cc2a80..39fe177b3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/overlaybutton/autorepeat/patch/AutoRepeatPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/overlaybutton/autorepeat/patch/AutoRepeatPatch.kt @@ -13,8 +13,11 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.overlaybutton.autorepeat.fingerprints.* +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility +import app.revanced.patches.youtube.overlaybutton.autorepeat.fingerprints.AutoNavInformerFingerprint +import app.revanced.patches.youtube.overlaybutton.autorepeat.fingerprints.RepeatListenerFingerprint +import app.revanced.patches.youtube.overlaybutton.autorepeat.fingerprints.VideoEndFingerprint +import app.revanced.patches.youtube.overlaybutton.autorepeat.fingerprints.VideoEndParentFingerprint import app.revanced.util.integrations.Constants.UTILS_PATH import app.revanced.util.integrations.Constants.VIDEO_PATH import org.jf.dexlib2.builder.instruction.BuilderInstruction35c @@ -33,7 +36,7 @@ class AutoRepeatPatch : BytecodePatch( ) { override fun execute(context: BytecodeContext): PatchResult { VideoEndParentFingerprint.result?.classDef?.let { classDef -> - VideoEndFingerprint.also {it.resolve(context, classDef) }.result?.let { + VideoEndFingerprint.also { it.resolve(context, classDef) }.result?.let { it.mutableMethod.apply { addInstructionsWithLabels( 0, """ diff --git a/src/main/kotlin/app/revanced/patches/youtube/overlaybutton/general/patch/OverlayButtonsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/overlaybutton/general/patch/OverlayButtonsPatch.kt index 5221b9662..3b84c6921 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/overlaybutton/general/patch/OverlayButtonsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/overlaybutton/general/patch/OverlayButtonsPatch.kt @@ -10,7 +10,7 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.overlaybutton.autorepeat.patch.AutoRepeatPatch import app.revanced.patches.youtube.utils.overridespeed.patch.OverrideSpeedHookPatch import app.revanced.patches.youtube.utils.playercontrols.patch.PlayerControlsPatch @@ -94,7 +94,11 @@ class OverlayButtonsPatch : ResourcePatch { /** * Merge xml nodes from the host to their real xml files */ - context.copyXmlNode("youtube/overlaybuttons/host", "layout/youtube_controls_bottom_ui_container.xml", "android.support.constraint.ConstraintLayout") + context.copyXmlNode( + "youtube/overlaybuttons/host", + "layout/youtube_controls_bottom_ui_container.xml", + "android.support.constraint.ConstraintLayout" + ) context.xmlEditor["res/layout/youtube_controls_bottom_ui_container.xml"].use { editor -> editor.file.doRecursively loop@{ @@ -108,7 +112,12 @@ class OverlayButtonsPatch : ResourcePatch { } // Adjust Fullscreen Button size and padding - val padding = "0.0dip" to arrayOf("paddingLeft", "paddingRight", "paddingTop", "paddingBottom") + val padding = "0.0dip" to arrayOf( + "paddingLeft", + "paddingRight", + "paddingTop", + "paddingBottom" + ) val size = "45.0dip" to arrayOf("layout_width", "layout_height") it.getAttributeNode("android:id")?.let { attribute -> if (attribute.textContent == "@id/fullscreen_button") { diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/autoplaybutton/patch/HideAutoplayButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/autoplaybutton/patch/HideAutoplayButtonPatch.kt index fc47a4b31..7423bcdc5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/autoplaybutton/patch/HideAutoplayButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/autoplaybutton/patch/HideAutoplayButtonPatch.kt @@ -13,8 +13,8 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.shared.fingerprints.LayoutConstructorFingerprint +import app.revanced.patches.youtube.utils.fingerprints.LayoutConstructorFingerprint +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.AutoNavPreviewStub import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch @@ -44,10 +44,14 @@ class HideAutoplayButtonPatch : BytecodePatch( LayoutConstructorFingerprint.result?.let { it.mutableMethod.apply { - val dummyRegister = getInstruction(getStringIndex("1.0x")).registerA + val dummyRegister = + getInstruction(getStringIndex("1.0x")).registerA val insertIndex = getWideLiteralIndex(AutoNavPreviewStub) - val branchIndex = implementation!!.instructions.subList(insertIndex + 1, implementation!!.instructions.size - 1).indexOfFirst { instruction -> + val branchIndex = implementation!!.instructions.subList( + insertIndex + 1, + implementation!!.instructions.size - 1 + ).indexOfFirst { instruction -> ((instruction as? ReferenceInstruction)?.reference as? MethodReference)?.name == "addOnLayoutChangeListener" } + 2 diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/captionsbutton/patch/HideCaptionsButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/captionsbutton/patch/HideCaptionsButtonPatch.kt index e9cd8915d..39bf952db 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/captionsbutton/patch/HideCaptionsButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/captionsbutton/patch/HideCaptionsButtonPatch.kt @@ -12,8 +12,8 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.shared.fingerprints.SubtitleButtonControllerFingerprint +import app.revanced.patches.youtube.utils.fingerprints.SubtitleButtonControllerFingerprint +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.PLAYER import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/castbutton/patch/HideCastButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/castbutton/patch/HideCastButtonPatch.kt index 5e9829613..fb8897e09 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/castbutton/patch/HideCastButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/castbutton/patch/HideCastButtonPatch.kt @@ -11,7 +11,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.player.castbutton.fingerprints.CastButtonFingerprint import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.PLAYER diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/collapsebutton/patch/HideCollapseButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/collapsebutton/patch/HideCollapseButtonPatch.kt index 810a01e6d..fc51afafa 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/collapsebutton/patch/HideCollapseButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/collapsebutton/patch/HideCollapseButtonPatch.kt @@ -9,7 +9,7 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.playerbutton.patch.PlayerButtonPatch import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/customspeedoverlay/patch/CustomSpeedOverlayPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/customspeedoverlay/patch/CustomSpeedOverlayPatch.kt index 1c34ca9cc..f6cc57dac 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/customspeedoverlay/patch/CustomSpeedOverlayPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/customspeedoverlay/patch/CustomSpeedOverlayPatch.kt @@ -13,7 +13,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.player.customspeedoverlay.fingerprints.SpeedOverlayHookFingerprint import app.revanced.patches.youtube.player.customspeedoverlay.fingerprints.YouTubeTextViewFingerprint import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/endscreencards/patch/HideEndScreenCardsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/endscreencards/patch/HideEndScreenCardsPatch.kt index 9542d4969..8a27d4d55 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/endscreencards/patch/HideEndScreenCardsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/endscreencards/patch/HideEndScreenCardsPatch.kt @@ -13,7 +13,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.player.endscreencards.fingerprints.LayoutCircleFingerprint import app.revanced.patches.youtube.player.endscreencards.fingerprints.LayoutIconFingerprint import app.revanced.patches.youtube.player.endscreencards.fingerprints.LayoutVideoFingerprint @@ -45,10 +45,15 @@ class HideEndScreenCardsPatch : BytecodePatch( val index = scanResult.patternScanResult!!.endIndex mutableMethod.apply { val register = this.getInstruction(index).registerA - implementation!!.injectHideCall(index + 1, register, "layout/PlayerPatch", "hideEndScreen") + implementation!!.injectHideCall( + index + 1, + register, + "layout/PlayerPatch", + "hideEndScreen" + ) } } - + listOf( LayoutCircleFingerprint, LayoutIconFingerprint, diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/filmstripoverlay/fingerprints/TimeBarOnClickListenerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/filmstripoverlay/fingerprints/TimeBarOnClickListenerFingerprint.kt index 321f79cf0..75aa2a6c9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/filmstripoverlay/fingerprints/TimeBarOnClickListenerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/filmstripoverlay/fingerprints/TimeBarOnClickListenerFingerprint.kt @@ -6,5 +6,9 @@ import app.revanced.util.bytecode.isWideLiteralExists object TimeBarOnClickListenerFingerprint : MethodFingerprint( returnType = "V", - customFingerprint = { it, _ -> it.definingClass.endsWith("YouTubeControlsOverlay;") && it.isWideLiteralExists(WatchWhileTimeBarOverlayStub) } + customFingerprint = { it, _ -> + it.definingClass.endsWith("YouTubeControlsOverlay;") && it.isWideLiteralExists( + WatchWhileTimeBarOverlayStub + ) + } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/filmstripoverlay/patch/HideFilmstripOverlayPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/filmstripoverlay/patch/HideFilmstripOverlayPatch.kt index 6a3bdd17f..d71f6ab0a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/filmstripoverlay/patch/HideFilmstripOverlayPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/filmstripoverlay/patch/HideFilmstripOverlayPatch.kt @@ -15,8 +15,12 @@ import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.player.filmstripoverlay.fingerprints.* +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility +import app.revanced.patches.youtube.player.filmstripoverlay.fingerprints.FilmStripOverlayConfigFingerprint +import app.revanced.patches.youtube.player.filmstripoverlay.fingerprints.FilmStripOverlayInteractionFingerprint +import app.revanced.patches.youtube.player.filmstripoverlay.fingerprints.FilmStripOverlayParentFingerprint +import app.revanced.patches.youtube.player.filmstripoverlay.fingerprints.FilmStripOverlayPreviewFingerprint +import app.revanced.patches.youtube.player.filmstripoverlay.fingerprints.TimeBarOnClickListenerFingerprint import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.WatchWhileTimeBarOverlayStub import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch @@ -52,7 +56,12 @@ class HideFilmstripOverlayPatch : BytecodePatch( FilmStripOverlayInteractionFingerprint, FilmStripOverlayPreviewFingerprint ).forEach { fingerprint -> - fingerprint.also { it.resolve(context, classDef) }.result?.mutableMethod?.injectHook() + fingerprint.also { + it.resolve( + context, + classDef + ) + }.result?.mutableMethod?.injectHook() ?: return fingerprint.toErrorResult() } } ?: return FilmStripOverlayParentFingerprint.toErrorResult() @@ -89,6 +98,7 @@ class HideFilmstripOverlayPatch : BytecodePatch( return PatchResultSuccess() } + private companion object { fun MutableMethod.injectHook() { addInstructionsWithLabels( diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/hapticfeedback/patch/HapticFeedBackPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/hapticfeedback/patch/HapticFeedBackPatch.kt index cbe818202..9bd2cb2f2 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/hapticfeedback/patch/HapticFeedBackPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/hapticfeedback/patch/HapticFeedBackPatch.kt @@ -15,8 +15,11 @@ import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.player.hapticfeedback.fingerprints.* +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility +import app.revanced.patches.youtube.player.hapticfeedback.fingerprints.MarkerHapticsFingerprint +import app.revanced.patches.youtube.player.hapticfeedback.fingerprints.ScrubbingHapticsFingerprint +import app.revanced.patches.youtube.player.hapticfeedback.fingerprints.SeekHapticsFingerprint +import app.revanced.patches.youtube.player.hapticfeedback.fingerprints.ZoomHapticsFingerprint import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.PLAYER import org.jf.dexlib2.iface.instruction.OneRegisterInstruction diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/infocards/patch/HideInfoCardsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/infocards/patch/HideInfoCardsPatch.kt index fc17f41c6..6364f9a8f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/infocards/patch/HideInfoCardsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/infocards/patch/HideInfoCardsPatch.kt @@ -13,7 +13,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.player.infocards.fingerprints.InfoCardsIncognitoFingerprint import app.revanced.patches.youtube.player.infocards.fingerprints.InfoCardsIncognitoParentFingerprint import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch @@ -34,7 +34,8 @@ class HideInfoCardsPatch : BytecodePatch( InfoCardsIncognitoFingerprint.also { it.resolve(context, classDef) }.result?.let { it.mutableMethod.apply { val targetIndex = it.scanResult.patternScanResult!!.startIndex - val targetRegister = getInstruction(targetIndex).registerA + val targetRegister = + getInstruction(targetIndex).registerA addInstructions( targetIndex + 1, """ diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/livechatbutton/patch/HideLiveChatButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/livechatbutton/patch/HideLiveChatButtonPatch.kt index 3c21bddb6..f13bae395 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/livechatbutton/patch/HideLiveChatButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/livechatbutton/patch/HideLiveChatButtonPatch.kt @@ -9,7 +9,7 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.playerbutton.patch.PlayerButtonPatch import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/musicbutton/patch/HideMusicButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/musicbutton/patch/HideMusicButtonPatch.kt index c94662b40..bf99f080b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/musicbutton/patch/HideMusicButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/musicbutton/patch/HideMusicButtonPatch.kt @@ -13,7 +13,7 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.player.musicbutton.fingerprints.MusicAppDeeplinkButtonFingerprint import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.PLAYER @@ -26,17 +26,19 @@ import app.revanced.util.integrations.Constants.PLAYER @Version("0.0.1") class HideMusicButtonPatch : BytecodePatch( listOf(MusicAppDeeplinkButtonFingerprint) -){ +) { override fun execute(context: BytecodeContext): PatchResult { MusicAppDeeplinkButtonFingerprint.result?.let { it.mutableMethod.apply { addInstructionsWithLabels( - 0, """ + 0, + """ invoke-static {}, $PLAYER->hideMusicButton()Z move-result v0 if-nez v0, :hidden - """, ExternalLabel("hidden", getInstruction(implementation!!.instructions.size - 1)) + """, + ExternalLabel("hidden", getInstruction(implementation!!.instructions.size - 1)) ) } } ?: return MusicAppDeeplinkButtonFingerprint.toErrorResult() diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/playerbuttonbg/fingerprints/HidePlayerButtonFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/playerbuttonbg/fingerprints/HidePlayerButtonFingerprint.kt index 7235b2511..8d0d4025d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/playerbuttonbg/fingerprints/HidePlayerButtonFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/playerbuttonbg/fingerprints/HidePlayerButtonFingerprint.kt @@ -2,6 +2,6 @@ package app.revanced.patches.youtube.player.playerbuttonbg.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -object HidePlayerButtonFingerprint : MethodFingerprint ( +object HidePlayerButtonFingerprint : MethodFingerprint( customFingerprint = { it, _ -> it.definingClass.endsWith("PlayerPatch;") && it.name == "hidePlayerButton" } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/playerbuttonbg/patch/HidePlayerButtonBackgroundPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/playerbuttonbg/patch/HidePlayerButtonBackgroundPatch.kt index 366790559..0cc727200 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/playerbuttonbg/patch/HidePlayerButtonBackgroundPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/playerbuttonbg/patch/HidePlayerButtonBackgroundPatch.kt @@ -11,7 +11,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.player.playerbuttonbg.fingerprints.HidePlayerButtonFingerprint import app.revanced.patches.youtube.utils.playerbutton.patch.PlayerButtonPatch import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/playeroverlayfilter/fingerprints/ScrimOverlayFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/playeroverlayfilter/fingerprints/ScrimOverlayFingerprint.kt index 957dbe38c..30aa365f2 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/playeroverlayfilter/fingerprints/ScrimOverlayFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/playeroverlayfilter/fingerprints/ScrimOverlayFingerprint.kt @@ -5,5 +5,9 @@ import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.util.bytecode.isWideLiteralExists object ScrimOverlayFingerprint : MethodFingerprint( - customFingerprint = { it, _ -> it.definingClass.endsWith("YouTubeControlsOverlay;") && it.isWideLiteralExists(ScrimOverlay) } + customFingerprint = { it, _ -> + it.definingClass.endsWith("YouTubeControlsOverlay;") && it.isWideLiteralExists( + ScrimOverlay + ) + } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/playeroverlayfilter/patch/PlayerOverlayFilterPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/playeroverlayfilter/patch/PlayerOverlayFilterPatch.kt index 8abcf2a6f..7faac0fee 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/playeroverlayfilter/patch/PlayerOverlayFilterPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/playeroverlayfilter/patch/PlayerOverlayFilterPatch.kt @@ -13,7 +13,7 @@ import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.player.playeroverlayfilter.fingerprints.ScrimOverlayFingerprint import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.ScrimOverlay diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/previousnextbutton/patch/HidePreviousNextButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/previousnextbutton/patch/HidePreviousNextButtonPatch.kt index 9ab346bb8..4639254e3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/previousnextbutton/patch/HidePreviousNextButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/previousnextbutton/patch/HidePreviousNextButtonPatch.kt @@ -9,7 +9,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.playerbutton.patch.PlayerButtonPatch import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/seekmessage/patch/SeekMessagePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/seekmessage/patch/SeekMessagePatch.kt index c69c21314..ea6d62494 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/seekmessage/patch/SeekMessagePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/seekmessage/patch/SeekMessagePatch.kt @@ -13,7 +13,7 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.player.seekmessage.fingerprints.SeekEduContainerFingerprint import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/speedoverlay/patch/HideSpeedOverlayPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/speedoverlay/patch/HideSpeedOverlayPatch.kt index a79d0c52c..f1a3a850b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/speedoverlay/patch/HideSpeedOverlayPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/speedoverlay/patch/HideSpeedOverlayPatch.kt @@ -12,7 +12,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.player.speedoverlay.fingerprints.SpeedOverlayConfigFingerprint import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.PLAYER diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/suggestactions/patch/SuggestedActionsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/suggestactions/patch/SuggestedActionsPatch.kt index 737225190..a12b06309 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/suggestactions/patch/SuggestedActionsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/suggestactions/patch/SuggestedActionsPatch.kt @@ -12,7 +12,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.player.suggestactions.fingerprints.SuggestedActionsFingerprint import app.revanced.patches.youtube.utils.litho.patch.LithoFilterPatch import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch @@ -35,12 +35,17 @@ class SuggestedActionsPatch : BytecodePatch( listOf(SuggestedActionsFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { - SuggestedActionsFingerprint.result?.let{ + SuggestedActionsFingerprint.result?.let { it.mutableMethod.apply { val targetIndex = it.scanResult.patternScanResult!!.endIndex val targetRegister = getInstruction(targetIndex).registerA - implementation!!.injectHideCall(targetIndex + 1, targetRegister, "layout/PlayerPatch", "hideSuggestedActions") + implementation!!.injectHideCall( + targetIndex + 1, + targetRegister, + "layout/PlayerPatch", + "hideSuggestedActions" + ) } } ?: return SuggestedActionsFingerprint.toErrorResult() diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/watermark/fingerprints/HideWatermarkFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/watermark/fingerprints/HideWatermarkFingerprint.kt index ffa1eac4a..fa4c5cbb1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/watermark/fingerprints/HideWatermarkFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/watermark/fingerprints/HideWatermarkFingerprint.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -object HideWatermarkFingerprint : MethodFingerprint ( +object HideWatermarkFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, parameters = listOf("L", "L"), diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/watermark/fingerprints/HideWatermarkParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/watermark/fingerprints/HideWatermarkParentFingerprint.kt index 6c5d60e8b..24227d04c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/watermark/fingerprints/HideWatermarkParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/watermark/fingerprints/HideWatermarkParentFingerprint.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.AccessFlags -object HideWatermarkParentFingerprint : MethodFingerprint ( +object HideWatermarkParentFingerprint : MethodFingerprint( returnType = "L", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, strings = listOf("player_overlay_in_video_programming") diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/watermark/patch/HideChannelWatermarkPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/watermark/patch/HideChannelWatermarkPatch.kt index 20c86438d..06fb73c1c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/watermark/patch/HideChannelWatermarkPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/watermark/patch/HideChannelWatermarkPatch.kt @@ -14,7 +14,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.player.watermark.fingerprints.HideWatermarkFingerprint import app.revanced.patches.youtube.player.watermark.fingerprints.HideWatermarkParentFingerprint import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch @@ -33,7 +33,12 @@ class HideChannelWatermarkBytecodePatch : BytecodePatch( override fun execute(context: BytecodeContext): PatchResult { HideWatermarkParentFingerprint.result?.let { parentResult -> - HideWatermarkFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let { + HideWatermarkFingerprint.also { + it.resolve( + context, + parentResult.classDef + ) + }.result?.let { it.mutableMethod.apply { val insertIndex = it.scanResult.patternScanResult!!.endIndex val register = getInstruction(insertIndex).registerA diff --git a/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbar/patch/HideSeekbarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbar/patch/HideSeekbarPatch.kt index 1b280b057..f3ed75c2e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbar/patch/HideSeekbarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbar/patch/HideSeekbarPatch.kt @@ -14,9 +14,9 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.shared.fingerprints.SeekbarFingerprint -import app.revanced.patches.shared.fingerprints.SeekbarOnDrawFingerprint +import app.revanced.patches.youtube.utils.fingerprints.SeekbarFingerprint +import app.revanced.patches.youtube.utils.fingerprints.SeekbarOnDrawFingerprint +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.seekbar.seekbarcolor.resource.patch.SeekbarColorResourcePatch import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.SEEKBAR diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/ControlsOverlayStyleFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/fingerprints/ControlsOverlayStyleFingerprint.kt similarity index 79% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/ControlsOverlayStyleFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/fingerprints/ControlsOverlayStyleFingerprint.kt index e0a542b08..3c57953da 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/ControlsOverlayStyleFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/fingerprints/ControlsOverlayStyleFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints +package app.revanced.patches.youtube.seekbar.seekbarcolor.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/bytecode/fingerprints/ProgressColorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/fingerprints/ProgressColorFingerprint.kt similarity index 75% rename from src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/bytecode/fingerprints/ProgressColorFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/fingerprints/ProgressColorFingerprint.kt index 7169fe854..880029d35 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/bytecode/fingerprints/ProgressColorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/fingerprints/ProgressColorFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.seekbar.seekbarcolor.bytecode.fingerprints +package app.revanced.patches.youtube.seekbar.seekbarcolor.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/bytecode/fingerprints/SeekbarColorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/fingerprints/SeekbarColorFingerprint.kt similarity index 83% rename from src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/bytecode/fingerprints/SeekbarColorFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/fingerprints/SeekbarColorFingerprint.kt index 240a5eb76..453143380 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/bytecode/fingerprints/SeekbarColorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/fingerprints/SeekbarColorFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.seekbar.seekbarcolor.bytecode.fingerprints +package app.revanced.patches.youtube.seekbar.seekbarcolor.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.InlineTimeBarColorizedBarPlayedColorDark diff --git a/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/bytecode/patch/SeekbarColorPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/patch/SeekbarColorPatch.kt similarity index 67% rename from src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/bytecode/patch/SeekbarColorPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/patch/SeekbarColorPatch.kt index 3d29eba11..a9fb491af 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/bytecode/patch/SeekbarColorPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/patch/SeekbarColorPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.seekbar.seekbarcolor.bytecode.patch +package app.revanced.patches.youtube.seekbar.seekbarcolor.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -10,23 +10,25 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.shared.fingerprints.ControlsOverlayStyleFingerprint -import app.revanced.patches.youtube.seekbar.seekbarcolor.bytecode.fingerprints.ProgressColorFingerprint -import app.revanced.patches.youtube.seekbar.seekbarcolor.bytecode.fingerprints.SeekbarColorFingerprint -import app.revanced.patches.youtube.seekbar.seekbarcolor.resource.patch.SeekbarColorResourcePatch +import app.revanced.patches.youtube.seekbar.seekbarcolor.fingerprints.ControlsOverlayStyleFingerprint +import app.revanced.patches.youtube.seekbar.seekbarcolor.fingerprints.ProgressColorFingerprint +import app.revanced.patches.youtube.seekbar.seekbarcolor.fingerprints.SeekbarColorFingerprint +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.litho.patch.LithoThemePatch import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.InlineTimeBarColorizedBarPlayedColorDark import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.InlineTimeBarPlayedNotHighlightedColor import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch.Companion.contexts import app.revanced.util.bytecode.getWideLiteralIndex import app.revanced.util.integrations.Constants.SEEKBAR import org.jf.dexlib2.iface.instruction.OneRegisterInstruction +import org.w3c.dom.Element @Patch @Name("custom-seekbar-color") @@ -34,7 +36,6 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @DependsOn( [ LithoThemePatch::class, - SeekbarColorResourcePatch::class, SettingsPatch::class, SharedResourceIdPatch::class, ] @@ -56,7 +57,12 @@ class SeekbarColorPatch : BytecodePatch( } ?: return SeekbarColorFingerprint.toErrorResult() ControlsOverlayStyleFingerprint.result?.let { parentResult -> - ProgressColorFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.addInstructions( + ProgressColorFingerprint.also { + it.resolve( + context, + parentResult.classDef + ) + }.result?.mutableMethod?.addInstructions( 0, """ invoke-static {p1}, $SEEKBAR->getSeekbarClickedColorValue(I)I move-result p1 @@ -66,6 +72,20 @@ class SeekbarColorPatch : BytecodePatch( LithoThemePatch.injectCall("$SEEKBAR->getLithoColor(I)I") + contexts.xmlEditor["res/drawable/resume_playback_progressbar_drawable.xml"].use { + val layerList = it.file.getElementsByTagName("layer-list").item(0) as Element + val progressNode = layerList.getElementsByTagName("item").item(1) as Element + if (!progressNode.getAttributeNode("android:id").value.endsWith("progress")) { + return PatchResultError("Could not find progress bar") + } + val scaleNode = progressNode.getElementsByTagName("scale").item(0) as Element + val shapeNode = scaleNode.getElementsByTagName("shape").item(0) as Element + val replacementNode = it.file.createElement( + "app.revanced.integrations.patches.utils.ProgressBarDrawable" + ) + scaleNode.replaceChild(replacementNode, shapeNode) + } + /** * Add settings */ diff --git a/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/resource/patch/SeekbarColorResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/resource/patch/SeekbarColorResourcePatch.kt deleted file mode 100644 index b06319369..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/resource/patch/SeekbarColorResourcePatch.kt +++ /dev/null @@ -1,34 +0,0 @@ -package app.revanced.patches.youtube.seekbar.seekbarcolor.resource.patch - -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.ResourceContext -import app.revanced.patcher.patch.PatchResult -import app.revanced.patcher.patch.PatchResultError -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import org.w3c.dom.Element - -@Name("custom-seekbar-color-resource-patch") -@YouTubeCompatibility -@Version("0.0.1") -class SeekbarColorResourcePatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - context.xmlEditor["res/drawable/resume_playback_progressbar_drawable.xml"].use { - val layerList = it.file.getElementsByTagName("layer-list").item(0) as Element - val progressNode = layerList.getElementsByTagName("item").item(1) as Element - if (!progressNode.getAttributeNode("android:id").value.endsWith("progress")) { - return PatchResultError("Could not find progress bar") - } - val scaleNode = progressNode.getElementsByTagName("scale").item(0) as Element - val shapeNode = scaleNode.getElementsByTagName("shape").item(0) as Element - val replacementNode = it.file.createElement( - "app.revanced.integrations.patches.utils.ProgressBarDrawable") - scaleNode.replaceChild(replacementNode, shapeNode) - } - - return PatchResultSuccess() - } -} diff --git a/src/main/kotlin/app/revanced/patches/youtube/seekbar/speed/patch/AppendSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/seekbar/speed/patch/AppendSpeedPatch.kt index 5c6e69b66..9d87209f7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/seekbar/speed/patch/AppendSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/seekbar/speed/patch/AppendSpeedPatch.kt @@ -13,8 +13,8 @@ import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.shared.fingerprints.TotalTimeFingerprint +import app.revanced.patches.youtube.utils.fingerprints.TotalTimeFingerprint +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.overridespeed.patch.OverrideSpeedHookPatch import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch @@ -47,7 +47,8 @@ class AppendSpeedPatch : BytecodePatch( if (targetInstruction.opcode != Opcode.INVOKE_VIRTUAL) continue if (getInstruction(targetIndex).reference.toString() == - "Landroid/widget/TextView;->getText()Ljava/lang/CharSequence;") { + "Landroid/widget/TextView;->getText()Ljava/lang/CharSequence;" + ) { insertIndex = targetIndex + 2 val insertRegister = getInstruction(insertIndex).registerC diff --git a/src/main/kotlin/app/revanced/patches/youtube/seekbar/tapping/fingerprints/SeekbarTappingFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/seekbar/tapping/fingerprints/SeekbarTappingFingerprint.kt index 5f1b62b23..31b5c1976 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/seekbar/tapping/fingerprints/SeekbarTappingFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/seekbar/tapping/fingerprints/SeekbarTappingFingerprint.kt @@ -26,5 +26,5 @@ object SeekbarTappingFingerprint : MethodFingerprint( Opcode.MOVE_RESULT, Opcode.IF_EQZ ), - customFingerprint = { it, _ -> it.name == "onTouchEvent"} + customFingerprint = { it, _ -> it.name == "onTouchEvent" } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/seekbar/tapping/patch/SeekbarTappingPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/seekbar/tapping/patch/SeekbarTappingPatch.kt index b29b21713..8d100369e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/seekbar/tapping/patch/SeekbarTappingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/seekbar/tapping/patch/SeekbarTappingPatch.kt @@ -13,7 +13,7 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.seekbar.tapping.fingerprints.SeekbarTappingFingerprint import app.revanced.patches.youtube.seekbar.tapping.fingerprints.SeekbarTappingReferenceFingerprint import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch @@ -71,6 +71,7 @@ class SeekbarTappingPatch : BytecodePatch( return PatchResultSuccess() } + private companion object { lateinit var TappingLabel: String } diff --git a/src/main/kotlin/app/revanced/patches/youtube/seekbar/thumbnailpreview/patch/NewThumbnailPreviewPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/seekbar/thumbnailpreview/patch/NewThumbnailPreviewPatch.kt index 2130011d5..94a6ea6c6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/seekbar/thumbnailpreview/patch/NewThumbnailPreviewPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/seekbar/thumbnailpreview/patch/NewThumbnailPreviewPatch.kt @@ -12,7 +12,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.seekbar.thumbnailpreview.fingerprints.ThumbnailPreviewConfigFingerprint import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.SEEKBAR diff --git a/src/main/kotlin/app/revanced/patches/youtube/seekbar/timestamps/patch/HideTimeStampPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/seekbar/timestamps/patch/HideTimeStampPatch.kt index 9d550f49c..24b306d96 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/seekbar/timestamps/patch/HideTimeStampPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/seekbar/timestamps/patch/HideTimeStampPatch.kt @@ -13,7 +13,7 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.seekbar.timestamps.fingerprints.TimeCounterFingerprint import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.SEEKBAR diff --git a/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsCommentButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsCommentButtonPatch.kt index 82e1458dd..d3fa06420 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsCommentButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsCommentButtonPatch.kt @@ -9,7 +9,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.shorts.shortscomponent.fingerprints.ShortsCommentFingerprint import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.RightComment import app.revanced.util.bytecode.getWideLiteralIndex diff --git a/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsComponentPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsComponentPatch.kt index f2c8c3f6a..15050c504 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsComponentPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsComponentPatch.kt @@ -9,9 +9,9 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch import app.revanced.patches.youtube.ads.general.resource.patch.GeneralAdsPatch +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.shorts.shortscomponent.patch.ShortsCommentButtonPatch import app.revanced.patches.youtube.shorts.shortscomponent.patch.ShortsInfoPanelPatch import app.revanced.patches.youtube.shorts.shortscomponent.patch.ShortsPaidContentBannerPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsInfoPanelPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsInfoPanelPatch.kt index b2d549397..e9127d64f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsInfoPanelPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsInfoPanelPatch.kt @@ -9,7 +9,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.shorts.shortscomponent.fingerprints.ShortsInfoPanelFingerprint import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.ReelPlayerInfoPanel diff --git a/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsPaidContentBannerPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsPaidContentBannerPatch.kt index 054074185..4ce6ddd57 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsPaidContentBannerPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsPaidContentBannerPatch.kt @@ -10,7 +10,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.shorts.shortscomponent.fingerprints.ShortsPaidContentFingerprint import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.ReelPlayerBadge import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.ReelPlayerBadge2 @@ -42,6 +42,7 @@ class ShortsPaidContentBannerPatch : BytecodePatch( return PatchResultSuccess() } + private companion object { fun MutableMethod.insertHook(insertIndex: Int) { val insertRegister = getInstruction(insertIndex).registerA diff --git a/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsRemixButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsRemixButtonPatch.kt index 33bdf97f9..197f21756 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsRemixButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsRemixButtonPatch.kt @@ -9,7 +9,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.shorts.shortscomponent.fingerprints.ShortsRemixFingerprint import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.ReelDynRemix import app.revanced.util.bytecode.getWideLiteralIndex diff --git a/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsSubscriptionsButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsSubscriptionsButtonPatch.kt index eb24ac5d6..3f8d7c974 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsSubscriptionsButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsSubscriptionsButtonPatch.kt @@ -11,7 +11,7 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion. import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.shorts.shortscomponent.fingerprints.ShortsSubscriptionsFingerprint import app.revanced.patches.youtube.shorts.shortscomponent.fingerprints.ShortsSubscriptionsTabletFingerprint import app.revanced.patches.youtube.shorts.shortscomponent.fingerprints.ShortsSubscriptionsTabletParentFingerprint @@ -51,20 +51,27 @@ class ShortsSubscriptionsButtonPatch : BytecodePatch( parentResult.mutableMethod.apply { val targetIndex = getWideLiteralIndex(ReelPlayerFooter) - 1 if (getInstruction(targetIndex).opcode != Opcode.IPUT) return ShortsSubscriptionsTabletFingerprint.toErrorResult() - subscriptionFieldReference = (getInstruction(targetIndex)).reference as FieldReference + subscriptionFieldReference = + (getInstruction(targetIndex)).reference as FieldReference } - ShortsSubscriptionsTabletFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.let { - with (it.implementation!!.instructions) { + ShortsSubscriptionsTabletFingerprint.also { + it.resolve( + context, + parentResult.classDef + ) + }.result?.mutableMethod?.let { + with(it.implementation!!.instructions) { filter { instruction -> - val fieldReference = (instruction as? ReferenceInstruction)?.reference as? FieldReference + val fieldReference = + (instruction as? ReferenceInstruction)?.reference as? FieldReference instruction.opcode == Opcode.IGET && fieldReference == subscriptionFieldReference }.forEach { instruction -> val insertIndex = indexOf(instruction) + 1 val register = (instruction as TwoRegisterInstruction).registerA it.addInstructions( - insertIndex,""" + insertIndex, """ invoke-static {v$register}, $SHORTS->hideShortsPlayerSubscriptionsButton(I)I move-result v$register """ @@ -76,6 +83,7 @@ class ShortsSubscriptionsButtonPatch : BytecodePatch( return PatchResultSuccess() } + private companion object { private lateinit var subscriptionFieldReference: FieldReference } diff --git a/src/main/kotlin/app/revanced/patches/youtube/shorts/startupshortsreset/patch/DisableShortsOnStartupPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/startupshortsreset/patch/DisableShortsOnStartupPatch.kt index e2cb62187..c5f35b08d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/shorts/startupshortsreset/patch/DisableShortsOnStartupPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/startupshortsreset/patch/DisableShortsOnStartupPatch.kt @@ -13,7 +13,7 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.shorts.startupshortsreset.fingerprints.UserWasInShortsFingerprint import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.SHORTS @@ -35,12 +35,14 @@ class DisableShortsOnStartupPatch : BytecodePatch( val targetIndex = it.scanResult.patternScanResult!!.endIndex val register = getInstruction(targetIndex).registerA + 2 addInstructionsWithLabels( - targetIndex + 1, """ + targetIndex + 1, + """ invoke-static { }, $SHORTS->disableStartupShortsPlayer()Z move-result v$register if-eqz v$register, :show_startup_shorts_player return-void - """, ExternalLabel("show_startup_shorts_player", getInstruction(targetIndex + 1)) + """, + ExternalLabel("show_startup_shorts_player", getInstruction(targetIndex + 1)) ) } } ?: return UserWasInShortsFingerprint.toErrorResult() diff --git a/src/main/kotlin/app/revanced/patches/youtube/swipe/hdrbrightness/patch/HDRBrightnessPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/swipe/hdrbrightness/patch/HDRBrightnessPatch.kt index b32c660a5..1007447f0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/swipe/hdrbrightness/patch/HDRBrightnessPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/swipe/hdrbrightness/patch/HDRBrightnessPatch.kt @@ -10,7 +10,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.swipe.hdrbrightness.fingerprints.HDRBrightnessFingerprint import app.revanced.util.integrations.Constants.SWIPE_PATH diff --git a/src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrols/bytecode/patch/SwipeControlsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrols/bytecode/patch/SwipeControlsBytecodePatch.kt index 297d4cf3c..da269517a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrols/bytecode/patch/SwipeControlsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrols/bytecode/patch/SwipeControlsBytecodePatch.kt @@ -11,10 +11,10 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.util.TypeUtil.traverseClassHierarchy import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.utils.playertype.patch.PlayerTypeHookPatch +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.swipe.swipecontrols.bytecode.fingerprints.SwipeControlsHostActivityFingerprint import app.revanced.patches.youtube.swipe.swipecontrols.bytecode.fingerprints.WatchWhileActivityFingerprint +import app.revanced.patches.youtube.utils.playertype.patch.PlayerTypeHookPatch import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.immutable.ImmutableMethod @@ -29,8 +29,10 @@ class SwipeControlsBytecodePatch : BytecodePatch( ) ) { override fun execute(context: BytecodeContext): PatchResult { - val wrapperClass = SwipeControlsHostActivityFingerprint.result?.mutableClass ?: return SwipeControlsHostActivityFingerprint.toErrorResult() - val targetClass = WatchWhileActivityFingerprint.result?.mutableClass ?: return WatchWhileActivityFingerprint.toErrorResult() + val wrapperClass = SwipeControlsHostActivityFingerprint.result?.mutableClass + ?: return SwipeControlsHostActivityFingerprint.toErrorResult() + val targetClass = WatchWhileActivityFingerprint.result?.mutableClass + ?: return WatchWhileActivityFingerprint.toErrorResult() // inject the wrapper class from integrations into the class hierarchy of WatchWhileActivity wrapperClass.setSuperClass(targetClass.superclass) diff --git a/src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrols/resource/patch/SwipeControlsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrols/resource/patch/SwipeControlsPatch.kt index 1a95ae92b..e5b382156 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrols/resource/patch/SwipeControlsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrols/resource/patch/SwipeControlsPatch.kt @@ -9,7 +9,7 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.swipe.hdrbrightness.patch.HDRBrightnessPatch import app.revanced.patches.youtube.swipe.swipecontrols.bytecode.patch.SwipeControlsBytecodePatch import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/shared/annotation/YouTubeCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/annotations/YouTubeCompatibility.kt similarity index 87% rename from src/main/kotlin/app/revanced/patches/shared/annotation/YouTubeCompatibility.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/annotations/YouTubeCompatibility.kt index ad9da51c6..f5dd1cdca 100644 --- a/src/main/kotlin/app/revanced/patches/shared/annotation/YouTubeCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/annotations/YouTubeCompatibility.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.annotation +package app.revanced.patches.youtube.utils.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/LayoutConstructorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/LayoutConstructorFingerprint.kt similarity index 81% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/LayoutConstructorFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/LayoutConstructorFingerprint.kt index 77eebb87f..3e232d742 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/LayoutConstructorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/LayoutConstructorFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints +package app.revanced.patches.youtube.utils.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/LayoutSwitchFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/LayoutSwitchFingerprint.kt similarity index 94% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/LayoutSwitchFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/LayoutSwitchFingerprint.kt index fa97e8a68..fbfeb5f79 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/LayoutSwitchFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/LayoutSwitchFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints +package app.revanced.patches.youtube.utils.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/OnBackPressedFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/OnBackPressedFingerprint.kt similarity index 84% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/OnBackPressedFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/OnBackPressedFingerprint.kt index baecd1898..b9857c0e2 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/OnBackPressedFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/OnBackPressedFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints +package app.revanced.patches.youtube.utils.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/PivotBarCreateButtonViewFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/PivotBarCreateButtonViewFingerprint.kt similarity index 92% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/PivotBarCreateButtonViewFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/PivotBarCreateButtonViewFingerprint.kt index 2450e9372..a72e3b690 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/PivotBarCreateButtonViewFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/PivotBarCreateButtonViewFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints +package app.revanced.patches.youtube.utils.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/SeekbarFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/SeekbarFingerprint.kt similarity index 76% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/SeekbarFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/SeekbarFingerprint.kt index 7fd78d7e7..01cd45965 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/SeekbarFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/SeekbarFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints +package app.revanced.patches.youtube.utils.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/SeekbarOnDrawFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/SeekbarOnDrawFingerprint.kt similarity index 77% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/SeekbarOnDrawFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/SeekbarOnDrawFingerprint.kt index 171dfd45f..6c5e9c6f7 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/SeekbarOnDrawFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/SeekbarOnDrawFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints +package app.revanced.patches.youtube.utils.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/SubtitleButtonControllerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/SubtitleButtonControllerFingerprint.kt similarity index 93% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/SubtitleButtonControllerFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/SubtitleButtonControllerFingerprint.kt index 166ae7c52..80d9b2746 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/SubtitleButtonControllerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/SubtitleButtonControllerFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints +package app.revanced.patches.youtube.utils.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/TotalTimeFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/TotalTimeFingerprint.kt similarity index 86% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/TotalTimeFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/TotalTimeFingerprint.kt index c003fcc64..9e4666494 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/TotalTimeFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/TotalTimeFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints +package app.revanced.patches.youtube.utils.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.TotalTime diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/clientspoof/patch/ClientSpoofPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/clientspoof/patch/ClientSpoofPatch.kt index 7ba516fae..acde5bec5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/clientspoof/patch/ClientSpoofPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/clientspoof/patch/ClientSpoofPatch.kt @@ -10,7 +10,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.fix.clientspoof.fingerprints.UserAgentHeaderBuilderFingerprint import app.revanced.patches.youtube.utils.microg.shared.Constants.PACKAGE_NAME import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction @@ -27,7 +27,8 @@ class ClientSpoofPatch : BytecodePatch( UserAgentHeaderBuilderFingerprint.result?.let { it.mutableMethod.apply { val insertIndex = it.scanResult.patternScanResult!!.endIndex - val packageNameRegister = getInstruction(insertIndex).registerD + val packageNameRegister = + getInstruction(insertIndex).registerD addInstruction( insertIndex, diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/doublebacktoclose/fingerprint/ScrollTopParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/doublebacktoclose/fingerprint/ScrollTopParentFingerprint.kt index 51bd4d664..6c35a53a0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/doublebacktoclose/fingerprint/ScrollTopParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/doublebacktoclose/fingerprint/ScrollTopParentFingerprint.kt @@ -20,6 +20,6 @@ object ScrollTopParentFingerprint : MethodFingerprint( Opcode.IPUT_OBJECT, Opcode.RETURN_VOID ), - customFingerprint = { it, _ -> it.name == ""} + customFingerprint = { it, _ -> it.name == "" } ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/doublebacktoclose/patch/DoubleBackToClosePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/doublebacktoclose/patch/DoubleBackToClosePatch.kt index cc9f6be3a..8589c968f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/doublebacktoclose/patch/DoubleBackToClosePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/doublebacktoclose/patch/DoubleBackToClosePatch.kt @@ -11,9 +11,11 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.shared.fingerprints.OnBackPressedFingerprint -import app.revanced.patches.youtube.utils.fix.doublebacktoclose.fingerprint.* +import app.revanced.patches.youtube.utils.fingerprints.OnBackPressedFingerprint +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility +import app.revanced.patches.youtube.utils.fix.doublebacktoclose.fingerprint.ScrollPositionFingerprint +import app.revanced.patches.youtube.utils.fix.doublebacktoclose.fingerprint.ScrollTopFingerprint +import app.revanced.patches.youtube.utils.fix.doublebacktoclose.fingerprint.ScrollTopParentFingerprint import app.revanced.util.integrations.Constants.UTILS_PATH @Name("double-back-to-close") diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/protobufpoof/patch/ProtobufSpoofPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/protobufpoof/patch/ProtobufSpoofPatch.kt index ce0338c8e..743ebb0db 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/protobufpoof/patch/ProtobufSpoofPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/protobufpoof/patch/ProtobufSpoofPatch.kt @@ -14,11 +14,13 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility +import app.revanced.patches.youtube.utils.fix.protobufpoof.fingerprints.BadResponseFingerprint +import app.revanced.patches.youtube.utils.fix.protobufpoof.fingerprints.ProtobufParameterBuilderFingerprint +import app.revanced.patches.youtube.utils.fix.protobufpoof.fingerprints.SubtitleWindowFingerprint import app.revanced.patches.youtube.utils.playertype.patch.PlayerTypeHookPatch import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.patches.youtube.utils.videoid.mainstream.patch.MainstreamVideoIdPatch -import app.revanced.patches.youtube.utils.fix.protobufpoof.fingerprints.* import app.revanced.util.integrations.Constants.MISC_PATH @Patch @@ -48,17 +50,17 @@ class ProtobufSpoofPatch : BytecodePatch( .toMethodWalker(it.method) .nextMethod(it.scanResult.patternScanResult!!.startIndex, true) .getMethod() as MutableMethod - ).apply { - val protobufParam = 3 + ).apply { + val protobufParam = 3 - addInstructions( - 0, - """ + addInstructions( + 0, + """ invoke-static {p$protobufParam}, $MISC_PATH/ProtobufSpoofPatch;->overrideProtobufParameter(Ljava/lang/String;)Ljava/lang/String; move-result-object p$protobufParam """ - ) - } + ) + } } ?: return ProtobufParameterBuilderFingerprint.toErrorResult() // hook video playback result diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/swiperefresh/patch/SwipeRefreshPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/swiperefresh/patch/SwipeRefreshPatch.kt index 1522d0730..d8a89823a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/swiperefresh/patch/SwipeRefreshPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/swiperefresh/patch/SwipeRefreshPatch.kt @@ -1,5 +1,6 @@ package app.revanced.patches.youtube.utils.fix.swiperefresh.patch +import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version @@ -9,9 +10,8 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.fix.swiperefresh.fingerprint.SwipeRefreshLayoutFingerprint -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.extensions.toErrorResult import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @Name("fix-swipe-refresh") diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/patch/IntegrationsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/patch/IntegrationsPatch.kt index dcbff298c..cd1b678fc 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/patch/IntegrationsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/patch/IntegrationsPatch.kt @@ -2,9 +2,15 @@ package app.revanced.patches.youtube.utils.integrations.patch import app.revanced.patcher.annotation.Name import app.revanced.patcher.patch.annotations.RequiresIntegrations -import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch -import app.revanced.patches.youtube.utils.integrations.fingerprints.* +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility +import app.revanced.patches.youtube.utils.integrations.fingerprints.APIPlayerServiceFingerprint +import app.revanced.patches.youtube.utils.integrations.fingerprints.ApplicationInitFingerprint +import app.revanced.patches.youtube.utils.integrations.fingerprints.EmbeddedPlayerControlsOverlayFingerprint +import app.revanced.patches.youtube.utils.integrations.fingerprints.EmbeddedPlayerFingerprint +import app.revanced.patches.youtube.utils.integrations.fingerprints.RemoteEmbedFragmentFingerprint +import app.revanced.patches.youtube.utils.integrations.fingerprints.RemoteEmbeddedPlayerFingerprint +import app.revanced.patches.youtube.utils.integrations.fingerprints.StandalonePlayerActivityFingerprint import app.revanced.util.integrations.Constants.INTEGRATIONS_PATH @Name("integrations") diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/litho/fingerprints/ByteBufferFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/litho/fingerprints/ByteBufferFingerprint.kt index 93358a6a3..6b0c97736 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/litho/fingerprints/ByteBufferFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/litho/fingerprints/ByteBufferFingerprint.kt @@ -8,7 +8,7 @@ import org.jf.dexlib2.Opcode object ByteBufferFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC, - parameters = listOf("L","L"), + parameters = listOf("L", "L"), opcodes = listOf( Opcode.SGET_OBJECT, Opcode.INVOKE_VIRTUAL, diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/litho/patch/LithoFilterPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/litho/patch/LithoFilterPatch.kt index 2acbdda21..e06a2a9fa 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/litho/patch/LithoFilterPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/litho/patch/LithoFilterPatch.kt @@ -8,9 +8,9 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.shared.patch.litho.ComponentParserPatch import app.revanced.patches.shared.patch.litho.ComponentParserPatch.Companion.generalHook +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.fix.doublebacktoclose.patch.DoubleBackToClosePatch import app.revanced.patches.youtube.utils.fix.swiperefresh.patch.SwipeRefreshPatch import app.revanced.patches.youtube.utils.litho.fingerprints.ByteBufferFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/litho/patch/LithoThemePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/litho/patch/LithoThemePatch.kt index 767aca45a..9149248f4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/litho/patch/LithoThemePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/litho/patch/LithoThemePatch.kt @@ -9,7 +9,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.litho.fingerprints.LithoThemeFingerprint import org.jf.dexlib2.iface.instruction.ReferenceInstruction import org.jf.dexlib2.iface.instruction.formats.Instruction35c @@ -26,7 +26,7 @@ class LithoThemePatch : BytecodePatch( override fun execute(context: BytecodeContext): PatchResult { LithoThemeFingerprint.result?.mutableMethod?.let { - with (it.implementation!!.instructions) { + with(it.implementation!!.instructions) { for (index in size - 1 downTo 0) { val invokeInstruction = this[index] as? ReferenceInstruction ?: continue if ((invokeInstruction.reference as MethodReference).name != "setColor") continue diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/microg/bytecode/fingerprints/ServiceCheckFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/microg/bytecode/fingerprints/ServiceCheckFingerprint.kt index 22ba53eec..22ad22ed1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/microg/bytecode/fingerprints/ServiceCheckFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/microg/bytecode/fingerprints/ServiceCheckFingerprint.kt @@ -8,5 +8,8 @@ object ServiceCheckFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC, parameters = listOf("L", "I"), - strings = listOf("Google Play Services not available", "GooglePlayServices not available due to error ") + strings = listOf( + "Google Play Services not available", + "GooglePlayServices not available due to error " + ) ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/microg/bytecode/patch/MicroGBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/microg/bytecode/patch/MicroGBytecodePatch.kt index d7d9d0fe0..25a80e03d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/microg/bytecode/patch/MicroGBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/microg/bytecode/patch/MicroGBytecodePatch.kt @@ -7,12 +7,17 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.shared.patch.packagename.PackageNamePatch +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.fix.clientspoof.patch.ClientSpoofPatch import app.revanced.patches.youtube.utils.fix.protobufpoof.patch.ProtobufSpoofPatch +import app.revanced.patches.youtube.utils.microg.bytecode.fingerprints.CastContextFetchFingerprint +import app.revanced.patches.youtube.utils.microg.bytecode.fingerprints.CastDynamiteModuleFingerprint +import app.revanced.patches.youtube.utils.microg.bytecode.fingerprints.CastDynamiteModuleV2Fingerprint +import app.revanced.patches.youtube.utils.microg.bytecode.fingerprints.GooglePlayUtilityFingerprint +import app.revanced.patches.youtube.utils.microg.bytecode.fingerprints.PrimeFingerprint +import app.revanced.patches.youtube.utils.microg.bytecode.fingerprints.ServiceCheckFingerprint import app.revanced.patches.youtube.utils.microg.shared.Constants.PACKAGE_NAME -import app.revanced.patches.youtube.utils.microg.bytecode.fingerprints.* import app.revanced.util.bytecode.BytecodeHelper.injectInit import app.revanced.util.microg.MicroGBytecodeHelper diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/microg/resource/patch/MicroGPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/microg/resource/patch/MicroGPatch.kt index 7fc535ca9..6dd6f2ae8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/microg/resource/patch/MicroGPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/microg/resource/patch/MicroGPatch.kt @@ -9,8 +9,8 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.shared.patch.packagename.PackageNamePatch +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.microg.bytecode.patch.MicroGBytecodePatch import app.revanced.patches.youtube.utils.microg.shared.Constants.PACKAGE_NAME import app.revanced.patches.youtube.utils.microg.shared.Constants.SPOOFED_PACKAGE_NAME diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/navbarindex/patch/NavBarIndexPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/navbarindex/patch/NavBarIndexPatch.kt index b3f659975..7c8ec011a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/navbarindex/patch/NavBarIndexPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/navbarindex/patch/NavBarIndexPatch.kt @@ -11,8 +11,8 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.shared.fingerprints.OnBackPressedFingerprint +import app.revanced.patches.youtube.utils.fingerprints.OnBackPressedFingerprint +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.navbarindex.fingerprints.NavBarBuilderFingerprint import app.revanced.patches.youtube.utils.navbarindex.fingerprints.TopBarButtonFingerprint import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch @@ -54,9 +54,11 @@ class NavBarIndexPatch : BytecodePatch( NavBarBuilderFingerprint.result?.let { val endIndex = it.scanResult.patternScanResult!!.endIndex - val onClickListener = it.mutableMethod.getInstruction(endIndex).reference.toString() + val onClickListener = + it.mutableMethod.getInstruction(endIndex).reference.toString() - val targetMethod = context.findClass(onClickListener)?.mutableClass?.methods?.first { method -> method.name == "onClick" } + val targetMethod = + context.findClass(onClickListener)?.mutableClass?.methods?.first { method -> method.name == "onClick" } targetMethod?.apply { for ((index, instruction) in implementation!!.instructions.withIndex()) { diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/fingerprints/VideoSpeedPatchFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/fingerprints/VideoSpeedPatchFingerprint.kt index 98c77b807..03bfdbc56 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/fingerprints/VideoSpeedPatchFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/fingerprints/VideoSpeedPatchFingerprint.kt @@ -8,5 +8,5 @@ object VideoSpeedPatchFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC, parameters = listOf("F"), - customFingerprint = { it, _ -> it.definingClass.endsWith("/VideoSpeedPatch;") && it.name == "overrideSpeed"} + customFingerprint = { it, _ -> it.definingClass.endsWith("/VideoSpeedPatch;") && it.name == "overrideSpeed" } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/patch/OverrideSpeedHookPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/patch/OverrideSpeedHookPatch.kt index 47de87d00..43df14281 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/patch/OverrideSpeedHookPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/patch/OverrideSpeedHookPatch.kt @@ -19,15 +19,21 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMut import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable import app.revanced.patcher.util.smali.toInstructions -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.utils.overridespeed.fingerprints.* +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility +import app.revanced.patches.youtube.utils.overridespeed.fingerprints.SpeedClassFingerprint +import app.revanced.patches.youtube.utils.overridespeed.fingerprints.VideoSpeedChangedFingerprint +import app.revanced.patches.youtube.utils.overridespeed.fingerprints.VideoSpeedParentFingerprint +import app.revanced.patches.youtube.utils.overridespeed.fingerprints.VideoSpeedPatchFingerprint import app.revanced.util.integrations.Constants.INTEGRATIONS_PATH import app.revanced.util.integrations.Constants.VIDEO_PATH import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.iface.instruction.OneRegisterInstruction import org.jf.dexlib2.iface.instruction.ReferenceInstruction import org.jf.dexlib2.iface.reference.FieldReference -import org.jf.dexlib2.immutable.* +import org.jf.dexlib2.immutable.ImmutableField +import org.jf.dexlib2.immutable.ImmutableMethod +import org.jf.dexlib2.immutable.ImmutableMethodImplementation +import org.jf.dexlib2.immutable.ImmutableMethodParameter @Name("override-speed-hook") @YouTubeCompatibility @@ -82,10 +88,11 @@ class OverrideSpeedHookPatch : BytecodePatch( ).toMutable() ) - with(context - .toMethodWalker(this) - .nextMethod(endIndex, true) - .getMethod() as MutableMethod + with( + context + .toMethodWalker(this) + .nextMethod(endIndex, true) + .getMethod() as MutableMethod ) { addInstruction( this.implementation!!.instructions.size - 1, diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/playerbutton/patch/PlayerButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/playerbutton/patch/PlayerButtonPatch.kt index 1f231079c..bdd190727 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/playerbutton/patch/PlayerButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/playerbutton/patch/PlayerButtonPatch.kt @@ -11,7 +11,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.playerbutton.fingerprints.LiveChatFingerprint import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.util.integrations.Constants.PLAYER @@ -33,9 +33,11 @@ class PlayerButtonPatch : BytecodePatch( val instructions = it.mutableMethod.getInstruction(endIndex) val imageButtonClass = context - .findClass((instructions as BuilderInstruction21c) - .reference.toString())!! - .mutableClass + .findClass( + (instructions as BuilderInstruction21c) + .reference.toString() + )!! + .mutableClass for (method in imageButtonClass.methods) { imageButtonClass.findMutableMethodOf(method).apply { @@ -46,7 +48,8 @@ class PlayerButtonPatch : BytecodePatch( val definedInstruction = (instructions as? BuilderInstruction35c) if (definedInstruction?.reference.toString() == - "Landroid/view/View;->setVisibility(I)V") { + "Landroid/view/View;->setVisibility(I)V" + ) { jumpInstruction = !jumpInstruction if (jumpInstruction) return@forEachIndexed diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/patch/PlayerControlsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/patch/PlayerControlsPatch.kt index 77704659a..25c164589 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/patch/PlayerControlsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/patch/PlayerControlsPatch.kt @@ -15,8 +15,7 @@ import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.playercontrols.fingerprints.BottomControlsInflateFingerprint import app.revanced.patches.youtube.utils.playercontrols.fingerprints.ControlsLayoutInflateFingerprint import app.revanced.patches.youtube.utils.playercontrols.fingerprints.PlayerControlsVisibilityFingerprint @@ -25,6 +24,7 @@ import app.revanced.patches.youtube.utils.playercontrols.fingerprints.SeekEDUVis import app.revanced.patches.youtube.utils.playercontrols.fingerprints.SpeedEduVisibleFingerprint import app.revanced.patches.youtube.utils.playercontrols.fingerprints.SpeedEduVisibleParentFingerprint import app.revanced.patches.youtube.utils.playercontrols.fingerprints.UserScrubbingFingerprint +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.util.bytecode.getStringIndex import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @@ -49,17 +49,24 @@ class PlayerControlsPatch : BytecodePatch( ) { override fun execute(context: BytecodeContext): PatchResult { - val playerControlsVisibilityModelClassDef = PlayerControlsVisibilityModelFingerprint.result?.classDef?: return PlayerControlsVisibilityModelFingerprint.toErrorResult() + val playerControlsVisibilityModelClassDef = + PlayerControlsVisibilityModelFingerprint.result?.classDef + ?: return PlayerControlsVisibilityModelFingerprint.toErrorResult() SeekEDUVisibleFingerprint.resolve(context, playerControlsVisibilityModelClassDef) - seekEDUVisibleResult = SeekEDUVisibleFingerprint.result?: return SeekEDUVisibleFingerprint.toErrorResult() + seekEDUVisibleResult = + SeekEDUVisibleFingerprint.result ?: return SeekEDUVisibleFingerprint.toErrorResult() UserScrubbingFingerprint.resolve(context, playerControlsVisibilityModelClassDef) - userScrubbingResult = UserScrubbingFingerprint.result?: return UserScrubbingFingerprint.toErrorResult() + userScrubbingResult = + UserScrubbingFingerprint.result ?: return UserScrubbingFingerprint.toErrorResult() - playerControlsVisibilityResult = PlayerControlsVisibilityFingerprint.result?: return PlayerControlsVisibilityFingerprint.toErrorResult() - controlsLayoutInflateResult = ControlsLayoutInflateFingerprint.result?: return ControlsLayoutInflateFingerprint.toErrorResult() - inflateResult = BottomControlsInflateFingerprint.result?: return BottomControlsInflateFingerprint.toErrorResult() + playerControlsVisibilityResult = PlayerControlsVisibilityFingerprint.result + ?: return PlayerControlsVisibilityFingerprint.toErrorResult() + controlsLayoutInflateResult = ControlsLayoutInflateFingerprint.result + ?: return ControlsLayoutInflateFingerprint.toErrorResult() + inflateResult = BottomControlsInflateFingerprint.result + ?: return BottomControlsInflateFingerprint.toErrorResult() SpeedEduVisibleParentFingerprint.result?.let { parentResult -> var speedIndex = 0 @@ -72,7 +79,8 @@ class PlayerControlsPatch : BytecodePatch( if (instruction.opcode != Opcode.IGET_BOOLEAN) continue if (getInstruction(index).registerA == targetRegister) { - speedEDUVisibleReference = getInstruction(index).reference + speedEDUVisibleReference = + getInstruction(index).reference speedIndex = index break } @@ -80,7 +88,12 @@ class PlayerControlsPatch : BytecodePatch( if (speedIndex == 0) return PatchResultError("SpeedEduVisibleParent Instruction not found!") } - SpeedEduVisibleFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.let { + SpeedEduVisibleFingerprint.also { + it.resolve( + context, + parentResult.classDef + ) + }.result?.mutableMethod?.let { it.implementation!!.instructions.apply { for ((index, instruction) in withIndex()) { if (instruction.opcode != Opcode.IPUT_BOOLEAN) continue @@ -88,7 +101,8 @@ class PlayerControlsPatch : BytecodePatch( if (it.getInstruction(index).reference == speedEDUVisibleReference) { speedEDUVisibleMutableMethod = it speedEDUVisibleIndex = index - speedEDUVisibleRegister = it.getInstruction(index).registerA + speedEDUVisibleRegister = + it.getInstruction(index).registerA break } } @@ -146,7 +160,10 @@ class PlayerControlsPatch : BytecodePatch( fun injectVisibility(descriptor: String) { playerControlsVisibilityResult.injectVisibilityCall(descriptor, "changeVisibility") - seekEDUVisibleResult.injectVisibilityCall(descriptor, "changeVisibilityNegatedImmediate") + seekEDUVisibleResult.injectVisibilityCall( + descriptor, + "changeVisibilityNegatedImmediate" + ) userScrubbingResult.injectVisibilityCall(descriptor, "changeVisibilityNegatedImmediate") injectSpeedEduVisibilityCall(descriptor) } diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/playeroverlay/patch/PlayerOverlaysHookPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/playeroverlay/patch/PlayerOverlaysHookPatch.kt index ab6a3a041..1fa49345b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/playeroverlay/patch/PlayerOverlaysHookPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/playeroverlay/patch/PlayerOverlaysHookPatch.kt @@ -9,7 +9,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.playeroverlay.fingerprint.PlayerOverlaysOnFinishInflateFingerprint import app.revanced.util.integrations.Constants.UTILS_PATH diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/playertype/patch/PlayerTypeHookPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/playertype/patch/PlayerTypeHookPatch.kt index 153f003ba..800839262 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/playertype/patch/PlayerTypeHookPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/playertype/patch/PlayerTypeHookPatch.kt @@ -11,7 +11,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.playertype.fingerprint.PlayerTypeFingerprint import app.revanced.patches.youtube.utils.playertype.fingerprint.VideoStateFingerprint import app.revanced.util.integrations.Constants.UTILS_PATH diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/quickactionscontainer/patch/HideQuickActionsContainerPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/quickactionscontainer/patch/HideQuickActionsContainerPatch.kt index 9aa76f36d..f83ee39df 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/quickactionscontainer/patch/HideQuickActionsContainerPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/quickactionscontainer/patch/HideQuickActionsContainerPatch.kt @@ -10,7 +10,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.quickactionscontainer.fingerprints.QuickActionsElementFingerprint import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.util.integrations.Constants.FULLSCREEN diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/patch/SharedResourceIdPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/patch/SharedResourceIdPatch.kt index ddc8c80a6..30e48a8ca 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/patch/SharedResourceIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/patch/SharedResourceIdPatch.kt @@ -8,10 +8,16 @@ import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.util.enum.ResourceType -import app.revanced.util.enum.ResourceType.* +import app.revanced.util.enum.ResourceType.ATTR +import app.revanced.util.enum.ResourceType.COLOR +import app.revanced.util.enum.ResourceType.DIMEN +import app.revanced.util.enum.ResourceType.DRAWABLE +import app.revanced.util.enum.ResourceType.ID +import app.revanced.util.enum.ResourceType.LAYOUT +import app.revanced.util.enum.ResourceType.STRING @Name("shared-resource-id") @DependsOn([ResourceMappingPatch::class]) @@ -104,8 +110,10 @@ class SharedResourceIdPatch : ResourcePatch { FullScreenEngagementPanel = find(ID, "fullscreen_engagement_panel_holder") HorizontalCardList = find(LAYOUT, "horizontal_card_list") ImageOnlyTab = find(LAYOUT, "image_only_tab") - InlineTimeBarColorizedBarPlayedColorDark = find(COLOR, "inline_time_bar_colorized_bar_played_color_dark") - InlineTimeBarPlayedNotHighlightedColor = find(COLOR, "inline_time_bar_played_not_highlighted_color") + InlineTimeBarColorizedBarPlayedColorDark = + find(COLOR, "inline_time_bar_colorized_bar_played_color_dark") + InlineTimeBarPlayedNotHighlightedColor = + find(COLOR, "inline_time_bar_played_not_highlighted_color") InsetOverlayViewLayout = find(ID, "inset_overlay_view_layout") LiveChatButton = find(ID, "live_chat_overlay_button") QuickActionsElementContainer = find(ID, "quick_actions_element_container") diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/patch/ReturnYouTubeDislikePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/patch/ReturnYouTubeDislikePatch.kt index 62a8928ac..86074c6d9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/patch/ReturnYouTubeDislikePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/patch/ReturnYouTubeDislikePatch.kt @@ -15,10 +15,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.utils.returnyoutubedislike.oldlayout.patch.ReturnYouTubeDislikeOldLayoutPatch -import app.revanced.patches.youtube.utils.returnyoutubedislike.shorts.patch.ReturnYouTubeDislikeShortsPatch -import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints.DislikeFingerprint import app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints.LikeFingerprint import app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints.RemoveLikeFingerprint @@ -26,6 +23,9 @@ import app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerpri import app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints.TextComponentConstructorFingerprint import app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints.TextComponentContextFingerprint import app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints.TextComponentTmpFingerprint +import app.revanced.patches.youtube.utils.returnyoutubedislike.oldlayout.patch.ReturnYouTubeDislikeOldLayoutPatch +import app.revanced.patches.youtube.utils.returnyoutubedislike.shorts.patch.ReturnYouTubeDislikeShortsPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.patches.youtube.utils.videoid.mainstream.patch.MainstreamVideoIdPatch import app.revanced.util.integrations.Constants.UTILS_PATH import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction @@ -74,7 +74,12 @@ class ReturnYouTubeDislikePatch : BytecodePatch( TextComponentConstructorFingerprint.result?.let { parentResult -> - TextComponentContextFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let { + TextComponentContextFingerprint.also { + it.resolve( + context, + parentResult.classDef + ) + }.result?.let { it.mutableMethod.apply { val conversionContextIndex = it.scanResult.patternScanResult!!.startIndex conversionContextFieldReference = @@ -82,7 +87,12 @@ class ReturnYouTubeDislikePatch : BytecodePatch( } } ?: return TextComponentContextFingerprint.toErrorResult() - TextComponentTmpFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let { + TextComponentTmpFingerprint.also { + it.resolve( + context, + parentResult.classDef + ) + }.result?.let { it.mutableMethod.apply { val startIndex = it.scanResult.patternScanResult!!.startIndex tmpRegister = @@ -91,11 +101,17 @@ class ReturnYouTubeDislikePatch : BytecodePatch( } ?: return TextComponentTmpFingerprint.toErrorResult() - TextComponentAtomicReferenceFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let { + TextComponentAtomicReferenceFingerprint.also { + it.resolve( + context, + parentResult.classDef + ) + }.result?.let { it.mutableMethod.apply { val atomicReferenceStartIndex = it.scanResult.patternScanResult!!.startIndex val insertIndex = it.scanResult.patternScanResult!!.endIndex - val moveCharSequenceInstruction = getInstruction(insertIndex) + val moveCharSequenceInstruction = + getInstruction(insertIndex) val atomicReferenceRegister = getInstruction(atomicReferenceStartIndex).registerC @@ -129,6 +145,7 @@ class ReturnYouTubeDislikePatch : BytecodePatch( return PatchResultSuccess() } + private companion object { const val INTEGRATIONS_RYD_CLASS_DESCRIPTOR = "$UTILS_PATH/ReturnYouTubeDislikePatch;" diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/oldlayout/patch/ReturnYouTubeDislikeOldLayoutPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/oldlayout/patch/ReturnYouTubeDislikeOldLayoutPatch.kt index 58680ceb7..ab3907b87 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/oldlayout/patch/ReturnYouTubeDislikeOldLayoutPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/oldlayout/patch/ReturnYouTubeDislikeOldLayoutPatch.kt @@ -10,7 +10,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.DislikeButton import app.revanced.patches.youtube.utils.returnyoutubedislike.oldlayout.fingerprints.ButtonTagFingerprint @@ -31,8 +31,10 @@ class ReturnYouTubeDislikeOldLayoutPatch : BytecodePatch( it.mutableMethod.apply { val dislikeButtonIndex = getWideLiteralIndex(DislikeButton) - val resourceIdentifierRegister = getInstruction(dislikeButtonIndex).registerA - val textViewRegister = getInstruction(dislikeButtonIndex + 4).registerA + val resourceIdentifierRegister = + getInstruction(dislikeButtonIndex).registerA + val textViewRegister = + getInstruction(dislikeButtonIndex + 4).registerA addInstruction( dislikeButtonIndex + 4, @@ -43,6 +45,7 @@ class ReturnYouTubeDislikeOldLayoutPatch : BytecodePatch( return PatchResultSuccess() } + private companion object { const val INTEGRATIONS_RYD_CLASS_DESCRIPTOR = "$UTILS_PATH/ReturnYouTubeDislikePatch;" diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/shorts/patch/ReturnYouTubeDislikeShortsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/shorts/patch/ReturnYouTubeDislikeShortsPatch.kt index 3e4c1e7c3..9e1f243ad 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/shorts/patch/ReturnYouTubeDislikeShortsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/shorts/patch/ReturnYouTubeDislikeShortsPatch.kt @@ -10,7 +10,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.returnyoutubedislike.shorts.fingerprints.ShortsTextViewFingerprint import app.revanced.util.integrations.Constants.UTILS_PATH import org.jf.dexlib2.iface.instruction.ReferenceInstruction @@ -27,7 +27,8 @@ class ReturnYouTubeDislikeShortsPatch : BytecodePatch( val patternResult = it.scanResult.patternScanResult!! // If the field is true, the TextView is for a dislike button. - val isDisLikesBooleanReference = getInstruction(patternResult.endIndex).reference + val isDisLikesBooleanReference = + getInstruction(patternResult.endIndex).reference val textViewFieldReference = // Like/Dislike button TextView field getInstruction(patternResult.endIndex - 2).reference @@ -54,6 +55,7 @@ class ReturnYouTubeDislikeShortsPatch : BytecodePatch( } ?: return ShortsTextViewFingerprint.toErrorResult() return PatchResultSuccess() } + private companion object { const val INTEGRATIONS_RYD_CLASS_DESCRIPTOR = "$UTILS_PATH/ReturnYouTubeDislikePatch;" diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubeusername/patch/ReturnYouTubeUserNamePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubeusername/patch/ReturnYouTubeUserNamePatch.kt index d30dbceaf..4bc3aca56 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubeusername/patch/ReturnYouTubeUserNamePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubeusername/patch/ReturnYouTubeUserNamePatch.kt @@ -13,7 +13,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.returnyoutubeusername.fingerprints.SpannableStringBuilderFingerprint import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import org.jf.dexlib2.iface.instruction.ReferenceInstruction diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/settings/bytecode/patch/SettingsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/settings/bytecode/patch/SettingsBytecodePatch.kt index 76ebcdab1..1ebae2772 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/settings/bytecode/patch/SettingsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/settings/bytecode/patch/SettingsBytecodePatch.kt @@ -10,8 +10,8 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.integrations.patch.IntegrationsPatch import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.utils.settings.bytecode.fingerprints.ThemeSetterSystemFingerprint @@ -55,6 +55,7 @@ class SettingsBytecodePatch : BytecodePatch( return PatchResultSuccess() } + companion object { const val SET_THEME = "invoke-static {v0}, $INTEGRATIONS_PATH/utils/ThemeHelper;->setTheme(Ljava/lang/Object;)V" diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/settings/resource/patch/SettingsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/settings/resource/patch/SettingsPatch.kt index b205fd79b..24565db90 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/settings/resource/patch/SettingsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/settings/resource/patch/SettingsPatch.kt @@ -1,6 +1,5 @@ package app.revanced.patches.youtube.utils.settings.resource.patch -import app.revanced.extensions.doRecursively import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version @@ -9,8 +8,8 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.shared.patch.settings.AbstractSettingsResourcePatch +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.integrations.patch.IntegrationsPatch import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.utils.settings.bytecode.patch.SettingsBytecodePatch @@ -25,7 +24,6 @@ import app.revanced.util.resources.ResourceUtils.copyResources import org.w3c.dom.Element import java.io.File import java.nio.file.Paths -import kotlin.io.path.exists @Patch @Name("settings") @@ -79,20 +77,20 @@ class SettingsPatch : AbstractSettingsResourcePatch( arrayOf("Theme.YouTube.Settings", "Theme.YouTube.Settings.Dark").forEach { themeName -> context.xmlEditor["res/values/styles.xml"].use { editor -> with(editor.file) { - val resourcesNode = getElementsByTagName("resources").item(0) as Element + val resourcesNode = getElementsByTagName("resources").item(0) as Element - val newElement: Element = createElement("item") - newElement.setAttribute("name", "android:listDivider") + val newElement: Element = createElement("item") + newElement.setAttribute("name", "android:listDivider") - for (i in 0 until resourcesNode.childNodes.length) { - val node = resourcesNode.childNodes.item(i) as? Element ?: continue + for (i in 0 until resourcesNode.childNodes.length) { + val node = resourcesNode.childNodes.item(i) as? Element ?: continue - if (node.getAttribute("name") == themeName) { - newElement.appendChild(createTextNode("@null")) + if (node.getAttribute("name") == themeName) { + newElement.appendChild(createTextNode("@null")) - node.appendChild(newElement) - } + node.appendChild(newElement) } + } } } } @@ -115,8 +113,11 @@ class SettingsPatch : AbstractSettingsResourcePatch( if (File(targetDirectory).exists()) { fun copyResources(resourceGroups: List) { - try { context.copyFiles(resourceGroups, iconPath) } - catch (_: Exception) { context.makeDirectoryAndCopyFiles(resourceGroups, iconPath) } + try { + context.copyFiles(resourceGroups, iconPath) + } catch (_: Exception) { + context.makeDirectoryAndCopyFiles(resourceGroups, iconPath) + } } val iconResourceFileNames = @@ -136,6 +137,7 @@ class SettingsPatch : AbstractSettingsResourcePatch( return PatchResultSuccess() } + companion object { internal lateinit var contexts: ResourceContext diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/bytecode/fingerprints/OverlayViewLayoutFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/bytecode/fingerprints/OverlayViewLayoutFingerprint.kt index 6607f24e8..7c52fed48 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/bytecode/fingerprints/OverlayViewLayoutFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/bytecode/fingerprints/OverlayViewLayoutFingerprint.kt @@ -12,5 +12,9 @@ object OverlayViewLayoutFingerprint : MethodFingerprint( Opcode.MOVE_RESULT_OBJECT, Opcode.CHECK_CAST ), - customFingerprint = { it, _ -> it.definingClass.endsWith("YouTubeControlsOverlay;") && it.isWideLiteralExists(InsetOverlayViewLayout) } + customFingerprint = { it, _ -> + it.definingClass.endsWith("YouTubeControlsOverlay;") && it.isWideLiteralExists( + InsetOverlayViewLayout + ) + } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/bytecode/fingerprints/RectangleFieldInvalidatorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/bytecode/fingerprints/RectangleFieldInvalidatorFingerprint.kt index 8e0bf8d6b..ea813f38a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/bytecode/fingerprints/RectangleFieldInvalidatorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/bytecode/fingerprints/RectangleFieldInvalidatorFingerprint.kt @@ -13,8 +13,10 @@ object RectangleFieldInvalidatorFingerprint : MethodFingerprint( // the method has definitely more than 5 instructions if (instructionCount < 5) return@custom false - val referenceInstruction = instructions.elementAt(instructionCount - 2) // the second to last instruction - val reference = ((referenceInstruction as? ReferenceInstruction)?.reference as? MethodReference) + val referenceInstruction = + instructions.elementAt(instructionCount - 2) // the second to last instruction + val reference = + ((referenceInstruction as? ReferenceInstruction)?.reference as? MethodReference) reference?.parameterTypes?.size == 1 && reference.name == "invalidate" // the reference is the invalidate(..) method } diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt index c7630446d..e096241ad 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt @@ -14,16 +14,19 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.shared.fingerprints.SeekbarFingerprint -import app.revanced.patches.shared.fingerprints.SeekbarOnDrawFingerprint -import app.revanced.patches.shared.fingerprints.TotalTimeFingerprint +import app.revanced.patches.youtube.utils.fingerprints.SeekbarFingerprint +import app.revanced.patches.youtube.utils.fingerprints.SeekbarOnDrawFingerprint +import app.revanced.patches.youtube.utils.fingerprints.TotalTimeFingerprint +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.overridespeed.patch.OverrideSpeedHookPatch import app.revanced.patches.youtube.utils.playercontrols.patch.PlayerControlsPatch import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.InsetOverlayViewLayout import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.TotalTime -import app.revanced.patches.youtube.utils.sponsorblock.bytecode.fingerprints.* +import app.revanced.patches.youtube.utils.sponsorblock.bytecode.fingerprints.EndScreenEngagementPanelsFingerprint +import app.revanced.patches.youtube.utils.sponsorblock.bytecode.fingerprints.OverlayViewLayoutFingerprint +import app.revanced.patches.youtube.utils.sponsorblock.bytecode.fingerprints.PlayerControllerFingerprint +import app.revanced.patches.youtube.utils.sponsorblock.bytecode.fingerprints.RectangleFieldInvalidatorFingerprint import app.revanced.patches.youtube.utils.videoid.legacy.patch.LegacyVideoIdPatch import app.revanced.patches.youtube.utils.videoid.mainstream.patch.MainstreamVideoIdPatch import app.revanced.util.bytecode.BytecodeHelper.injectInit @@ -81,7 +84,7 @@ class SponsorBlockBytecodePatch : BytecodePatch( */ insertMethod = SeekbarFingerprint.result!!.let { SeekbarOnDrawFingerprint.apply { resolve(context, it.mutableClass) } - }.result?.mutableMethod?: return SeekbarFingerprint.toErrorResult() + }.result?.mutableMethod ?: return SeekbarFingerprint.toErrorResult() insertInstructions = insertMethod.implementation!!.instructions @@ -126,7 +129,9 @@ class SponsorBlockBytecodePatch : BytecodePatch( val drawSegmentInstructionInsertIndex = index - 1 val (canvasInstance, centerY) = - insertMethod.getInstruction(drawSegmentInstructionInsertIndex).let { it.registerC to it.registerE } + insertMethod.getInstruction( + drawSegmentInstructionInsertIndex + ).let { it.registerC to it.registerE } insertMethod.addInstruction( drawSegmentInstructionInsertIndex, @@ -139,8 +144,8 @@ class SponsorBlockBytecodePatch : BytecodePatch( * Voting & Shield button */ arrayOf("CreateSegmentButtonController", "VotingButtonController").forEach { - PlayerControlsPatch.initializeSB("$INTEGRATIONS_BUTTON_CLASS_DESCRIPTOR/ui/$it;") - PlayerControlsPatch.injectVisibility("$INTEGRATIONS_BUTTON_CLASS_DESCRIPTOR/ui/$it;") + PlayerControlsPatch.initializeSB("$INTEGRATIONS_BUTTON_CLASS_DESCRIPTOR/ui/$it;") + PlayerControlsPatch.injectVisibility("$INTEGRATIONS_BUTTON_CLASS_DESCRIPTOR/ui/$it;") } EndScreenEngagementPanelsFingerprint.result?.mutableMethod?.let { @@ -170,8 +175,8 @@ class SponsorBlockBytecodePatch : BytecodePatch( /** * Initialize the SponsorBlock view */ - OverlayViewLayoutFingerprint.result?.mutableMethod?.let{ - it.apply{ + OverlayViewLayoutFingerprint.result?.mutableMethod?.let { + it.apply { val targetIndex = getWideLiteralIndex(InsetOverlayViewLayout) + 3 val targetRegister = getInstruction(targetIndex).registerA @@ -185,7 +190,10 @@ class SponsorBlockBytecodePatch : BytecodePatch( /** * Replace strings */ - RectangleFieldInvalidatorFingerprint.resolve(context, SeekbarOnDrawFingerprint.result!!.classDef) + RectangleFieldInvalidatorFingerprint.resolve( + context, + SeekbarOnDrawFingerprint.result!!.classDef + ) val rectangleFieldInvalidatorInstructions = RectangleFieldInvalidatorFingerprint.result!!.method.implementation!!.instructions val rectangleFieldName = diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/resource/patch/SponsorBlockResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/resource/patch/SponsorBlockResourcePatch.kt index 622029d5b..35268bbc2 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/resource/patch/SponsorBlockResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/resource/patch/SponsorBlockResourcePatch.kt @@ -9,7 +9,7 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.patches.youtube.utils.sponsorblock.bytecode.patch.SponsorBlockBytecodePatch import app.revanced.util.resources.ResourceUtils @@ -65,26 +65,32 @@ class SponsorBlockResourcePatch : ResourcePatch { // copy nodes from host resources to their real xml files hostingXmlResources.forEach { (path, resources) -> resources.forEach { resource -> - val hostingResourceStream = this.javaClass.classLoader.getResourceAsStream("youtube/sponsorblock/host/$path/$resource.xml")!! + val hostingResourceStream = + this.javaClass.classLoader.getResourceAsStream("youtube/sponsorblock/host/$path/$resource.xml")!! val targetXmlEditor = context.xmlEditor["res/$path/$resource.xml"] "RelativeLayout".copyXmlNode( context.xmlEditor[hostingResourceStream], targetXmlEditor ).also { - val children = targetXmlEditor.file.getElementsByTagName("RelativeLayout").item(0).childNodes + val children = targetXmlEditor.file.getElementsByTagName("RelativeLayout") + .item(0).childNodes // Replace the startOf with the voting button view so that the button does not overlap for (i in 1 until children.length) { val view = children.item(i) // Replace the attribute for a specific node only - if (!(view.hasAttributes() && view.attributes.getNamedItem("android:id").nodeValue.endsWith("player_video_heading"))) continue + if (!(view.hasAttributes() && view.attributes.getNamedItem("android:id").nodeValue.endsWith( + "player_video_heading" + )) + ) continue // voting button id from the voting button view from the youtube_controls_layout.xml host file val votingButtonId = "@+id/sb_voting_button" - view.attributes.getNamedItem("android:layout_toStartOf").nodeValue = votingButtonId + view.attributes.getNamedItem("android:layout_toStartOf").nodeValue = + votingButtonId break } diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/legacy/patch/LegacyVideoIdPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/legacy/patch/LegacyVideoIdPatch.kt index 859665212..7263dc514 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/legacy/patch/LegacyVideoIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/legacy/patch/LegacyVideoIdPatch.kt @@ -10,7 +10,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.videoid.legacy.fingerprint.LegacyVideoIdFingerprint import app.revanced.util.integrations.Constants.VIDEO_PATH import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @@ -29,7 +29,8 @@ class LegacyVideoIdPatch : BytecodePatch( it.mutableMethod.apply { insertMethod = this - videoIdRegister = (implementation!!.instructions[insertIndex + 1] as OneRegisterInstruction).registerA + videoIdRegister = + (implementation!!.instructions[insertIndex + 1] as OneRegisterInstruction).registerA } offset++ // offset so setCurrentVideoId is called before any injected call } ?: return LegacyVideoIdFingerprint.toErrorResult() diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/fingerprint/VideoTimeHighPrecisionFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/fingerprint/VideoTimeHighPrecisionFingerprint.kt index 7cd6b3e83..555b16761 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/fingerprint/VideoTimeHighPrecisionFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/fingerprint/VideoTimeHighPrecisionFingerprint.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -object VideoTimeHighPrecisionFingerprint : MethodFingerprint ( +object VideoTimeHighPrecisionFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, parameters = listOf("J", "J", "J", "J", "I", "L"), diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/patch/MainstreamVideoIdPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/patch/MainstreamVideoIdPatch.kt index 3d7856a8d..1c7cd2ad3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/patch/MainstreamVideoIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/patch/MainstreamVideoIdPatch.kt @@ -17,9 +17,16 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.playertype.patch.PlayerTypeHookPatch -import app.revanced.patches.youtube.utils.videoid.mainstream.fingerprint.* +import app.revanced.patches.youtube.utils.videoid.mainstream.fingerprint.MainstreamVideoIdFingerprint +import app.revanced.patches.youtube.utils.videoid.mainstream.fingerprint.PlayerControllerSetTimeReferenceFingerprint +import app.revanced.patches.youtube.utils.videoid.mainstream.fingerprint.PlayerInitFingerprint +import app.revanced.patches.youtube.utils.videoid.mainstream.fingerprint.SeekFingerprint +import app.revanced.patches.youtube.utils.videoid.mainstream.fingerprint.TimebarFingerprint +import app.revanced.patches.youtube.utils.videoid.mainstream.fingerprint.VideoLengthFingerprint +import app.revanced.patches.youtube.utils.videoid.mainstream.fingerprint.VideoTimeHighPrecisionFingerprint +import app.revanced.patches.youtube.utils.videoid.mainstream.fingerprint.VideoTimeHighPrecisionParentFingerprint import app.revanced.util.integrations.Constants.VIDEO_PATH import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.builder.MutableMethodImplementation @@ -48,7 +55,8 @@ class MainstreamVideoIdPatch : BytecodePatch( override fun execute(context: BytecodeContext): PatchResult { PlayerInitFingerprint.result?.let { parentResult -> - playerInitMethod = parentResult.mutableClass.methods.first { MethodUtil.isConstructor(it) } + playerInitMethod = + parentResult.mutableClass.methods.first { MethodUtil.isConstructor(it) } // hook the player controller for use through integrations onCreateHook(INTEGRATIONS_CLASS_DESCRIPTOR, "initialize") @@ -85,7 +93,12 @@ class MainstreamVideoIdPatch : BytecodePatch( * Set the high precision video time method */ VideoTimeHighPrecisionParentFingerprint.result?.let { parentResult -> - VideoTimeHighPrecisionFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.let { method -> + VideoTimeHighPrecisionFingerprint.also { + it.resolve( + context, + parentResult.classDef + ) + }.result?.mutableMethod?.let { method -> highPrecisionTimeMethod = method } ?: return VideoTimeHighPrecisionFingerprint.toErrorResult() } ?: return VideoTimeHighPrecisionParentFingerprint.toErrorResult() diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/patch/CustomVideoSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/patch/CustomVideoSpeedPatch.kt index 025cbe6ed..af1525ea6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/patch/CustomVideoSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/patch/CustomVideoSpeedPatch.kt @@ -13,7 +13,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.patches.youtube.video.customspeed.fingerprints.SpeedArrayGeneratorFingerprint import app.revanced.patches.youtube.video.customspeed.fingerprints.SpeedLimiterFingerprint @@ -40,7 +40,7 @@ class CustomVideoSpeedPatch : BytecodePatch( override fun execute(context: BytecodeContext): PatchResult { SpeedArrayGeneratorFingerprint.result?.let { result -> result.mutableMethod.apply { - val targetIndex= result.scanResult.patternScanResult!!.startIndex + val targetIndex = result.scanResult.patternScanResult!!.startIndex val targetRegister = getInstruction(targetIndex).registerA addInstructions( @@ -73,7 +73,8 @@ class CustomVideoSpeedPatch : BytecodePatch( for ((index, instruction) in targetInstruction.withIndex()) { if (instruction.opcode != Opcode.SGET_OBJECT) continue - val targetReference = getInstruction(index).reference.toString() + val targetReference = + getInstruction(index).reference.toString() if (targetReference.contains("PlayerConfigModel;") && targetReference.endsWith("[F")) { val register = getInstruction(index).registerA @@ -92,11 +93,15 @@ class CustomVideoSpeedPatch : BytecodePatch( SpeedLimiterFingerprint.result?.let { result -> result.mutableMethod.apply { - val limiterMinConstIndex = implementation!!.instructions.indexOfFirst { (it as? NarrowLiteralInstruction)?.narrowLiteral == 0.25f.toRawBits() } - val limiterMaxConstIndex = implementation!!.instructions.indexOfFirst { (it as? NarrowLiteralInstruction)?.narrowLiteral == 2.0f.toRawBits() } + val limiterMinConstIndex = + implementation!!.instructions.indexOfFirst { (it as? NarrowLiteralInstruction)?.narrowLiteral == 0.25f.toRawBits() } + val limiterMaxConstIndex = + implementation!!.instructions.indexOfFirst { (it as? NarrowLiteralInstruction)?.narrowLiteral == 2.0f.toRawBits() } - val limiterMinConstDestination = getInstruction(limiterMinConstIndex).registerA - val limiterMaxConstDestination = getInstruction(limiterMaxConstIndex).registerA + val limiterMinConstDestination = + getInstruction(limiterMinConstIndex).registerA + val limiterMaxConstDestination = + getInstruction(limiterMaxConstIndex).registerA replaceInstruction( limiterMinConstIndex, diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/hdr/patch/DisableHdrVideoPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/hdr/patch/DisableHdrVideoPatch.kt index 2c74221d2..00a864174 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/hdr/patch/DisableHdrVideoPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/hdr/patch/DisableHdrVideoPatch.kt @@ -15,7 +15,7 @@ import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.patches.youtube.video.hdr.fingerprints.HdrCapabilitiesFingerprint import app.revanced.util.integrations.Constants.VIDEO_PATH @@ -32,10 +32,11 @@ class DisableHdrVideoPatch : BytecodePatch( override fun execute(context: BytecodeContext): PatchResult { HdrCapabilitiesFingerprint.result?.let { - with (context - .toMethodWalker(it.method) - .nextMethod(it.scanResult.patternScanResult!!.endIndex, true) - .getMethod() as MutableMethod + with( + context + .toMethodWalker(it.method) + .nextMethod(it.scanResult.patternScanResult!!.endIndex, true) + .getMethod() as MutableMethod ) { addInstructionsWithLabels( 0, """ diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/quality/patch/VideoQualityPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/quality/patch/VideoQualityPatch.kt index 9dd2cfc08..3ef9fea3d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/quality/patch/VideoQualityPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/quality/patch/VideoQualityPatch.kt @@ -14,11 +14,15 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch.Companion.contexts import app.revanced.patches.youtube.utils.videoid.legacy.patch.LegacyVideoIdPatch -import app.revanced.patches.youtube.video.quality.fingerprints.* +import app.revanced.patches.youtube.video.quality.fingerprints.VideoQualityReferenceFingerprint +import app.revanced.patches.youtube.video.quality.fingerprints.VideoQualitySetterFingerprint +import app.revanced.patches.youtube.video.quality.fingerprints.VideoQualitySettingsFingerprint +import app.revanced.patches.youtube.video.quality.fingerprints.VideoQualitySettingsParentFingerprint +import app.revanced.patches.youtube.video.quality.fingerprints.VideoUserQualityChangeFingerprint import app.revanced.util.integrations.Constants.VIDEO_PATH import app.revanced.util.resources.ResourceUtils.copyXmlNode import org.jf.dexlib2.iface.instruction.ReferenceInstruction @@ -43,7 +47,12 @@ class VideoQualityPatch : BytecodePatch( ) { override fun execute(context: BytecodeContext): PatchResult { VideoQualitySetterFingerprint.result?.let { parentResult -> - VideoQualityReferenceFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let { result -> + VideoQualityReferenceFingerprint.also { + it.resolve( + context, + parentResult.classDef + ) + }.result?.let { result -> result.mutableMethod.apply { qualityFieldReference = getInstruction(0).reference as FieldReference @@ -54,15 +63,26 @@ class VideoQualityPatch : BytecodePatch( } } ?: return VideoQualityReferenceFingerprint.toErrorResult() - VideoUserQualityChangeFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.addInstruction( + VideoUserQualityChangeFingerprint.also { + it.resolve( + context, + parentResult.classDef + ) + }.result?.mutableMethod?.addInstruction( 0, "invoke-static {p3}, $INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR->userChangedQuality(I)V" ) ?: return VideoUserQualityChangeFingerprint.toErrorResult() } ?: return VideoQualitySetterFingerprint.toErrorResult() VideoQualitySettingsParentFingerprint.result?.let { parentResult -> - VideoQualitySettingsFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.let { - relayFieldReference = it.getInstruction(0).reference as FieldReference + VideoQualitySettingsFingerprint.also { + it.resolve( + context, + parentResult.classDef + ) + }.result?.mutableMethod?.let { + relayFieldReference = + it.getInstruction(0).reference as FieldReference } ?: return VideoQualitySettingsFingerprint.toErrorResult() parentResult.mutableMethod.addInstructions( @@ -99,6 +119,7 @@ class VideoQualityPatch : BytecodePatch( return PatchResultSuccess() } + private companion object { const val INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR = "$VIDEO_PATH/VideoQualityPatch;" diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/patch/VideoSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/patch/VideoSpeedPatch.kt index fa26914c5..68bdf23be 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/patch/VideoSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/patch/VideoSpeedPatch.kt @@ -12,7 +12,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.overridespeed.patch.OverrideSpeedHookPatch import app.revanced.patches.youtube.utils.playertype.patch.PlayerTypeHookPatch import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch diff --git a/src/main/kotlin/app/revanced/util/enum/CategoryType.kt b/src/main/kotlin/app/revanced/util/enum/CategoryType.kt index e796f7e0e..70118c05c 100644 --- a/src/main/kotlin/app/revanced/util/enum/CategoryType.kt +++ b/src/main/kotlin/app/revanced/util/enum/CategoryType.kt @@ -1,7 +1,7 @@ package app.revanced.util.enum internal enum class CategoryType(val value: String) { - ADS("ads"), - LAYOUT("layout"), - MISC("misc") + ADS("ads"), + LAYOUT("layout"), + MISC("misc") } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/util/enum/ResourceType.kt b/src/main/kotlin/app/revanced/util/enum/ResourceType.kt index 12d294a2b..5d469d687 100644 --- a/src/main/kotlin/app/revanced/util/enum/ResourceType.kt +++ b/src/main/kotlin/app/revanced/util/enum/ResourceType.kt @@ -1,13 +1,13 @@ package app.revanced.util.enum internal enum class ResourceType(val value: String) { - ATTR("attr"), - BOOL("bool"), - COLOR("color"), - DIMEN("dimen"), - DRAWABLE("drawable"), - ID("id"), - LAYOUT("layout"), - STRING("string"), - STYLE("style") + ATTR("attr"), + BOOL("bool"), + COLOR("color"), + DIMEN("dimen"), + DRAWABLE("drawable"), + ID("id"), + LAYOUT("layout"), + STRING("string"), + STYLE("style") } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/util/microg/Constants.kt b/src/main/kotlin/app/revanced/util/microg/Constants.kt index 912b97561..0eb8938b8 100644 --- a/src/main/kotlin/app/revanced/util/microg/Constants.kt +++ b/src/main/kotlin/app/revanced/util/microg/Constants.kt @@ -18,7 +18,8 @@ internal object Constants { /** * meta-data for microG package signature spoofing on patched builds */ - const val META_SPOOFED_PACKAGE_SIGNATURE = "$MICROG_VENDOR.android.gms.SPOOFED_PACKAGE_SIGNATURE" + const val META_SPOOFED_PACKAGE_SIGNATURE = + "$MICROG_VENDOR.android.gms.SPOOFED_PACKAGE_SIGNATURE" /** * meta-data for microG package detection diff --git a/src/main/kotlin/app/revanced/util/microg/MicroGBytecodeHelper.kt b/src/main/kotlin/app/revanced/util/microg/MicroGBytecodeHelper.kt index 012a86a02..fdee3f9b0 100644 --- a/src/main/kotlin/app/revanced/util/microg/MicroGBytecodeHelper.kt +++ b/src/main/kotlin/app/revanced/util/microg/MicroGBytecodeHelper.kt @@ -32,7 +32,11 @@ internal object MicroGBytecodeHelper { return { referencedString -> when (referencedString) { "$fromPackageName.SuggestionsProvider", - "$fromPackageName.fileprovider" -> referencedString.replace(fromPackageName, toPackageName) + "$fromPackageName.fileprovider" -> referencedString.replace( + fromPackageName, + toPackageName + ) + else -> null } } @@ -61,7 +65,8 @@ internal object MicroGBytecodeHelper { val targetIndex = implementation!!.instructions.indexOfFirst { instructions -> if (instructions.opcode != Opcode.CONST_STRING) return@indexOfFirst false - val instructionString = ((instructions as Instruction21c).reference as StringReference).string + val instructionString = + ((instructions as Instruction21c).reference as StringReference).string if (instructionString != fromPackageName) return@indexOfFirst false targetRegister = instructions.registerA diff --git a/src/main/kotlin/app/revanced/util/resources/IconHelper.kt b/src/main/kotlin/app/revanced/util/resources/IconHelper.kt index 3c9d5859b..51b790060 100644 --- a/src/main/kotlin/app/revanced/util/resources/IconHelper.kt +++ b/src/main/kotlin/app/revanced/util/resources/IconHelper.kt @@ -170,7 +170,7 @@ internal object IconHelper { iconPath: String, directory: String, iconArray: Array - ){ + ) { arrayOf( "xxxhdpi", "xxhdpi", @@ -192,7 +192,7 @@ internal object IconHelper { appName: String, monochromeIconName: String, iconName: String - ){ + ) { try { val relativePath = "drawable/$monochromeIconName.xml" Files.copy( @@ -200,14 +200,15 @@ internal object IconHelper { this["res"].resolve(relativePath).toPath(), StandardCopyOption.REPLACE_EXISTING ) - } catch (_: Exception) {} + } catch (_: Exception) { + } } private fun ResourceContext.copyMusicResources( iconName: String, iconArray: Array, resourceNames: String - ){ + ) { iconArray.forEach { path -> val relativePath = "drawable-$path/$resourceNames.png" @@ -225,7 +226,9 @@ internal object IconHelper { xmlEditor[targetPath].use { editor -> val tags = editor.file.getElementsByTagName("item") List(tags.length) { tags.item(it) as Element } - .filter { it.getAttribute("name").contains("android:windowSplashScreenAnimatedIcon") } + .filter { + it.getAttribute("name").contains("android:windowSplashScreenAnimatedIcon") + } .forEach { it.parentNode.removeChild(it) } } } diff --git a/src/main/kotlin/app/revanced/util/resources/MusicResourceHelper.kt b/src/main/kotlin/app/revanced/util/resources/MusicResourceHelper.kt index 97ddb28b3..75d52000d 100644 --- a/src/main/kotlin/app/revanced/util/resources/MusicResourceHelper.kt +++ b/src/main/kotlin/app/revanced/util/resources/MusicResourceHelper.kt @@ -30,22 +30,25 @@ internal object MusicResourceHelper { private const val YOUTUBE_MUSIC_SETTINGS_KEY = "revanced_extended_settings" - private const val YOUTUBE_MUSIC_CATEGORY_TAG_NAME = "com.google.android.apps.youtube.music.ui.preference.PreferenceCategoryCompat" + private const val YOUTUBE_MUSIC_CATEGORY_TAG_NAME = + "com.google.android.apps.youtube.music.ui.preference.PreferenceCategoryCompat" - private const val YOUTUBE_MUSIC_PREFERENCE_TAG_NAME = "com.google.android.apps.youtube.music.ui.preference.SwitchCompatPreference" + private const val YOUTUBE_MUSIC_PREFERENCE_TAG_NAME = + "com.google.android.apps.youtube.music.ui.preference.SwitchCompatPreference" - private const val YOUTUBE_MUSIC_PREFERENCE_TARGET_CLASS = "com.google.android.libraries.strictmode.penalties.notification.FullStackTraceActivity" + private const val YOUTUBE_MUSIC_PREFERENCE_TARGET_CLASS = + "com.google.android.libraries.strictmode.penalties.notification.FullStackTraceActivity" private var currentMusicPreferenceCategory = emptyArray() private var targetPackage = "com.google.android.apps.youtube.music" - internal fun ResourceContext.setMicroG (newPackage: String) { + internal fun ResourceContext.setMicroG(newPackage: String) { targetPackage = newPackage replacePackageName() } - private fun setMusicPreferenceCategory (newCategory: String) { + private fun setMusicPreferenceCategory(newCategory: String) { currentMusicPreferenceCategory += listOf(newCategory) } @@ -85,9 +88,10 @@ internal object MusicResourceHelper { replacePackageName() } - private fun ResourceContext.replacePackageName(){ + private fun ResourceContext.replacePackageName() { this[YOUTUBE_MUSIC_SETTINGS_PATH].writeText( - this[YOUTUBE_MUSIC_SETTINGS_PATH].readText().replace("\"com.google.android.apps.youtube.music\"", "\"" + targetPackage + "\"") + this[YOUTUBE_MUSIC_SETTINGS_PATH].readText() + .replace("\"com.google.android.apps.youtube.music\"", "\"" + targetPackage + "\"") ) } @@ -129,7 +133,10 @@ internal object MusicResourceHelper { this.adoptChild("intent") { setAttribute("android:targetPackage", targetPackage) setAttribute("android:data", key) - setAttribute("android:targetClass", YOUTUBE_MUSIC_PREFERENCE_TARGET_CLASS) + setAttribute( + "android:targetClass", + YOUTUBE_MUSIC_PREFERENCE_TARGET_CLASS + ) } } } @@ -138,13 +145,19 @@ internal object MusicResourceHelper { internal fun ResourceContext.addReVancedMusicPreference() { this.xmlEditor[YOUTUBE_MUSIC_SETTINGS_PATH].use { editor -> - with (editor.file) { + with(editor.file) { doRecursively loop@{ if (it !is Element) return@loop it.getAttributeNode("android:key")?.let { attribute -> - if (attribute.textContent == "settings_header_about_youtube_music" && it.getAttributeNode("app:allowDividerBelow").textContent == "false") { + if (attribute.textContent == "settings_header_about_youtube_music" && it.getAttributeNode( + "app:allowDividerBelow" + ).textContent == "false" + ) { it.insertNode("PreferenceScreen", it) { - setAttribute("android:title", "@string/" + YOUTUBE_MUSIC_SETTINGS_KEY + "_title") + setAttribute( + "android:title", + "@string/" + YOUTUBE_MUSIC_SETTINGS_KEY + "_title" + ) setAttribute("android:key", YOUTUBE_MUSIC_SETTINGS_KEY) } it.getAttributeNode("app:allowDividerBelow").textContent = "true" diff --git a/src/main/kotlin/app/revanced/util/resources/ResourceHelper.kt b/src/main/kotlin/app/revanced/util/resources/ResourceHelper.kt index 99f6f04bd..8e05c12c5 100644 --- a/src/main/kotlin/app/revanced/util/resources/ResourceHelper.kt +++ b/src/main/kotlin/app/revanced/util/resources/ResourceHelper.kt @@ -22,7 +22,7 @@ internal object ResourceHelper { private var targetPackage = "com.google.android.youtube" - internal fun setMicroG (newPackage: String) { + internal fun setMicroG(newPackage: String) { targetPackage = newPackage } @@ -96,21 +96,26 @@ internal object ResourceHelper { } internal fun ResourceContext.addReVancedPreference(key: String) { - val targetClass = "com.google.android.apps.youtube.app.settings.videoquality.VideoQualitySettingsActivity" + val targetClass = + "com.google.android.apps.youtube.app.settings.videoquality.VideoQualitySettingsActivity" this.xmlEditor[YOUTUBE_SETTINGS_PATH].use { editor -> - with (editor.file) { + with(editor.file) { doRecursively loop@{ if (it !is Element) return@loop it.getAttributeNode("android:key")?.let { attribute -> if (attribute.textContent == "@string/about_key" && it.getAttributeNode("app:iconSpaceReserved").textContent == "false") { it.insertNode("Preference", it) { setAttribute("android:title", "@string/revanced_" + key + "_title") - this.appendChild(ownerDocument.createElement("intent").also { intentNode -> - intentNode.setAttribute("android:targetPackage", targetPackage) - intentNode.setAttribute("android:data", key) - intentNode.setAttribute("android:targetClass", targetClass) - }) + this.appendChild( + ownerDocument.createElement("intent").also { intentNode -> + intentNode.setAttribute( + "android:targetPackage", + targetPackage + ) + intentNode.setAttribute("android:data", key) + intentNode.setAttribute("android:targetClass", targetClass) + }) } it.getAttributeNode("app:iconSpaceReserved").textContent = "true" return@loop diff --git a/src/main/kotlin/app/revanced/util/resources/ResourceUtils.kt b/src/main/kotlin/app/revanced/util/resources/ResourceUtils.kt index 230720840..e5305bf35 100644 --- a/src/main/kotlin/app/revanced/util/resources/ResourceUtils.kt +++ b/src/main/kotlin/app/revanced/util/resources/ResourceUtils.kt @@ -11,7 +11,10 @@ internal object ResourceUtils { * @param sourceResourceDirectory The source resource directory name. * @param resources The resources to copy. */ - internal fun ResourceContext.copyResources(sourceResourceDirectory: String, vararg resources: ResourceGroup) { + internal fun ResourceContext.copyResources( + sourceResourceDirectory: String, + vararg resources: ResourceGroup + ) { val classLoader = ResourceUtils.javaClass.classLoader val targetResourceDirectory = this["res"] @@ -20,7 +23,8 @@ internal object ResourceUtils { val resourceFile = "${resourceGroup.resourceDirectoryName}/$resource" Files.copy( classLoader.getResourceAsStream("$sourceResourceDirectory/$resourceFile")!!, - targetResourceDirectory.resolve(resourceFile).toPath(), StandardCopyOption.REPLACE_EXISTING + targetResourceDirectory.resolve(resourceFile).toPath(), + StandardCopyOption.REPLACE_EXISTING ) } } @@ -39,8 +43,13 @@ internal object ResourceUtils { * @param targetResource The target resource. * @param elementTag The element to copy. */ - internal fun ResourceContext.copyXmlNode(resourceDirectory: String, targetResource: String, elementTag: String) { - val stringsResourceInputStream = ResourceUtils.javaClass.classLoader.getResourceAsStream("$resourceDirectory/$targetResource")!! + internal fun ResourceContext.copyXmlNode( + resourceDirectory: String, + targetResource: String, + elementTag: String + ) { + val stringsResourceInputStream = + ResourceUtils.javaClass.classLoader.getResourceAsStream("$resourceDirectory/$targetResource")!! // Copy nodes from the resources node to the real resource node elementTag.copyXmlNode(