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 4001a38c7..58f0f8d6b 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 @@ -10,7 +10,7 @@ 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.misc.litho.patch.MusicLithoFilterPatch -import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch +import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.patch.videoads.GeneralVideoAdsPatch import app.revanced.util.enum.CategoryType 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 997bfa33e..91584c6a8 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,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.music.misc.settings.resource.patch.MusicSettingsPatch +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.util.enum.CategoryType diff --git a/src/main/kotlin/app/revanced/patches/music/layout/blacknavbar/fingerprints/TabLayoutFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/layout/blacknavbar/fingerprints/TabLayoutFingerprint.kt index 83c6a42f5..a2e79cb9a 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/blacknavbar/fingerprints/TabLayoutFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/blacknavbar/fingerprints/TabLayoutFingerprint.kt @@ -2,7 +2,7 @@ package app.revanced.patches.music.layout.blacknavbar.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.music.misc.resourceid.patch.SharedResourceIdPatch.Companion.colorGreyId +import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch.Companion.ColorGrey import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @@ -16,6 +16,6 @@ object TabLayoutFingerprint : MethodFingerprint( Opcode.INVOKE_STATIC, Opcode.MOVE_RESULT ), - customFingerprint = { it, _ -> it.isWideLiteralExists(colorGreyId) } + customFingerprint = { it, _ -> it.isWideLiteralExists(ColorGrey) } ) 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 fab19c538..9a94d8f06 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 @@ -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.patches.music.layout.blacknavbar.fingerprints.TabLayoutFingerprint -import app.revanced.patches.music.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch +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 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 bb881640a..d26f23207 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 @@ -10,7 +10,7 @@ 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.misc.litho.patch.MusicLithoFilterPatch -import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch +import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.util.enum.CategoryType 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 aa3e13761..7fbb5f184 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 @@ -10,7 +10,7 @@ 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.misc.litho.patch.MusicLithoFilterPatch -import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch +import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.util.enum.CategoryType 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 d7228cb5d..62521af8f 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 @@ -14,7 +14,7 @@ import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.music.layout.castbutton.fingerprints.HideCastButtonFingerprint import app.revanced.patches.music.layout.castbutton.fingerprints.HideCastButtonParentFingerprint -import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch +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 diff --git a/src/main/kotlin/app/revanced/patches/music/layout/categorybar/fingerprints/ChipCloudFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/layout/categorybar/fingerprints/ChipCloudFingerprint.kt index 906bcc1f7..04e7df990 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/categorybar/fingerprints/ChipCloudFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/categorybar/fingerprints/ChipCloudFingerprint.kt @@ -1,7 +1,7 @@ package app.revanced.patches.music.layout.categorybar.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.music.misc.resourceid.patch.SharedResourceIdPatch.Companion.chipCloudId +import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch.Companion.ChipCloud import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.Opcode @@ -13,6 +13,6 @@ object ChipCloudFingerprint : MethodFingerprint( Opcode.INVOKE_STATIC, Opcode.MOVE_RESULT_OBJECT ), - customFingerprint = { it, _ -> it.isWideLiteralExists(chipCloudId) } + customFingerprint = { it, _ -> it.isWideLiteralExists(ChipCloud) } ) 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 44570c0e5..74e7a99a1 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 @@ -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.patches.music.layout.categorybar.fingerprints.ChipCloudFingerprint -import app.revanced.patches.music.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch +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 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 2289e4b7d..257d69349 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 @@ -17,7 +17,7 @@ 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.layout.colormatchplayer.fingerprints.ColorMatchPlayerFingerprint -import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch +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.util.enum.CategoryType diff --git a/src/main/kotlin/app/revanced/patches/music/layout/compactdialog/fingerprints/DialogSolidFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/layout/compactdialog/fingerprints/DialogSolidFingerprint.kt index 189503304..b888e232c 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/compactdialog/fingerprints/DialogSolidFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/compactdialog/fingerprints/DialogSolidFingerprint.kt @@ -2,7 +2,7 @@ package app.revanced.patches.music.layout.compactdialog.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.music.misc.resourceid.patch.SharedResourceIdPatch.Companion.dialogSolidId +import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch.Companion.DialogSolid import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @@ -16,6 +16,6 @@ object DialogSolidFingerprint : MethodFingerprint( Opcode.MOVE_RESULT_OBJECT, Opcode.INVOKE_STATIC ), - customFingerprint = { it, _ -> it.isWideLiteralExists(dialogSolidId) } + customFingerprint = { it, _ -> it.isWideLiteralExists(DialogSolid) } ) 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 f93cda3f8..840bcf911 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 @@ -14,8 +14,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.patches.music.layout.compactdialog.fingerprints.DialogSolidFingerprint -import app.revanced.patches.music.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch +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 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 6dc9b34c1..989787fef 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 @@ -15,8 +15,8 @@ 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.layout.floatingbutton.fingerprints.* -import app.revanced.patches.music.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch +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 diff --git a/src/main/kotlin/app/revanced/patches/music/layout/landscapemode/fingerprints/TabletIdentifierFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/layout/landscapemode/fingerprints/TabletIdentifierFingerprint.kt index 6b28693a2..4b6f0cbdb 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/landscapemode/fingerprints/TabletIdentifierFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/landscapemode/fingerprints/TabletIdentifierFingerprint.kt @@ -2,7 +2,7 @@ package app.revanced.patches.music.layout.landscapemode.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.music.misc.resourceid.patch.SharedResourceIdPatch.Companion.isTabletId +import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch.Companion.IsTablet import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @@ -16,6 +16,6 @@ object TabletIdentifierFingerprint : MethodFingerprint( Opcode.INVOKE_VIRTUAL, Opcode.MOVE_RESULT ), - customFingerprint = { it, _ -> it.isWideLiteralExists(isTabletId) } + customFingerprint = { it, _ -> it.isWideLiteralExists(IsTablet) } ) 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 ebbe518be..4106242cd 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 @@ -12,8 +12,8 @@ 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.layout.landscapemode.fingerprints.TabletIdentifierFingerprint -import app.revanced.patches.music.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch +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 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 c8d1a92c5..08be9a18c 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 @@ -12,7 +12,7 @@ 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.layout.minimizedplayer.fingerprints.MinimizedPlayerFingerprint -import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch +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 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 3d7e0af52..b1fb5f70b 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 @@ -10,7 +10,7 @@ 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.misc.litho.patch.MusicLithoFilterPatch -import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch +import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.util.enum.CategoryType 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 8c622ab6e..f8e48477d 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 @@ -15,7 +15,7 @@ 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.layout.zenmode.fingerprints.ZenModeFingerprint -import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch +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.util.enum.CategoryType 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 b5df93a4e..09aeabb70 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 @@ -18,7 +18,7 @@ import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.music.misc.codecs.fingerprints.AllCodecsFingerprint import app.revanced.patches.music.misc.codecs.fingerprints.AllCodecsParentFingerprint import app.revanced.patches.music.misc.codecs.fingerprints.CodecsLockFingerprint -import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch +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_MISC_PATH diff --git a/src/main/kotlin/app/revanced/patches/music/misc/microg/bytecode/fingerprints/ServiceCheckFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/misc/microg/bytecode/fingerprints/ServiceCheckFingerprint.kt deleted file mode 100644 index 4cea72dd6..000000000 --- a/src/main/kotlin/app/revanced/patches/music/misc/microg/bytecode/fingerprints/ServiceCheckFingerprint.kt +++ /dev/null @@ -1,14 +0,0 @@ -package app.revanced.patches.music.misc.microg.bytecode.fingerprints - -import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import org.jf.dexlib2.AccessFlags - -@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. -object ServiceCheckFingerprint : MethodFingerprint( - "V", - AccessFlags.PUBLIC or AccessFlags.STATIC, - listOf("L", "I"), - strings = listOf("Google Play Services not available") -) diff --git a/src/main/kotlin/app/revanced/patches/music/misc/premium/fingerprints/AccountMenuFooterFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/misc/premium/fingerprints/AccountMenuFooterFingerprint.kt index ecec2e1e1..0bab15609 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/premium/fingerprints/AccountMenuFooterFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/premium/fingerprints/AccountMenuFooterFingerprint.kt @@ -2,7 +2,7 @@ package app.revanced.patches.music.misc.premium.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.music.misc.resourceid.patch.SharedResourceIdPatch.Companion.privacyTosFooterId +import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch.Companion.PrivacyTosFooter import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @@ -18,5 +18,5 @@ object AccountMenuFooterFingerprint : MethodFingerprint( Opcode.INVOKE_VIRTUAL, Opcode.IGET_OBJECT ), - customFingerprint = { it, _ -> it.isWideLiteralExists(privacyTosFooterId) } + customFingerprint = { it, _ -> it.isWideLiteralExists(PrivacyTosFooter) } ) 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 a16cb23ff..b2980867a 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 @@ -16,8 +16,8 @@ import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patches.music.misc.premium.fingerprints.AccountMenuFooterFingerprint import app.revanced.patches.music.misc.premium.fingerprints.HideGetPremiumFingerprint -import app.revanced.patches.music.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.music.misc.resourceid.patch.SharedResourceIdPatch.Companion.privacyTosFooterId +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 @@ -55,7 +55,7 @@ class HideGetPremiumPatch : BytecodePatch( AccountMenuFooterFingerprint.result?.let { it.mutableMethod.apply { - val targetIndex = getWideLiteralIndex(privacyTosFooterId) + 4 + val targetIndex = getWideLiteralIndex(PrivacyTosFooter) + 4 targetReference = getInstruction(targetIndex + 1).reference with (context diff --git a/src/main/kotlin/app/revanced/patches/music/misc/quality/fingerprints/MusicVideoQualitySetterFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/misc/quality/fingerprints/MusicVideoQualitySetterFingerprint.kt deleted file mode 100644 index 72bddf84d..000000000 --- a/src/main/kotlin/app/revanced/patches/music/misc/quality/fingerprints/MusicVideoQualitySetterFingerprint.kt +++ /dev/null @@ -1,13 +0,0 @@ -package app.revanced.patches.music.misc.quality.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import org.jf.dexlib2.Opcode - -object MusicVideoQualitySetterFingerprint : MethodFingerprint( - returnType = "V", - opcodes = listOf( - Opcode.CHECK_CAST, - Opcode.IPUT_OBJECT - ), - customFingerprint = { it, _ -> it.name == "" } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/music/misc/quality/fingerprints/MusicVideoQualitySetterParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/misc/quality/fingerprints/MusicVideoQualitySetterParentFingerprint.kt deleted file mode 100644 index 92532f662..000000000 --- a/src/main/kotlin/app/revanced/patches/music/misc/quality/fingerprints/MusicVideoQualitySetterParentFingerprint.kt +++ /dev/null @@ -1,11 +0,0 @@ -package app.revanced.patches.music.misc.quality.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.music.misc.resourceid.patch.SharedResourceIdPatch.Companion.qualityAutoId -import app.revanced.util.bytecode.isWideLiteralExists - -object MusicVideoQualitySetterParentFingerprint : MethodFingerprint( - returnType = "V", - parameters = listOf("L"), - customFingerprint = { it, _ -> it.isWideLiteralExists(qualityAutoId)} -) \ No newline at end of file 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 d52b4dceb..dd0a2a94c 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 @@ -1,11 +1,14 @@ package app.revanced.patches.music.misc.quality.fingerprints +import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.music.misc.resourceid.patch.SharedResourceIdPatch.Companion.qualityTitleId +import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch.Companion.QualityTitle import app.revanced.util.bytecode.isWideLiteralExists +import org.jf.dexlib2.AccessFlags object MusicVideoQualitySettingsParentFingerprint : MethodFingerprint( - returnType = "L", - parameters = listOf(), - customFingerprint = { it, _ -> it.isWideLiteralExists(qualityTitleId)} + returnType = "V", + accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, + parameters = listOf("L"), + 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 a2e8f8797..e50b76095 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,16 +15,20 @@ 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.misc.quality.fingerprints.* -import app.revanced.patches.music.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch -import app.revanced.patches.music.misc.videoid.patch.MusicVideoIdPatch +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 import org.jf.dexlib2.builder.instruction.BuilderInstruction21c import org.jf.dexlib2.iface.instruction.ReferenceInstruction -import org.jf.dexlib2.iface.reference.FieldReference +import org.jf.dexlib2.iface.instruction.formats.Instruction35c +import org.jf.dexlib2.iface.reference.MethodReference import org.jf.dexlib2.iface.reference.Reference @Patch @@ -41,27 +45,40 @@ import org.jf.dexlib2.iface.reference.Reference @Version("0.0.1") class VideoQualityPatch : BytecodePatch( listOf( - MusicVideoQualitySetterParentFingerprint, MusicVideoQualitySettingsParentFingerprint, UserQualityChangeFingerprint ) ) { override fun execute(context: BytecodeContext): PatchResult { - MusicVideoQualitySetterParentFingerprint.result?.let { parentResult -> - MusicVideoQualitySetterFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let { - it.mutableMethod.apply { - val endIndex = it.scanResult.patternScanResult!!.endIndex + UserQualityChangeFingerprint.result?.let { + it.mutableMethod.apply { + val endIndex = it.scanResult.patternScanResult!!.endIndex + val qualityChangedClass = + context.findClass((getInstruction(endIndex)) + .reference.toString())!! + .mutableClass - qualityReference = getInstruction(endIndex).reference - qualityFieldReference = qualityReference as FieldReference + for (method in qualityChangedClass.methods) { + qualityChangedClass.findMutableMethodOf(method).apply { + if (this.name == "onItemClick") { + for ((index, instruction) in implementation!!.instructions.withIndex()) { + if (instruction.opcode != Opcode.INVOKE_INTERFACE) continue - qIndexMethodName = context - .classes.single { classDef -> classDef.type == qualityFieldReference.type } - .methods.single { method -> method.parameterTypes.first() == "I" }.name + qualityReference = getInstruction(index - 1).reference + qIndexMethodName = ((getInstruction(index).reference) as MethodReference).name + + addInstruction( + 0, + "invoke-static {p3}, $INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR->userChangedQuality(I)V" + ) + break + } + } + } } - } ?: return MusicVideoQualitySetterFingerprint.toErrorResult() - } ?: return MusicVideoQualitySetterParentFingerprint.toErrorResult() + } + } ?: return UserQualityChangeFingerprint.toErrorResult() MusicVideoQualitySettingsParentFingerprint.result?.let { parentResult -> MusicVideoQualitySettingsFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.addInstructions( @@ -75,27 +92,6 @@ class VideoQualityPatch : BytecodePatch( ) ?: return MusicVideoQualitySettingsFingerprint.toErrorResult() } ?: return MusicVideoQualitySettingsParentFingerprint.toErrorResult() - UserQualityChangeFingerprint.result?.let { - it.mutableMethod.apply { - val endIndex = it.scanResult.patternScanResult!!.endIndex - val qualityChangedClass = - context.findClass((getInstruction(endIndex)) - .reference.toString())!! - .mutableClass - - for (method in qualityChangedClass.methods) { - with (qualityChangedClass.findMutableMethodOf(method)) { - if (this.name == "onItemClick") { - addInstruction( - 0, - "invoke-static {p3}, $INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR->userChangedQuality(I)V" - ) - } - } - } - } - } ?: return UserQualityChangeFingerprint.toErrorResult() - MusicVideoIdPatch.injectCall("$INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR->newVideoStarted(Ljava/lang/String;)V") MusicSettingsPatch.addMusicPreference(CategoryType.MISC, "revanced_enable_save_video_quality", "true") @@ -106,7 +102,6 @@ class VideoQualityPatch : BytecodePatch( "$MUSIC_MISC_PATH/MusicVideoQualityPatch;" private lateinit var qIndexMethodName: String - private lateinit var qualityFieldReference: FieldReference private lateinit var qualityReference: Reference } } diff --git a/src/main/kotlin/app/revanced/patches/music/misc/resourceid/patch/SharedResourceIdPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/resourceid/patch/SharedResourceIdPatch.kt deleted file mode 100644 index d864b579e..000000000 --- a/src/main/kotlin/app/revanced/patches/music/misc/resourceid/patch/SharedResourceIdPatch.kt +++ /dev/null @@ -1,50 +0,0 @@ -package app.revanced.patches.music.misc.resourceid.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.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.shared.patch.mapping.ResourceMappingPatch -import app.revanced.util.enum.ResourceType -import app.revanced.util.enum.ResourceType.* - -@Name("music-resource-id") -@DependsOn([ResourceMappingPatch::class]) -@YouTubeMusicCompatibility -@Version("0.0.1") -class SharedResourceIdPatch : ResourcePatch { - internal companion object { - var chipCloudId: Long = -1 - var colorGreyId: Long = -1 - var dialogSolidId: Long = -1 - var disabledIconId: Long = -1 - var isTabletId: Long = -1 - var notifierShelfId: Long = -1 - var privacyTosFooterId: Long = -1 - var qualityAutoId: Long = -1 - var qualityTitleId: Long = -1 - } - - override fun execute(context: ResourceContext): PatchResult { - - fun find(type: ResourceType, name: String) = ResourceMappingPatch - .resourceMappings - .single { it.type == type.value && it.name == name }.id - - chipCloudId = find(LAYOUT, "chip_cloud") - colorGreyId = find(COLOR, "ytm_color_grey_12") - dialogSolidId = find(STYLE, "Theme.YouTubeMusic.Dialog.Solid") - disabledIconId = find(DIMEN, "disabled_icon_alpha") - isTabletId = find(BOOL, "is_tablet") - notifierShelfId = find(LAYOUT, "music_notifier_shelf") - privacyTosFooterId = find(ID, "privacy_tos_footer") - qualityAutoId = find(STRING, "quality_auto") - qualityTitleId = find(STRING, "quality_title") - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/music/misc/sharebuttonhook/fingerprints/FullStackTraceActivityFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/misc/sharebuttonhook/fingerprints/FullStackTraceActivityFingerprint.kt index af5cf4ed6..e937db4b0 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/sharebuttonhook/fingerprints/FullStackTraceActivityFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/sharebuttonhook/fingerprints/FullStackTraceActivityFingerprint.kt @@ -3,7 +3,5 @@ package app.revanced.patches.music.misc.sharebuttonhook.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint object FullStackTraceActivityFingerprint : MethodFingerprint( - customFingerprint = { it, _ -> - it.definingClass.endsWith("FullStackTraceActivity;") && it.name == "onCreate" - } + customFingerprint = { it, _ -> it.definingClass.endsWith("FullStackTraceActivity;") && it.name == "onCreate" } ) 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 5f3a5edc0..5be31f4cc 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,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.smali.ExternalLabel -import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch +import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch +import app.revanced.patches.music.utils.videoid.patch.MusicVideoIdPatch import app.revanced.patches.music.misc.sharebuttonhook.fingerprints.* import app.revanced.patches.music.misc.sleeptimerhook.patch.SleepTimerHookPatch -import app.revanced.patches.music.misc.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 @@ -80,7 +80,6 @@ class ShareButtonHookPatch : BytecodePatch( ) ?: return FullStackTraceActivityFingerprint.toErrorResult() MusicSettingsPatch.addMusicPreference(CategoryType.MISC, "revanced_hook_share_button", "false") - MusicSettingsPatch.addMusicPreferenceAlt(CategoryType.MISC, "revanced_hook_type", "false", "revanced_hook_share_button") MusicSettingsPatch.addMusicPreferenceWithIntent(CategoryType.MISC, "revanced_default_downloader", "revanced_hook_share_button") return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/music/misc/shuffle/fingerprints/ShuffleClassFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/misc/shuffle/fingerprints/ShuffleClassFingerprint.kt index 02a253ffb..aa3f83961 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/shuffle/fingerprints/ShuffleClassFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/shuffle/fingerprints/ShuffleClassFingerprint.kt @@ -2,7 +2,7 @@ package app.revanced.patches.music.misc.shuffle.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.music.misc.resourceid.patch.SharedResourceIdPatch.Companion.disabledIconId +import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch.Companion.DisabledIconAlpha import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @@ -18,6 +18,6 @@ object ShuffleClassFingerprint : MethodFingerprint( Opcode.INVOKE_VIRTUAL, Opcode.RETURN_VOID ), - customFingerprint = { it, _ -> it.name == "" && it.isWideLiteralExists(disabledIconId) } + customFingerprint = { it, _ -> it.name == "" && it.isWideLiteralExists(DisabledIconAlpha) } ) 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 e517d15f4..cb55f6f29 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,8 +19,8 @@ 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.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch +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 @@ -156,7 +156,7 @@ class EnforceShufflePatch : BytecodePatch( iput-boolean v4, v3, $shuffleReference5 invoke-virtual {v3}, $shuffleReference6 return-void - """.toInstructions(), null, null + """.toInstructions(), null, null ) ).toMutable() ) 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 2d95015bf..23b3a0219 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,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.music.misc.settings.resource.patch.MusicSettingsPatch +import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.util.resources.ResourceHelper.addTranslations 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 d3f979062..01293342a 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 @@ -2,7 +2,7 @@ package app.revanced.patches.music.misc.upgradebutton.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.music.misc.resourceid.patch.SharedResourceIdPatch.Companion.notifierShelfId +import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch.Companion.MusicNotifierShelf import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @@ -16,6 +16,6 @@ object NotifierShelfFingerprint : MethodFingerprint( Opcode.INVOKE_STATIC, Opcode.MOVE_RESULT_OBJECT ), - customFingerprint = { it, _ -> it.isWideLiteralExists(notifierShelfId)} + 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 5f04605e1..ca647904c 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,10 +14,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.misc.integrations.patch.MusicIntegrationsPatch -import app.revanced.patches.music.misc.resourceid.patch.SharedResourceIdPatch -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 @@ -73,7 +72,7 @@ class RemoveUpgradeButtonPatch : BytecodePatch( val targetRegister = getInstruction(targetIndex).registerA addInstruction( targetIndex + 1, - "invoke-static {v$targetRegister}, $INTEGRATIONS_PATH/adremover/AdRemoverAPI;->HideViewWithLayout1dp(Landroid/view/View;)V" + "invoke-static {v$targetRegister}, Lapp/revanced/music/utils/ReVancedUtils;->hideViewByLayoutParams(Landroid/view/View;)V" ) } } ?: return NotifierShelfFingerprint.toErrorResult() 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 501a8ba4d..d627eaef7 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 @@ -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.music.misc.settings.resource.patch.MusicSettingsPatch +import app.revanced.patches.music.utils.settings.resource.patch.MusicSettingsPatch import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.patch.versionspoof.GeneralVersionSpoofPatch import app.revanced.util.enum.CategoryType diff --git a/src/main/kotlin/app/revanced/patches/music/misc/androidauto/fingerprints/CertificateCheckFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/utils/fix/androidauto/fingerprints/CertificateCheckFingerprint.kt similarity index 75% rename from src/main/kotlin/app/revanced/patches/music/misc/androidauto/fingerprints/CertificateCheckFingerprint.kt rename to src/main/kotlin/app/revanced/patches/music/utils/fix/androidauto/fingerprints/CertificateCheckFingerprint.kt index d0d23129d..d2300d74e 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/androidauto/fingerprints/CertificateCheckFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/fix/androidauto/fingerprints/CertificateCheckFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.music.misc.androidauto.fingerprints +package app.revanced.patches.music.utils.fix.androidauto.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/music/misc/androidauto/patch/AndroidAutoCertificatePatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/fix/androidauto/patch/AndroidAutoCertificatePatch.kt similarity index 88% rename from src/main/kotlin/app/revanced/patches/music/misc/androidauto/patch/AndroidAutoCertificatePatch.kt rename to src/main/kotlin/app/revanced/patches/music/utils/fix/androidauto/patch/AndroidAutoCertificatePatch.kt index ff4ef9b55..de407da7c 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/androidauto/patch/AndroidAutoCertificatePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/fix/androidauto/patch/AndroidAutoCertificatePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.music.misc.androidauto.patch +package app.revanced.patches.music.utils.fix.androidauto.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -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.Patch -import app.revanced.patches.music.misc.androidauto.fingerprints.CertificateCheckFingerprint +import app.revanced.patches.music.utils.fix.androidauto.fingerprints.CertificateCheckFingerprint import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility @Patch diff --git a/src/main/kotlin/app/revanced/patches/music/misc/clientspoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/utils/fix/clientspoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt similarity index 83% rename from src/main/kotlin/app/revanced/patches/music/misc/clientspoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt rename to src/main/kotlin/app/revanced/patches/music/utils/fix/clientspoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt index e899bb293..f3fcf823d 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/clientspoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/fix/clientspoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.music.misc.clientspoof.fingerprints +package app.revanced.patches.music.utils.fix.clientspoof.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/music/misc/clientspoof/patch/ClientSpoofMusicPatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/fix/clientspoof/patch/ClientSpoofMusicPatch.kt similarity index 86% rename from src/main/kotlin/app/revanced/patches/music/misc/clientspoof/patch/ClientSpoofMusicPatch.kt rename to src/main/kotlin/app/revanced/patches/music/utils/fix/clientspoof/patch/ClientSpoofMusicPatch.kt index f807ac4ee..3a243ace6 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/clientspoof/patch/ClientSpoofMusicPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/fix/clientspoof/patch/ClientSpoofMusicPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.music.misc.clientspoof.patch +package app.revanced.patches.music.utils.fix.clientspoof.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -10,8 +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.music.misc.clientspoof.fingerprints.UserAgentHeaderBuilderFingerprint -import app.revanced.patches.music.misc.microg.shared.Constants.MUSIC_PACKAGE_NAME +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 diff --git a/src/main/kotlin/app/revanced/patches/music/misc/integrations/fingerprints/InitFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/utils/integrations/fingerprints/InitFingerprint.kt similarity index 75% rename from src/main/kotlin/app/revanced/patches/music/misc/integrations/fingerprints/InitFingerprint.kt rename to src/main/kotlin/app/revanced/patches/music/utils/integrations/fingerprints/InitFingerprint.kt index ca9567029..9474bf9a6 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/integrations/fingerprints/InitFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/integrations/fingerprints/InitFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.music.misc.integrations.fingerprints +package app.revanced.patches.music.utils.integrations.fingerprints import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint diff --git a/src/main/kotlin/app/revanced/patches/music/misc/integrations/patch/MusicIntegrationsPatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/integrations/patch/MusicIntegrationsPatch.kt similarity index 79% rename from src/main/kotlin/app/revanced/patches/music/misc/integrations/patch/MusicIntegrationsPatch.kt rename to src/main/kotlin/app/revanced/patches/music/utils/integrations/patch/MusicIntegrationsPatch.kt index 1ca203f11..55f41be7d 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/integrations/patch/MusicIntegrationsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/integrations/patch/MusicIntegrationsPatch.kt @@ -1,8 +1,8 @@ -package app.revanced.patches.music.misc.integrations.patch +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.misc.integrations.fingerprints.InitFingerprint +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 diff --git a/src/main/kotlin/app/revanced/patches/music/misc/microg/bytecode/fingerprints/CastContextFetchFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/utils/microg/bytecode/fingerprints/CastContextFetchFingerprint.kt similarity index 72% rename from src/main/kotlin/app/revanced/patches/music/misc/microg/bytecode/fingerprints/CastContextFetchFingerprint.kt rename to src/main/kotlin/app/revanced/patches/music/utils/microg/bytecode/fingerprints/CastContextFetchFingerprint.kt index 3fdaec70c..e96357a78 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/microg/bytecode/fingerprints/CastContextFetchFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/microg/bytecode/fingerprints/CastContextFetchFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.music.misc.microg.bytecode.fingerprints +package app.revanced.patches.music.utils.microg.bytecode.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/music/misc/microg/bytecode/fingerprints/CastDynamiteModuleFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/utils/microg/bytecode/fingerprints/CastDynamiteModuleFingerprint.kt similarity index 76% rename from src/main/kotlin/app/revanced/patches/music/misc/microg/bytecode/fingerprints/CastDynamiteModuleFingerprint.kt rename to src/main/kotlin/app/revanced/patches/music/utils/microg/bytecode/fingerprints/CastDynamiteModuleFingerprint.kt index 5dff4dd5f..1de319b72 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/microg/bytecode/fingerprints/CastDynamiteModuleFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/microg/bytecode/fingerprints/CastDynamiteModuleFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.music.misc.microg.bytecode.fingerprints +package app.revanced.patches.music.utils.microg.bytecode.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/music/misc/microg/bytecode/fingerprints/CastDynamiteModuleV2Fingerprint.kt b/src/main/kotlin/app/revanced/patches/music/utils/microg/bytecode/fingerprints/CastDynamiteModuleV2Fingerprint.kt similarity index 72% rename from src/main/kotlin/app/revanced/patches/music/misc/microg/bytecode/fingerprints/CastDynamiteModuleV2Fingerprint.kt rename to src/main/kotlin/app/revanced/patches/music/utils/microg/bytecode/fingerprints/CastDynamiteModuleV2Fingerprint.kt index 686e0fd7e..30784810c 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/microg/bytecode/fingerprints/CastDynamiteModuleV2Fingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/microg/bytecode/fingerprints/CastDynamiteModuleV2Fingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.music.misc.microg.bytecode.fingerprints +package app.revanced.patches.music.utils.microg.bytecode.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/music/misc/microg/bytecode/fingerprints/GooglePlayUtilityFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/utils/microg/bytecode/fingerprints/GooglePlayUtilityFingerprint.kt similarity index 68% rename from src/main/kotlin/app/revanced/patches/music/misc/microg/bytecode/fingerprints/GooglePlayUtilityFingerprint.kt rename to src/main/kotlin/app/revanced/patches/music/utils/microg/bytecode/fingerprints/GooglePlayUtilityFingerprint.kt index dc1fe1631..249013333 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/microg/bytecode/fingerprints/GooglePlayUtilityFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/microg/bytecode/fingerprints/GooglePlayUtilityFingerprint.kt @@ -1,13 +1,13 @@ -package app.revanced.patches.music.misc.microg.bytecode.fingerprints +package app.revanced.patches.music.utils.microg.bytecode.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.AccessFlags object GooglePlayUtilityFingerprint : MethodFingerprint( - "I", - AccessFlags.PUBLIC or AccessFlags.STATIC, - listOf("L", "I"), + returnType = "I", + accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC, + parameters = listOf("L", "I"), strings = listOf( "This should never happen.", "MetadataValueReader", diff --git a/src/main/kotlin/app/revanced/patches/music/misc/microg/bytecode/fingerprints/PrimeFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/utils/microg/bytecode/fingerprints/PrimeFingerprint.kt similarity index 73% rename from src/main/kotlin/app/revanced/patches/music/misc/microg/bytecode/fingerprints/PrimeFingerprint.kt rename to src/main/kotlin/app/revanced/patches/music/utils/microg/bytecode/fingerprints/PrimeFingerprint.kt index cc4719d46..c295a7786 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/microg/bytecode/fingerprints/PrimeFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/microg/bytecode/fingerprints/PrimeFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.music.misc.microg.bytecode.fingerprints +package app.revanced.patches.music.utils.microg.bytecode.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/music/utils/microg/bytecode/fingerprints/ServiceCheckFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/utils/microg/bytecode/fingerprints/ServiceCheckFingerprint.kt new file mode 100644 index 000000000..e1ff7b1e7 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/music/utils/microg/bytecode/fingerprints/ServiceCheckFingerprint.kt @@ -0,0 +1,12 @@ +package app.revanced.patches.music.utils.microg.bytecode.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags + +object ServiceCheckFingerprint : MethodFingerprint( + returnType = "V", + accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC, + parameters = listOf("L", "I"), + strings = listOf("Google Play Services not available") +) diff --git a/src/main/kotlin/app/revanced/patches/music/misc/microg/bytecode/patch/MusicMicroGBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/microg/bytecode/patch/MusicMicroGBytecodePatch.kt similarity index 75% rename from src/main/kotlin/app/revanced/patches/music/misc/microg/bytecode/patch/MusicMicroGBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/music/utils/microg/bytecode/patch/MusicMicroGBytecodePatch.kt index 0293eb96b..a9d45ad9d 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/microg/bytecode/patch/MusicMicroGBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/microg/bytecode/patch/MusicMicroGBytecodePatch.kt @@ -9,11 +9,16 @@ 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.misc.clientspoof.patch.ClientSpoofMusicPatch -import app.revanced.patches.music.misc.microg.bytecode.fingerprints.* -import app.revanced.patches.music.misc.microg.resource.patch.MusicMicroGResourcePatch -import app.revanced.patches.music.misc.microg.shared.Constants.MUSIC_PACKAGE_NAME -import app.revanced.patches.music.misc.microg.shared.Constants.YOUTUBE_PACKAGE_NAME +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.shared.patch.packagename.PackageNamePatch import app.revanced.util.microg.MicroGBytecodeHelper diff --git a/src/main/kotlin/app/revanced/patches/music/misc/microg/resource/patch/MusicMicroGResourcePatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/microg/resource/patch/MusicMicroGResourcePatch.kt similarity index 82% rename from src/main/kotlin/app/revanced/patches/music/misc/microg/resource/patch/MusicMicroGResourcePatch.kt rename to src/main/kotlin/app/revanced/patches/music/utils/microg/resource/patch/MusicMicroGResourcePatch.kt index 8e21f329c..fae7059ed 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/microg/resource/patch/MusicMicroGResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/microg/resource/patch/MusicMicroGResourcePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.music.misc.microg.resource.patch +package app.revanced.patches.music.utils.microg.resource.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -8,9 +8,9 @@ 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.misc.microg.shared.Constants.MUSIC_PACKAGE_NAME -import app.revanced.patches.music.misc.microg.shared.Constants.SPOOFED_PACKAGE_NAME -import app.revanced.patches.music.misc.microg.shared.Constants.SPOOFED_PACKAGE_SIGNATURE +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 diff --git a/src/main/kotlin/app/revanced/patches/music/misc/microg/shared/Constants.kt b/src/main/kotlin/app/revanced/patches/music/utils/microg/shared/Constants.kt similarity index 86% rename from src/main/kotlin/app/revanced/patches/music/misc/microg/shared/Constants.kt rename to src/main/kotlin/app/revanced/patches/music/utils/microg/shared/Constants.kt index 35d8cd35a..e4026ad12 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/microg/shared/Constants.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/microg/shared/Constants.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.music.misc.microg.shared +package app.revanced.patches.music.utils.microg.shared object Constants { internal const val YOUTUBE_PACKAGE_NAME = "com.google.android.youtube" 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 new file mode 100644 index 000000000..7f9ad1677 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/music/utils/resourceid/patch/SharedResourceIdPatch.kt @@ -0,0 +1,52 @@ +package app.revanced.patches.music.utils.resourceid.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.patcher.patch.annotations.DependsOn +import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility +import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch +import app.revanced.util.enum.ResourceType +import app.revanced.util.enum.ResourceType.* + +@Name("music-resource-id") +@DependsOn([ResourceMappingPatch::class]) +@YouTubeMusicCompatibility +@Version("0.0.1") +class SharedResourceIdPatch : ResourcePatch { + internal companion object { + var ChipCloud: Long = -1 + var ColorGrey: Long = -1 + var DialogSolid: Long = -1 + var DisabledIconAlpha: Long = -1 + var IsTablet: Long = -1 + var MusicNotifierShelf: Long = -1 + var PrivacyTosFooter: Long = -1 + var QualityTitle: Long = -1 + var Text1: Long = -1 + } + + override fun execute(context: ResourceContext): PatchResult { + + fun find(resourceType: ResourceType, resourceName: String) = ResourceMappingPatch + .resourceMappings + .find { it.type == resourceType.value && it.name == resourceName }?.id + ?: throw PatchResultError("Failed to find resource id : $resourceName") + + ChipCloud = find(LAYOUT, "chip_cloud") + ColorGrey = find(COLOR, "ytm_color_grey_12") + DialogSolid = find(STYLE, "Theme.YouTubeMusic.Dialog.Solid") + DisabledIconAlpha = find(DIMEN, "disabled_icon_alpha") + IsTablet = find(BOOL, "is_tablet") + MusicNotifierShelf = find(LAYOUT, "music_notifier_shelf") + PrivacyTosFooter = find(ID, "privacy_tos_footer") + QualityTitle = find(STRING, "quality_title") + Text1 = find(ID, "text1") + + return PatchResultSuccess() + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/music/misc/settings/bytecode/fingerprints/PreferenceFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/utils/settings/bytecode/fingerprints/PreferenceFingerprint.kt similarity index 89% rename from src/main/kotlin/app/revanced/patches/music/misc/settings/bytecode/fingerprints/PreferenceFingerprint.kt rename to src/main/kotlin/app/revanced/patches/music/utils/settings/bytecode/fingerprints/PreferenceFingerprint.kt index 0dc218ab8..2e504dbf5 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/settings/bytecode/fingerprints/PreferenceFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/settings/bytecode/fingerprints/PreferenceFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.music.misc.settings.bytecode.fingerprints +package app.revanced.patches.music.utils.settings.bytecode.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/music/misc/settings/bytecode/fingerprints/SettingsHeadersFragmentFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/utils/settings/bytecode/fingerprints/SettingsHeadersFragmentFingerprint.kt similarity index 86% rename from src/main/kotlin/app/revanced/patches/music/misc/settings/bytecode/fingerprints/SettingsHeadersFragmentFingerprint.kt rename to src/main/kotlin/app/revanced/patches/music/utils/settings/bytecode/fingerprints/SettingsHeadersFragmentFingerprint.kt index 9db4b12e5..838117251 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/settings/bytecode/fingerprints/SettingsHeadersFragmentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/settings/bytecode/fingerprints/SettingsHeadersFragmentFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.music.misc.settings.bytecode.fingerprints +package app.revanced.patches.music.utils.settings.bytecode.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/music/misc/settings/bytecode/patch/MusicSettingsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/settings/bytecode/patch/MusicSettingsBytecodePatch.kt similarity index 88% rename from src/main/kotlin/app/revanced/patches/music/misc/settings/bytecode/patch/MusicSettingsBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/music/utils/settings/bytecode/patch/MusicSettingsBytecodePatch.kt index 041d50990..ac795bf92 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/settings/bytecode/patch/MusicSettingsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/settings/bytecode/patch/MusicSettingsBytecodePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.music.misc.settings.bytecode.patch +package app.revanced.patches.music.utils.settings.bytecode.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Name @@ -10,8 +10,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.music.misc.integrations.patch.MusicIntegrationsPatch -import app.revanced.patches.music.misc.settings.bytecode.fingerprints.* +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 diff --git a/src/main/kotlin/app/revanced/patches/music/misc/settings/resource/patch/MusicSettingsPatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/settings/resource/patch/MusicSettingsPatch.kt similarity index 86% rename from src/main/kotlin/app/revanced/patches/music/misc/settings/resource/patch/MusicSettingsPatch.kt rename to src/main/kotlin/app/revanced/patches/music/utils/settings/resource/patch/MusicSettingsPatch.kt index 7c402ebe7..76e1cfdf4 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/settings/resource/patch/MusicSettingsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/settings/resource/patch/MusicSettingsPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.music.misc.settings.resource.patch +package app.revanced.patches.music.utils.settings.resource.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -8,7 +8,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.music.misc.settings.bytecode.patch.MusicSettingsBytecodePatch +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 @@ -16,7 +16,6 @@ import app.revanced.util.resources.IconHelper import app.revanced.util.resources.IconHelper.copyFiles import app.revanced.util.resources.IconHelper.makeDirectoryAndCopyFiles import app.revanced.util.resources.MusicResourceHelper.addMusicPreference -import app.revanced.util.resources.MusicResourceHelper.addMusicPreferenceAlt import app.revanced.util.resources.MusicResourceHelper.addMusicPreferenceCategory import app.revanced.util.resources.MusicResourceHelper.addMusicPreferenceWithIntent import app.revanced.util.resources.MusicResourceHelper.addReVancedMusicPreference @@ -103,19 +102,6 @@ class MusicSettingsPatch : AbstractSettingsResourcePatch( contexts.sortMusicPreferenceCategory(categoryValue) } - internal fun addMusicPreferenceAlt( - category: CategoryType, - key: String, - defaultValue: String, - dependencyKey: String - - ) { - val categoryValue = category.value - contexts.addMusicPreferenceCategory(categoryValue) - contexts.addMusicPreferenceAlt(categoryValue, key, defaultValue, dependencyKey) - contexts.sortMusicPreferenceCategory(categoryValue) - } - internal fun addMusicPreferenceWithIntent( category: CategoryType, key: String, diff --git a/src/main/kotlin/app/revanced/patches/music/misc/videoid/fingerprint/MusicVideoIdFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/utils/videoid/fingerprint/MusicVideoIdFingerprint.kt similarity index 89% rename from src/main/kotlin/app/revanced/patches/music/misc/videoid/fingerprint/MusicVideoIdFingerprint.kt rename to src/main/kotlin/app/revanced/patches/music/utils/videoid/fingerprint/MusicVideoIdFingerprint.kt index d0727fc03..2ffe48cba 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/videoid/fingerprint/MusicVideoIdFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/videoid/fingerprint/MusicVideoIdFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.music.misc.videoid.fingerprint +package app.revanced.patches.music.utils.videoid.fingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/music/misc/videoid/patch/MusicVideoIdPatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/videoid/patch/MusicVideoIdPatch.kt similarity index 92% rename from src/main/kotlin/app/revanced/patches/music/misc/videoid/patch/MusicVideoIdPatch.kt rename to src/main/kotlin/app/revanced/patches/music/utils/videoid/patch/MusicVideoIdPatch.kt index dd83fe4e8..56154314c 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/videoid/patch/MusicVideoIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/videoid/patch/MusicVideoIdPatch.kt @@ -1,17 +1,17 @@ -package app.revanced.patches.music.misc.videoid.patch +package app.revanced.patches.music.utils.videoid.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions 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.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.music.misc.videoid.fingerprint.MusicVideoIdFingerprint +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 @@ -55,7 +55,7 @@ class MusicVideoIdPatch : BytecodePatch( fun injectCall( methodDescriptor: String ) { - insertMethod.addInstruction( + insertMethod.addInstructions( insertIndex + offset, // move-result-object offset "invoke-static {v$videoIdRegister}, $methodDescriptor" ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/oldlayout/fingerprints/SlimMetadataButtonViewFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/fingerprints/EmptyComponentBuilderFingerprint.kt similarity index 53% rename from src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/oldlayout/fingerprints/SlimMetadataButtonViewFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/fingerprints/EmptyComponentBuilderFingerprint.kt index 03c7aeef1..e4467ce53 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/oldlayout/fingerprints/SlimMetadataButtonViewFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/fingerprints/EmptyComponentBuilderFingerprint.kt @@ -1,16 +1,16 @@ -package app.revanced.patches.youtube.misc.returnyoutubedislike.oldlayout.fingerprints +package app.revanced.patches.shared.fingerprints 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 SlimMetadataButtonViewFingerprint : MethodFingerprint( +object EmptyComponentBuilderFingerprint : MethodFingerprint( returnType = "L", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, - parameters = listOf(), opcodes = listOf( - Opcode.IGET_OBJECT, - Opcode.RETURN_OBJECT - ) + Opcode.NEW_INSTANCE, + Opcode.INVOKE_DIRECT + ), + strings = listOf("Failed to convert Element to Flatbuffers: %s") ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/OnBackPressedFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/fingerprints/OnBackPressedFingerprint.kt new file mode 100644 index 000000000..baecd1898 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/shared/fingerprints/OnBackPressedFingerprint.kt @@ -0,0 +1,9 @@ +package app.revanced.patches.shared.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.Opcode + +object OnBackPressedFingerprint : MethodFingerprint( + opcodes = listOf(Opcode.RETURN_VOID), + customFingerprint = { it, _ -> it.definingClass.endsWith("WatchWhileActivity;") && it.name == "onBackPressed" } +) diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/PivotBarCreateButtonViewFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/fingerprints/PivotBarCreateButtonViewFingerprint.kt index 0e2a58451..2450e9372 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/PivotBarCreateButtonViewFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/fingerprints/PivotBarCreateButtonViewFingerprint.kt @@ -2,7 +2,7 @@ package app.revanced.patches.shared.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.imageOnlyTabId +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.ImageOnlyTab import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @@ -14,5 +14,5 @@ object PivotBarCreateButtonViewFingerprint : MethodFingerprint( Opcode.MOVE_OBJECT, Opcode.INVOKE_DIRECT_RANGE, // unique instruction anchor ), - customFingerprint = { it, _ -> it.isWideLiteralExists(imageOnlyTabId) } + customFingerprint = { it, _ -> it.isWideLiteralExists(ImageOnlyTab) } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/SeekbarFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/fingerprints/SeekbarFingerprint.kt new file mode 100644 index 000000000..7fd78d7e7 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/shared/fingerprints/SeekbarFingerprint.kt @@ -0,0 +1,8 @@ +package app.revanced.patches.shared.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +object SeekbarFingerprint : MethodFingerprint( + returnType = "V", + strings = listOf("timed_markers_width") +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/SeekbarOnDrawFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/fingerprints/SeekbarOnDrawFingerprint.kt new file mode 100644 index 000000000..171dfd45f --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/shared/fingerprints/SeekbarOnDrawFingerprint.kt @@ -0,0 +1,7 @@ +package app.revanced.patches.shared.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +object SeekbarOnDrawFingerprint : MethodFingerprint( + customFingerprint = { methodDef, _ -> methodDef.name == "onDraw" } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/TotalTimeFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/fingerprints/TotalTimeFingerprint.kt index d2ada638f..c003fcc64 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/TotalTimeFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/fingerprints/TotalTimeFingerprint.kt @@ -1,10 +1,10 @@ package app.revanced.patches.shared.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.totalTimeId +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.TotalTime import app.revanced.util.bytecode.isWideLiteralExists object TotalTimeFingerprint : MethodFingerprint( returnType = "V", - customFingerprint = { it, _ -> it.isWideLiteralExists(totalTimeId) } + customFingerprint = { it, _ -> it.isWideLiteralExists(TotalTime) } ) \ No newline at end of file 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 5f61f631e..978d400ea 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 @@ -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.youtube.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.adAttributionId +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.AdAttribution import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus import app.revanced.util.bytecode.getWideLiteralIndex import app.revanced.util.bytecode.isWideLiteralExists @@ -25,14 +25,14 @@ class GeneralAdsBytecodePatch : BytecodePatch() { override fun execute(context: BytecodeContext): PatchResult { context.classes.forEach { classDef -> classDef.methods.forEach { method -> - if (!method.isWideLiteralExists(adAttributionId)) + if (!method.isWideLiteralExists(AdAttribution)) return@forEach context.proxy(classDef) .mutableClass .findMutableMethodOf(method) .apply { - val insertIndex = method.getWideLiteralIndex(adAttributionId) + 1 + val insertIndex = method.getWideLiteralIndex(AdAttribution) + 1 if (getInstruction(insertIndex).opcode != org.jf.dexlib2.Opcode.INVOKE_VIRTUAL) return@forEach 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 121483b42..3033aba2b 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 @@ -15,8 +15,7 @@ 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.misc.litho.patch.ByteBufferFilterPatch -import app.revanced.patches.youtube.misc.litho.patch.LithoFilterPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import org.w3c.dom.Element @Patch 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 d87a6db03..e5a793026 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 @@ -11,7 +11,7 @@ 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.GeneralVideoAdsPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.ADS_PATH @Patch @@ -31,7 +31,7 @@ class VideoAdsPatch : BytecodePatch() { GeneralVideoAdsPatch.injectLegacyAds(INTEGRATIONS_CLASS_DESCRIPTOR) GeneralVideoAdsPatch.injectMainstreamAds(INTEGRATIONS_CLASS_DESCRIPTOR) - /* + /** * Add settings */ diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttomplayer/buttoncontainer/patch/ButtonContainerPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/buttomplayer/buttoncontainer/patch/ButtonContainerPatch.kt similarity index 89% rename from src/main/kotlin/app/revanced/patches/youtube/layout/buttomplayer/buttoncontainer/patch/ButtonContainerPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/buttomplayer/buttoncontainer/patch/ButtonContainerPatch.kt index 5a9e61fa5..045b38780 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttomplayer/buttoncontainer/patch/ButtonContainerPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/buttomplayer/buttoncontainer/patch/ButtonContainerPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.buttomplayer.buttoncontainer.patch +package app.revanced.patches.youtube.buttomplayer.buttoncontainer.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -11,7 +11,7 @@ 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.litho.patch.ByteBufferFilterPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.BOTTOM_PLAYER @Patch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttomplayer/comment/patch/CommentComponentPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/buttomplayer/comment/patch/CommentComponentPatch.kt similarity index 90% rename from src/main/kotlin/app/revanced/patches/youtube/layout/buttomplayer/comment/patch/CommentComponentPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/buttomplayer/comment/patch/CommentComponentPatch.kt index 6c83c074a..467a5ebeb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttomplayer/comment/patch/CommentComponentPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/buttomplayer/comment/patch/CommentComponentPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.buttomplayer.comment.patch +package app.revanced.patches.youtube.buttomplayer.comment.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -11,7 +11,7 @@ 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.misc.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch @Patch @Name("hide-comment-component") diff --git a/src/main/kotlin/app/revanced/patches/youtube/button/overlaybuttons/bytecode/patch/OverlayButtonsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/button/overlaybuttons/bytecode/patch/OverlayButtonsBytecodePatch.kt deleted file mode 100644 index 3fbc6365d..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/button/overlaybuttons/bytecode/patch/OverlayButtonsBytecodePatch.kt +++ /dev/null @@ -1,40 +0,0 @@ -package app.revanced.patches.youtube.button.overlaybuttons.bytecode.patch - -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.BytecodeContext -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.misc.playercontrols.patch.PlayerControlsPatch -import app.revanced.patches.youtube.misc.videoid.legacy.patch.LegacyVideoIdPatch -import app.revanced.util.integrations.Constants.BUTTON_PATH - -@Name("overlay-buttons-bytecode-patch") -@DependsOn( - dependencies = [ - PlayerControlsPatch::class, - LegacyVideoIdPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class OverlayButtonsBytecodePatch : BytecodePatch() { - override fun execute(context: BytecodeContext): PatchResult { - - arrayOf( - "Download", - "AutoRepeat", - "CopyWithTimeStamp", - "Copy", - "Speed" - ).forEach { - PlayerControlsPatch.initializeControl("$BUTTON_PATH/$it;") - PlayerControlsPatch.injectVisibility("$BUTTON_PATH/$it;") - } - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/flyoutpanel/flyoutpanel/patch/FlyoutPanelPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/flyoutpanel/patch/FlyoutPanelPatch.kt similarity index 89% rename from src/main/kotlin/app/revanced/patches/youtube/layout/flyoutpanel/flyoutpanel/patch/FlyoutPanelPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/flyoutpanel/patch/FlyoutPanelPatch.kt index ae19f710e..9014dee31 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/flyoutpanel/flyoutpanel/patch/FlyoutPanelPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/flyoutpanel/patch/FlyoutPanelPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.flyoutpanel.flyoutpanel.patch +package app.revanced.patches.youtube.flyoutpanel.flyoutpanel.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -11,7 +11,7 @@ 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.misc.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch @Patch @Name("hide-flyout-panel") diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/flyoutpanel/oldqualitylayout/fingerprints/QualityMenuViewInflateFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/oldqualitylayout/fingerprints/QualityMenuViewInflateFingerprint.kt similarity index 69% rename from src/main/kotlin/app/revanced/patches/youtube/layout/flyoutpanel/oldqualitylayout/fingerprints/QualityMenuViewInflateFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/oldqualitylayout/fingerprints/QualityMenuViewInflateFingerprint.kt index 9fc99a107..ae0d66d6b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/flyoutpanel/oldqualitylayout/fingerprints/QualityMenuViewInflateFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/oldqualitylayout/fingerprints/QualityMenuViewInflateFingerprint.kt @@ -1,7 +1,7 @@ -package app.revanced.patches.youtube.layout.flyoutpanel.oldqualitylayout.fingerprints +package app.revanced.patches.youtube.flyoutpanel.oldqualitylayout.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.videoQualityFragmentId +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.VideoQualityBottomSheet import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.Opcode @@ -22,5 +22,5 @@ object QualityMenuViewInflateFingerprint : MethodFingerprint( Opcode.MOVE_RESULT_OBJECT, Opcode.CHECK_CAST ), - customFingerprint = { it, _ -> it.isWideLiteralExists(videoQualityFragmentId) } + customFingerprint = { it, _ -> it.isWideLiteralExists(VideoQualityBottomSheet) } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/flyoutpanel/oldqualitylayout/patch/OldQualityLayoutPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/oldqualitylayout/patch/OldQualityLayoutPatch.kt similarity index 83% rename from src/main/kotlin/app/revanced/patches/youtube/layout/flyoutpanel/oldqualitylayout/patch/OldQualityLayoutPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/oldqualitylayout/patch/OldQualityLayoutPatch.kt index da07d9d81..9707b279e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/flyoutpanel/oldqualitylayout/patch/OldQualityLayoutPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/oldqualitylayout/patch/OldQualityLayoutPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.flyoutpanel.oldqualitylayout.patch +package app.revanced.patches.youtube.flyoutpanel.oldqualitylayout.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -13,9 +13,9 @@ 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.layout.flyoutpanel.oldqualitylayout.fingerprints.QualityMenuViewInflateFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 import app.revanced.util.integrations.Constants.FLYOUT_PANEL import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @@ -31,9 +31,7 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @YouTubeCompatibility @Version("0.0.1") class OldQualityLayoutPatch : BytecodePatch( - listOf( - QualityMenuViewInflateFingerprint - ) + listOf(QualityMenuViewInflateFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/autoplaypreview/patch/HideAutoplayPreviewPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/autoplaypreview/patch/HideAutoplayPreviewPatch.kt similarity index 58% rename from src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/autoplaypreview/patch/HideAutoplayPreviewPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/fullscreen/autoplaypreview/patch/HideAutoplayPreviewPatch.kt index ed70fb846..f2be5b5a1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/autoplaypreview/patch/HideAutoplayPreviewPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/autoplaypreview/patch/HideAutoplayPreviewPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.fullscreen.autoplaypreview.patch +package app.revanced.patches.youtube.fullscreen.autoplaypreview.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -15,9 +15,9 @@ 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.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.autoNavPreviewId -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 import app.revanced.util.bytecode.getStringIndex import app.revanced.util.bytecode.getWideLiteralIndex import app.revanced.util.integrations.Constants.FULLSCREEN @@ -41,25 +41,27 @@ class HideAutoplayPreviewPatch : BytecodePatch( listOf(LayoutConstructorFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { - LayoutConstructorFingerprint.result?.mutableMethod?.let { - val insertInstruction = it.implementation!!.instructions + LayoutConstructorFingerprint.result?.let { + it.mutableMethod.apply { + val insertInstruction = implementation!!.instructions - val dummyRegister = it.getInstruction(it.getStringIndex("1.0x")).registerA - val insertIndex = it.getWideLiteralIndex(autoNavPreviewId) + 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 = it.getInstruction(insertIndex + branchIndex) + val jumpInstruction = getInstruction(insertIndex + branchIndex) - it.addInstructionsWithLabels( - insertIndex, """ - invoke-static {}, $FULLSCREEN->hideAutoPlayPreview()Z - move-result v$dummyRegister - if-nez v$dummyRegister, :hidden - """, ExternalLabel("hidden", jumpInstruction) - ) + addInstructionsWithLabels( + insertIndex, """ + invoke-static {}, $FULLSCREEN->hideAutoPlayPreview()Z + move-result v$dummyRegister + if-nez v$dummyRegister, :hidden + """, ExternalLabel("hidden", jumpInstruction) + ) + } } ?: return LayoutConstructorFingerprint.toErrorResult() /** diff --git a/src/main/kotlin/app/revanced/patches/youtube/fullscreen/endscreenoverlay/fingerprints/EndScreenResultsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/endscreenoverlay/fingerprints/EndScreenResultsFingerprint.kt new file mode 100644 index 000000000..ea56527ab --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/endscreenoverlay/fingerprints/EndScreenResultsFingerprint.kt @@ -0,0 +1,10 @@ +package app.revanced.patches.youtube.fullscreen.endscreenoverlay.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.AppRelatedEndScreenResults +import app.revanced.util.bytecode.isWideLiteralExists + +object EndScreenResultsFingerprint : MethodFingerprint( + returnType = "V", + customFingerprint = { it, _ -> it.isWideLiteralExists(AppRelatedEndScreenResults) } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/endscreenoverlay/patch/HideEndScreenOverlayPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/endscreenoverlay/patch/HideEndScreenOverlayPatch.kt similarity index 67% rename from src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/endscreenoverlay/patch/HideEndScreenOverlayPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/fullscreen/endscreenoverlay/patch/HideEndScreenOverlayPatch.kt index ca745579f..f3a67338f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/endscreenoverlay/patch/HideEndScreenOverlayPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/endscreenoverlay/patch/HideEndScreenOverlayPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.fullscreen.endscreenoverlay.patch +package app.revanced.patches.youtube.fullscreen.endscreenoverlay.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -14,9 +14,9 @@ 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.layout.fullscreen.endscreenoverlay.fingerprints.EndScreenResultsFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 import app.revanced.util.integrations.Constants.FULLSCREEN @Patch @@ -34,15 +34,17 @@ class HideEndScreenOverlayPatch : BytecodePatch( listOf(EndScreenResultsFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { - EndScreenResultsFingerprint.result?.mutableMethod?.let { - it.addInstructionsWithLabels( - 0, """ - invoke-static {}, $FULLSCREEN->hideEndScreenOverlay()Z - move-result v0 - if-eqz v0, :show - return-void - """, ExternalLabel("show", it.getInstruction(0)) - ) + EndScreenResultsFingerprint.result?.let { + it.mutableMethod.apply { + addInstructionsWithLabels( + 0, """ + invoke-static {}, $FULLSCREEN->hideEndScreenOverlay()Z + move-result v0 + if-eqz v0, :show + return-void + """, ExternalLabel("show", getInstruction(0)) + ) + } } ?: return EndScreenResultsFingerprint.toErrorResult() /** 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 new file mode 100644 index 000000000..48713e69b --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/fullscreenpanels/fingerprints/FullscreenEngagementPanelFingerprint.kt @@ -0,0 +1,10 @@ +package app.revanced.patches.youtube.fullscreen.fullscreenpanels.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.FullScreenEngagementPanel +import app.revanced.util.bytecode.isWideLiteralExists + +object FullscreenEngagementPanelFingerprint : MethodFingerprint( + returnType = "L", + 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/layout/fullscreen/fullscreenpanels/fingerprints/FullscreenViewAdderFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/fullscreenpanels/fingerprints/FullscreenViewAdderFingerprint.kt similarity index 84% rename from src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/fullscreenpanels/fingerprints/FullscreenViewAdderFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/fullscreen/fullscreenpanels/fingerprints/FullscreenViewAdderFingerprint.kt index d5457245b..48556b507 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/fullscreenpanels/fingerprints/FullscreenViewAdderFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/fullscreenpanels/fingerprints/FullscreenViewAdderFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.fullscreen.fullscreenpanels.fingerprints +package app.revanced.patches.youtube.fullscreen.fullscreenpanels.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/fullscreenpanels/patch/HideFullscreenPanelsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/fullscreenpanels/patch/HideFullscreenPanelsPatch.kt similarity index 52% rename from src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/fullscreenpanels/patch/HideFullscreenPanelsPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/fullscreen/fullscreenpanels/patch/HideFullscreenPanelsPatch.kt index 7d9246d79..d62ecc42a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/fullscreenpanels/patch/HideFullscreenPanelsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/fullscreenpanels/patch/HideFullscreenPanelsPatch.kt @@ -1,10 +1,11 @@ -package app.revanced.patches.youtube.layout.fullscreen.fullscreenpanels.patch +package app.revanced.patches.youtube.fullscreen.fullscreenpanels.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.getInstruction @@ -17,10 +18,14 @@ 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.layout.fullscreen.fullscreenpanels.fingerprints.FullscreenViewAdderFingerprint -import app.revanced.patches.youtube.layout.fullscreen.quickactions.patch.QuickActionsPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.FullScreenEngagementPanel +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.bytecode.getStringIndex +import app.revanced.util.bytecode.getWideLiteralIndex import app.revanced.util.integrations.Constants.FULLSCREEN import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @@ -32,19 +37,34 @@ import org.jf.dexlib2.iface.instruction.formats.Instruction35c @Description("Hides video description and comments panel in fullscreen view.") @DependsOn( [ - QuickActionsPatch::class, - SettingsPatch::class + HideQuickActionsContainerPatch::class, + SettingsPatch::class, + SharedResourceIdPatch::class ] ) @YouTubeCompatibility @Version("0.0.1") class HideFullscreenPanelsPatch : BytecodePatch( listOf( + FullscreenEngagementPanelFingerprint, FullscreenViewAdderFingerprint, LayoutConstructorFingerprint ) ) { override fun execute(context: BytecodeContext): PatchResult { + + FullscreenEngagementPanelFingerprint.result?.let { + it.mutableMethod.apply { + val targetIndex = getWideLiteralIndex(FullScreenEngagementPanel) + 3 + val targetRegister = getInstruction(targetIndex).registerA + + addInstruction( + targetIndex + 1, + "invoke-static {v$targetRegister}, $FULLSCREEN->hideFullscreenPanels(Landroidx/coordinatorlayout/widget/CoordinatorLayout;)V" + ) + } + } ?: return FullscreenEngagementPanelFingerprint.toErrorResult() + FullscreenViewAdderFingerprint.result?.let { it.mutableMethod.apply { val endIndex = it.scanResult.patternScanResult!!.endIndex @@ -59,25 +79,26 @@ class HideFullscreenPanelsPatch : BytecodePatch( """ ) } - } ?: return FullscreenViewAdderFingerprint.toErrorResult() + } - LayoutConstructorFingerprint.result?.mutableMethod?.let { - val instructions = it.implementation!!.instructions - val dummyRegister = it.getInstruction(it.getStringIndex("1.0x")).registerA + LayoutConstructorFingerprint.result?.let { + it.mutableMethod.apply { + val dummyRegister = getInstruction(getStringIndex("1.0x")).registerA - val invokeIndex = instructions.indexOfFirst { instruction -> - instruction.opcode == Opcode.INVOKE_VIRTUAL && - ((instruction as ReferenceInstruction).reference.toString() == - "Landroid/widget/FrameLayout;->addView(Landroid/view/View;)V") + val invokeIndex = implementation!!.instructions.indexOfFirst { instruction -> + instruction.opcode == Opcode.INVOKE_VIRTUAL && + ((instruction as ReferenceInstruction).reference.toString() == + "Landroid/widget/FrameLayout;->addView(Landroid/view/View;)V") + } + + addInstructionsWithLabels( + invokeIndex, """ + invoke-static {}, $FULLSCREEN->showFullscreenTitle()Z + move-result v$dummyRegister + if-eqz v$dummyRegister, :hidden + """, ExternalLabel("hidden", getInstruction(invokeIndex + 1)) + ) } - - it.addInstructionsWithLabels( - invokeIndex, """ - invoke-static {}, $FULLSCREEN->showFullscreenTitle()Z - move-result v$dummyRegister - if-eqz v$dummyRegister, :hidden - """, ExternalLabel("hidden", it.getInstruction(invokeIndex + 1)) - ) } ?: return LayoutConstructorFingerprint.toErrorResult() /** diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/landscapemode/fingerprints/OrientationParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/landscapemode/fingerprints/OrientationParentFingerprint.kt similarity index 73% rename from src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/landscapemode/fingerprints/OrientationParentFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/fullscreen/landscapemode/fingerprints/OrientationParentFingerprint.kt index c2b1f9ee8..423d3d229 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/landscapemode/fingerprints/OrientationParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/landscapemode/fingerprints/OrientationParentFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.fullscreen.landscapemode.fingerprints +package app.revanced.patches.youtube.fullscreen.landscapemode.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/landscapemode/fingerprints/OrientationPrimaryFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/landscapemode/fingerprints/OrientationPrimaryFingerprint.kt similarity index 85% rename from src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/landscapemode/fingerprints/OrientationPrimaryFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/fullscreen/landscapemode/fingerprints/OrientationPrimaryFingerprint.kt index 5e176a100..a651cfa4c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/landscapemode/fingerprints/OrientationPrimaryFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/landscapemode/fingerprints/OrientationPrimaryFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.fullscreen.landscapemode.fingerprints +package app.revanced.patches.youtube.fullscreen.landscapemode.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/landscapemode/fingerprints/OrientationSecondaryFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/landscapemode/fingerprints/OrientationSecondaryFingerprint.kt similarity index 84% rename from src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/landscapemode/fingerprints/OrientationSecondaryFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/fullscreen/landscapemode/fingerprints/OrientationSecondaryFingerprint.kt index 9c0582ed9..261aef324 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/landscapemode/fingerprints/OrientationSecondaryFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/landscapemode/fingerprints/OrientationSecondaryFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.fullscreen.landscapemode.fingerprints +package app.revanced.patches.youtube.fullscreen.landscapemode.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/landscapemode/patch/LandScapeModePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/landscapemode/patch/LandScapeModePatch.kt similarity index 92% rename from src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/landscapemode/patch/LandScapeModePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/fullscreen/landscapemode/patch/LandScapeModePatch.kt index a99deff41..3263aa6dd 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/landscapemode/patch/LandScapeModePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/landscapemode/patch/LandScapeModePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.fullscreen.landscapemode.patch +package app.revanced.patches.youtube.fullscreen.landscapemode.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -15,8 +15,8 @@ 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.layout.fullscreen.landscapemode.fingerprints.* -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.fullscreen.landscapemode.fingerprints.* +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.FULLSCREEN import org.jf.dexlib2.iface.instruction.OneRegisterInstruction diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/quickactions/patch/QuickActionsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/quickactions/patch/QuickActionsPatch.kt similarity index 81% rename from src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/quickactions/patch/QuickActionsPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/fullscreen/quickactions/patch/QuickActionsPatch.kt index 422866fe7..2135d3462 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/quickactions/patch/QuickActionsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/quickactions/patch/QuickActionsPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.fullscreen.quickactions.patch +package app.revanced.patches.youtube.fullscreen.quickactions.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -11,7 +11,8 @@ 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.misc.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.utils.quickactionscontainer.patch.HideQuickActionsContainerPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch @Patch @Name("hide-quick-actions") @@ -19,6 +20,7 @@ import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch @DependsOn( [ GeneralAdsPatch::class, + HideQuickActionsContainerPatch::class, SettingsPatch::class ] ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/accountmenu/fingerprints/AccountMenuFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/accountmenu/fingerprints/AccountMenuFingerprint.kt similarity index 81% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/accountmenu/fingerprints/AccountMenuFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/accountmenu/fingerprints/AccountMenuFingerprint.kt index ff55300a5..64b477bfe 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/accountmenu/fingerprints/AccountMenuFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/accountmenu/fingerprints/AccountMenuFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.accountmenu.fingerprints +package app.revanced.patches.youtube.general.accountmenu.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/accountmenu/fingerprints/AccountMenuParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/accountmenu/fingerprints/AccountMenuParentFingerprint.kt similarity index 57% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/accountmenu/fingerprints/AccountMenuParentFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/accountmenu/fingerprints/AccountMenuParentFingerprint.kt index 2911f3f55..ff74997ac 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/accountmenu/fingerprints/AccountMenuParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/accountmenu/fingerprints/AccountMenuParentFingerprint.kt @@ -1,7 +1,7 @@ -package app.revanced.patches.youtube.layout.general.accountmenu.fingerprints +package app.revanced.patches.youtube.general.accountmenu.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.compactLinkId +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.CompactLink import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.Opcode @@ -12,5 +12,5 @@ object AccountMenuParentFingerprint : MethodFingerprint( Opcode.INVOKE_VIRTUAL, Opcode.MOVE_RESULT_OBJECT ), - customFingerprint = { it, _ -> it.isWideLiteralExists(compactLinkId) } + customFingerprint = { it, _ -> it.isWideLiteralExists(CompactLink) } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/accountmenu/patch/AccountMenuPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/accountmenu/patch/AccountMenuPatch.kt similarity index 86% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/accountmenu/patch/AccountMenuPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/accountmenu/patch/AccountMenuPatch.kt index d6db9b21f..3af7db96f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/accountmenu/patch/AccountMenuPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/accountmenu/patch/AccountMenuPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.accountmenu.patch +package app.revanced.patches.youtube.general.accountmenu.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -14,10 +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.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.layout.general.accountmenu.fingerprints.AccountMenuFingerprint -import app.revanced.patches.youtube.layout.general.accountmenu.fingerprints.AccountMenuParentFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.GENERAL import org.jf.dexlib2.iface.instruction.OneRegisterInstruction diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/autocaptions/fingerprints/StartVideoInformerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/autocaptions/fingerprints/StartVideoInformerFingerprint.kt similarity index 84% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/autocaptions/fingerprints/StartVideoInformerFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/autocaptions/fingerprints/StartVideoInformerFingerprint.kt index 01e05b524..272a96296 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/autocaptions/fingerprints/StartVideoInformerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/autocaptions/fingerprints/StartVideoInformerFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.autocaptions.fingerprints +package app.revanced.patches.youtube.general.autocaptions.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/autocaptions/patch/AutoCaptionsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/autocaptions/patch/AutoCaptionsPatch.kt similarity index 68% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/autocaptions/patch/AutoCaptionsPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/autocaptions/patch/AutoCaptionsPatch.kt index 0f0e46ac9..9ea77f95e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/autocaptions/patch/AutoCaptionsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/autocaptions/patch/AutoCaptionsPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.autocaptions.patch +package app.revanced.patches.youtube.general.autocaptions.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -18,9 +18,9 @@ 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.layout.general.autocaptions.fingerprints.StartVideoInformerFingerprint -import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 import app.revanced.util.integrations.Constants.GENERAL @Patch @@ -46,29 +46,28 @@ class AutoCaptionsPatch : BytecodePatch( StartVideoInformerFingerprint.toPatch(Status.DISABLED), SubtitleButtonControllerFingerprint.toPatch(Status.ENABLED) ).forEach { (fingerprint, status) -> - with(fingerprint.result?.mutableMethod ?: return fingerprint.toErrorResult()) { - addInstructions( - 0, + fingerprint.result?.mutableMethod?.addInstructions( + 0, """ + const/4 v0, ${status.value} + sput-boolean v0, $GENERAL->captionsButtonStatus:Z """ - const/4 v0, ${status.value} - sput-boolean v0, $GENERAL->captionsButtonStatus:Z - """ - ) - } + )?: return fingerprint.toErrorResult() } - SubtitleTrackFingerprint.result?.mutableMethod?.let { - it.addInstructionsWithLabels( - 0, """ - invoke-static {}, $GENERAL->hideAutoCaptions()Z - move-result v0 - if-eqz v0, :auto_captions_shown - sget-boolean v0, $GENERAL->captionsButtonStatus:Z - if-nez v0, :auto_captions_shown - const/4 v0, 0x1 - return v0 - """, ExternalLabel("auto_captions_shown", it.getInstruction(0)) - ) + SubtitleTrackFingerprint.result?.let { + it.mutableMethod.apply { + addInstructionsWithLabels( + 0, """ + invoke-static {}, $GENERAL->hideAutoCaptions()Z + move-result v0 + if-eqz v0, :auto_captions_shown + sget-boolean v0, $GENERAL->captionsButtonStatus:Z + if-nez v0, :auto_captions_shown + const/4 v0, 0x1 + return v0 + """, ExternalLabel("auto_captions_shown", getInstruction(0)) + ) + } } ?: return SubtitleTrackFingerprint.toErrorResult() /** diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/autopopuppanels/fingerprints/EngagementPanelControllerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/autopopuppanels/fingerprints/EngagementPanelControllerFingerprint.kt similarity index 87% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/autopopuppanels/fingerprints/EngagementPanelControllerFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/autopopuppanels/fingerprints/EngagementPanelControllerFingerprint.kt index d109c0578..ab7900fd1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/autopopuppanels/fingerprints/EngagementPanelControllerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/autopopuppanels/fingerprints/EngagementPanelControllerFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.autopopuppanels.fingerprints +package app.revanced.patches.youtube.general.autopopuppanels.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/autopopuppanels/patch/PlayerPopupPanelsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/autopopuppanels/patch/PlayerPopupPanelsPatch.kt similarity index 65% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/autopopuppanels/patch/PlayerPopupPanelsPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/autopopuppanels/patch/PlayerPopupPanelsPatch.kt index 21ed578ab..aea06d0a0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/autopopuppanels/patch/PlayerPopupPanelsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/autopopuppanels/patch/PlayerPopupPanelsPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.autopopuppanels.patch +package app.revanced.patches.youtube.general.autopopuppanels.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -14,8 +14,8 @@ 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.layout.general.autopopuppanels.fingerprints.EngagementPanelControllerFingerprint -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 @Patch @@ -29,17 +29,19 @@ class PlayerPopupPanelsPatch : BytecodePatch( ) { override fun execute(context: BytecodeContext): PatchResult { - EngagementPanelControllerFingerprint.result?.mutableMethod?.let { - it.addInstructionsWithLabels( - 0, """ - invoke-static {}, $GENERAL->hideAutoPlayerPopupPanels()Z - move-result v0 - if-eqz v0, :player_popup_panels_shown - if-eqz p4, :player_popup_panels_shown - const/4 v0, 0x0 - return-object v0 - """, ExternalLabel("player_popup_panels_shown", it.getInstruction(0)) - ) + EngagementPanelControllerFingerprint.result?.let { + it.mutableMethod.apply { + addInstructionsWithLabels( + 0, """ + invoke-static {}, $GENERAL->hideAutoPlayerPopupPanels()Z + move-result v0 + if-eqz v0, :player_popup_panels_shown + if-eqz p4, :player_popup_panels_shown + const/4 v0, 0x0 + return-object v0 + """, ExternalLabel("player_popup_panels_shown", getInstruction(0)) + ) + } } ?: return EngagementPanelControllerFingerprint.toErrorResult() /** diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/breakingnews/fingerprints/BreakingNewsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/breakingnews/fingerprints/BreakingNewsFingerprint.kt similarity index 56% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/breakingnews/fingerprints/BreakingNewsFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/breakingnews/fingerprints/BreakingNewsFingerprint.kt index bab03ab15..59d5b995a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/breakingnews/fingerprints/BreakingNewsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/breakingnews/fingerprints/BreakingNewsFingerprint.kt @@ -1,7 +1,7 @@ -package app.revanced.patches.youtube.layout.general.breakingnews.fingerprints +package app.revanced.patches.youtube.general.breakingnews.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.horizontalCardListId +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.HorizontalCardList import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.Opcode @@ -12,5 +12,5 @@ object BreakingNewsFingerprint : MethodFingerprint( Opcode.INVOKE_VIRTUAL, Opcode.MOVE_RESULT_OBJECT ), - customFingerprint = { it, _ -> it.isWideLiteralExists(horizontalCardListId) } + customFingerprint = { it, _ -> it.isWideLiteralExists(HorizontalCardList) } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/breakingnews/patch/BreakingNewsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/breakingnews/patch/BreakingNewsPatch.kt similarity index 86% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/breakingnews/patch/BreakingNewsPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/breakingnews/patch/BreakingNewsPatch.kt index 13b270750..1d2f8e444 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/breakingnews/patch/BreakingNewsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/breakingnews/patch/BreakingNewsPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.breakingnews.patch +package app.revanced.patches.youtube.general.breakingnews.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -13,9 +13,9 @@ 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.layout.general.breakingnews.fingerprints.BreakingNewsFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.general.breakingnews.fingerprints.BreakingNewsFingerprint +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.GENERAL import org.jf.dexlib2.iface.instruction.OneRegisterInstruction diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/categorybar/fingerprints/FilterBarHeightFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/categorybar/fingerprints/FilterBarHeightFingerprint.kt similarity index 56% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/categorybar/fingerprints/FilterBarHeightFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/categorybar/fingerprints/FilterBarHeightFingerprint.kt index 871489d37..e935cce3c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/categorybar/fingerprints/FilterBarHeightFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/categorybar/fingerprints/FilterBarHeightFingerprint.kt @@ -1,7 +1,7 @@ -package app.revanced.patches.youtube.layout.general.categorybar.fingerprints +package app.revanced.patches.youtube.general.categorybar.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.filterBarHeightId +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.FilterBarHeight import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.Opcode @@ -12,5 +12,5 @@ object FilterBarHeightFingerprint : MethodFingerprint( Opcode.MOVE_RESULT, Opcode.IPUT ), - customFingerprint = { it, _ -> it.isWideLiteralExists(filterBarHeightId) } + customFingerprint = { it, _ -> it.isWideLiteralExists(FilterBarHeight) } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/categorybar/fingerprints/RelatedChipCloudFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/categorybar/fingerprints/RelatedChipCloudFingerprint.kt similarity index 54% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/categorybar/fingerprints/RelatedChipCloudFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/categorybar/fingerprints/RelatedChipCloudFingerprint.kt index bd30cf50c..a9351a65e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/categorybar/fingerprints/RelatedChipCloudFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/categorybar/fingerprints/RelatedChipCloudFingerprint.kt @@ -1,7 +1,7 @@ -package app.revanced.patches.youtube.layout.general.categorybar.fingerprints +package app.revanced.patches.youtube.general.categorybar.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.relatedChipCloudMarginId +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.RelatedChipCloudMargin import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.Opcode @@ -11,5 +11,5 @@ object RelatedChipCloudFingerprint : MethodFingerprint( Opcode.INVOKE_VIRTUAL, Opcode.MOVE_RESULT_OBJECT ), - customFingerprint = { it, _ -> it.isWideLiteralExists(relatedChipCloudMarginId) } + customFingerprint = { it, _ -> it.isWideLiteralExists(RelatedChipCloudMargin) } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/categorybar/fingerprints/SearchResultsChipBarFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/categorybar/fingerprints/SearchResultsChipBarFingerprint.kt similarity index 59% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/categorybar/fingerprints/SearchResultsChipBarFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/categorybar/fingerprints/SearchResultsChipBarFingerprint.kt index 5cc04caff..26e9464ef 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/categorybar/fingerprints/SearchResultsChipBarFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/categorybar/fingerprints/SearchResultsChipBarFingerprint.kt @@ -1,7 +1,7 @@ -package app.revanced.patches.youtube.layout.general.categorybar.fingerprints +package app.revanced.patches.youtube.general.categorybar.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.barContainerHeightId +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.BarContainerHeight import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.Opcode @@ -13,5 +13,5 @@ object SearchResultsChipBarFingerprint : MethodFingerprint( Opcode.INVOKE_VIRTUAL, Opcode.MOVE_RESULT_OBJECT ), - customFingerprint = { it, _ -> it.isWideLiteralExists(barContainerHeightId) } + customFingerprint = { it, _ -> it.isWideLiteralExists(BarContainerHeight) } ) \ No newline at end of file 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 new file mode 100644 index 000000000..1a11f97a9 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/general/categorybar/patch/CategoryBarPatch.kt @@ -0,0 +1,96 @@ +package app.revanced.patches.youtube.general.categorybar.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +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.patcher.patch.annotations.Patch +import app.revanced.patches.shared.annotation.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 +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch +import app.revanced.util.integrations.Constants.GENERAL +import org.jf.dexlib2.iface.instruction.OneRegisterInstruction +import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction + +@Patch +@Name("hide-category-bar") +@Description("Hide the category bar at the top of the feed and at the top of related videos.") +@DependsOn( + [ + SettingsPatch::class, + SharedResourceIdPatch::class + ] +) +@YouTubeCompatibility +@Version("0.0.1") +class CategoryBarPatch : BytecodePatch( + listOf( + FilterBarHeightFingerprint, + RelatedChipCloudFingerprint, + SearchResultsChipBarFingerprint + ) +) { + override fun execute(context: BytecodeContext): PatchResult { + + FilterBarHeightFingerprint.patch { register -> + """ + invoke-static { v$register }, $GENERAL->hideCategoryBarInFeed(I)I + move-result v$register + """ + } + + RelatedChipCloudFingerprint.patch(1) { register -> + "invoke-static { v$register }, " + + "$GENERAL->hideCategoryBarInRelatedVideo(Landroid/view/View;)V" + } + + SearchResultsChipBarFingerprint.patch(-1, -2) { register -> + """ + invoke-static { v$register }, $GENERAL->hideCategoryBarInSearchResults(I)I + move-result v$register + """ + } + + /** + * Add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: GENERAL_SETTINGS", + "SETTINGS: HIDE_CATEGORY_BAR" + ) + ) + + SettingsPatch.updatePatchStatus("hide-category-bar") + + return PatchResultSuccess() + } + private companion object { + private fun MethodFingerprint.patch( + insertIndexOffset: Int = 0, + hookRegisterOffset: Int = 0, + instructions: (Int) -> String + ) = + result?.let { + it.mutableMethod.apply { + val endIndex = it.scanResult.patternScanResult!!.endIndex + + val insertIndex = endIndex + insertIndexOffset + val register = getInstruction(endIndex + hookRegisterOffset).registerA + + addInstructions(insertIndex, instructions(register)) + } + } ?: throw toErrorResult() + } +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/channellistsubmenu/fingerprints/ChannelListSubMenuFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/channellistsubmenu/fingerprints/ChannelListSubMenuFingerprint.kt similarity index 56% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/channellistsubmenu/fingerprints/ChannelListSubMenuFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/channellistsubmenu/fingerprints/ChannelListSubMenuFingerprint.kt index 1e3596dad..c0dca6286 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/channellistsubmenu/fingerprints/ChannelListSubMenuFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/channellistsubmenu/fingerprints/ChannelListSubMenuFingerprint.kt @@ -1,7 +1,7 @@ -package app.revanced.patches.youtube.layout.general.channellistsubmenu.fingerprints +package app.revanced.patches.youtube.general.channellistsubmenu.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.channelListSubMenuId +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.ChannelListSubMenu import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.Opcode @@ -12,5 +12,5 @@ object ChannelListSubMenuFingerprint : MethodFingerprint( Opcode.INVOKE_VIRTUAL, Opcode.MOVE_RESULT_OBJECT ), - customFingerprint = { it, _ -> it.isWideLiteralExists(channelListSubMenuId) } + customFingerprint = { it, _ -> it.isWideLiteralExists(ChannelListSubMenu) } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/channellistsubmenu/patch/ChannelListSubMenuPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/channellistsubmenu/patch/ChannelListSubMenuPatch.kt similarity index 85% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/channellistsubmenu/patch/ChannelListSubMenuPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/channellistsubmenu/patch/ChannelListSubMenuPatch.kt index eac2aeee5..9e3cbbf34 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/channellistsubmenu/patch/ChannelListSubMenuPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/channellistsubmenu/patch/ChannelListSubMenuPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.channellistsubmenu.patch +package app.revanced.patches.youtube.general.channellistsubmenu.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -13,9 +13,9 @@ 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.layout.general.channellistsubmenu.fingerprints.ChannelListSubMenuFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 import app.revanced.util.integrations.Constants.GENERAL import org.jf.dexlib2.iface.instruction.OneRegisterInstruction diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/crowdfundingbox/fingerprints/CrowdfundingBoxFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/crowdfundingbox/fingerprints/CrowdfundingBoxFingerprint.kt similarity index 53% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/crowdfundingbox/fingerprints/CrowdfundingBoxFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/crowdfundingbox/fingerprints/CrowdfundingBoxFingerprint.kt index 46543d8a2..8623e2334 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/crowdfundingbox/fingerprints/CrowdfundingBoxFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/crowdfundingbox/fingerprints/CrowdfundingBoxFingerprint.kt @@ -1,7 +1,7 @@ -package app.revanced.patches.youtube.layout.general.crowdfundingbox.fingerprints +package app.revanced.patches.youtube.general.crowdfundingbox.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.donationCompanionResourceId +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.DonationCompanion import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.Opcode @@ -11,5 +11,5 @@ object CrowdfundingBoxFingerprint : MethodFingerprint( Opcode.MOVE_RESULT_OBJECT, Opcode.IPUT_OBJECT ), - customFingerprint = { it, _ -> it.isWideLiteralExists(donationCompanionResourceId) } + customFingerprint = { it, _ -> it.isWideLiteralExists(DonationCompanion) } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/crowdfundingbox/patch/CrowdfundingBoxPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/crowdfundingbox/patch/CrowdfundingBoxPatch.kt similarity index 86% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/crowdfundingbox/patch/CrowdfundingBoxPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/crowdfundingbox/patch/CrowdfundingBoxPatch.kt index 8662da52f..64fa35be4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/crowdfundingbox/patch/CrowdfundingBoxPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/crowdfundingbox/patch/CrowdfundingBoxPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.crowdfundingbox.patch +package app.revanced.patches.youtube.general.crowdfundingbox.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -13,9 +13,9 @@ 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.layout.general.crowdfundingbox.fingerprints.CrowdfundingBoxFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 import app.revanced.util.integrations.Constants.GENERAL import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/floatingmicrophone/fingerprints/FloatingMicrophoneFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/floatingmicrophone/fingerprints/FloatingMicrophoneFingerprint.kt similarity index 56% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/floatingmicrophone/fingerprints/FloatingMicrophoneFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/floatingmicrophone/fingerprints/FloatingMicrophoneFingerprint.kt index f2ecb9c1c..4dd5148bb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/floatingmicrophone/fingerprints/FloatingMicrophoneFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/floatingmicrophone/fingerprints/FloatingMicrophoneFingerprint.kt @@ -1,7 +1,7 @@ -package app.revanced.patches.youtube.layout.general.floatingmicrophone.fingerprints +package app.revanced.patches.youtube.general.floatingmicrophone.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.fabId +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.Fab import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.Opcode @@ -11,5 +11,5 @@ object FloatingMicrophoneFingerprint : MethodFingerprint( Opcode.IF_EQZ, Opcode.RETURN_VOID ), - customFingerprint = { it, _ -> it.isWideLiteralExists(fabId) } + customFingerprint = { it, _ -> it.isWideLiteralExists(Fab) } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/floatingmicrophone/patch/FloatingMicrophonePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/floatingmicrophone/patch/FloatingMicrophonePatch.kt similarity index 85% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/floatingmicrophone/patch/FloatingMicrophonePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/floatingmicrophone/patch/FloatingMicrophonePatch.kt index afba455d6..b27c068ed 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/floatingmicrophone/patch/FloatingMicrophonePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/floatingmicrophone/patch/FloatingMicrophonePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.floatingmicrophone.patch +package app.revanced.patches.youtube.general.floatingmicrophone.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -13,9 +13,9 @@ 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.layout.general.floatingmicrophone.fingerprints.FloatingMicrophoneFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 import app.revanced.util.integrations.Constants.GENERAL import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction @@ -49,7 +49,7 @@ class FloatingMicrophonePatch : BytecodePatch( } } ?: return FloatingMicrophoneFingerprint.toErrorResult() - /* + /** * Add settings */ SettingsPatch.addPreference( 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 new file mode 100644 index 000000000..6397c27c6 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/general/headerswitch/patch/HeaderSwitchPatch.kt @@ -0,0 +1,74 @@ +package app.revanced.patches.youtube.general.headerswitch.patch + +import app.revanced.extensions.findMutableMethodOf +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +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.patcher.patch.annotations.DependsOn +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.shared.annotation.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 +import app.revanced.util.bytecode.getWideLiteralIndex +import app.revanced.util.bytecode.isWideLiteralExists +import app.revanced.util.integrations.Constants.GENERAL +import org.jf.dexlib2.iface.instruction.OneRegisterInstruction + +@Patch +@Name("header-switch") +@Description("Add switch to change header.") +@DependsOn( + [ + SettingsPatch::class, + SharedResourceIdPatch::class + ] +) +@YouTubeCompatibility +@Version("0.0.1") +@Suppress("LABEL_NAME_CLASH") +class HeaderSwitchPatch : BytecodePatch() { + override fun execute(context: BytecodeContext): PatchResult { + context.classes.forEach { classDef -> + classDef.methods.forEach { method -> + if (!method.isWideLiteralExists(WordMarkHeader)) + return@forEach + + context.proxy(classDef) + .mutableClass + .findMutableMethodOf(method) + .apply { + val targetIndex = getWideLiteralIndex(WordMarkHeader) + val targetRegister = getInstruction(targetIndex).registerA + + addInstructions( + targetIndex + 1, """ + invoke-static {v$targetRegister}, $GENERAL->enablePremiumHeader(I)I + move-result v$targetRegister + """ + ) + } + } + } + + /** + * Add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: GENERAL_SETTINGS", + "SETTINGS: HEADER_SWITCH" + ) + ) + + SettingsPatch.updatePatchStatus("header-switch") + + return PatchResultSuccess() + } +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/loadmorebutton/fingerprints/LoadMoreButtonFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/loadmorebutton/fingerprints/LoadMoreButtonFingerprint.kt similarity index 57% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/loadmorebutton/fingerprints/LoadMoreButtonFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/loadmorebutton/fingerprints/LoadMoreButtonFingerprint.kt index 88273fd62..3a37a2fc6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/loadmorebutton/fingerprints/LoadMoreButtonFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/loadmorebutton/fingerprints/LoadMoreButtonFingerprint.kt @@ -1,7 +1,7 @@ -package app.revanced.patches.youtube.layout.general.loadmorebutton.fingerprints +package app.revanced.patches.youtube.general.loadmorebutton.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.expandButtonId +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.ExpandButtonDown import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.Opcode @@ -12,5 +12,5 @@ object LoadMoreButtonFingerprint : MethodFingerprint( Opcode.INVOKE_STATIC, Opcode.MOVE_RESULT_OBJECT ), - customFingerprint = { it, _ -> it.isWideLiteralExists(expandButtonId) } + customFingerprint = { it, _ -> it.isWideLiteralExists(ExpandButtonDown) } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/loadmorebutton/patch/LoadMoreButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/loadmorebutton/patch/LoadMoreButtonPatch.kt similarity index 86% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/loadmorebutton/patch/LoadMoreButtonPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/loadmorebutton/patch/LoadMoreButtonPatch.kt index 44d3f73b6..5cb643abc 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/loadmorebutton/patch/LoadMoreButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/loadmorebutton/patch/LoadMoreButtonPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.loadmorebutton.patch +package app.revanced.patches.youtube.general.loadmorebutton.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -13,9 +13,9 @@ 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.layout.general.loadmorebutton.fingerprints.LoadMoreButtonFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 import app.revanced.util.integrations.Constants.GENERAL import org.jf.dexlib2.iface.instruction.OneRegisterInstruction diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/mixplaylists/fingerprints/BottomPanelOverlayTextFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/mixplaylists/fingerprints/BottomPanelOverlayTextFingerprint.kt new file mode 100644 index 000000000..8aa933539 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/general/mixplaylists/fingerprints/BottomPanelOverlayTextFingerprint.kt @@ -0,0 +1,15 @@ +package app.revanced.patches.youtube.general.mixplaylists.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.BottomPanelOverlayText +import app.revanced.util.bytecode.isWideLiteralExists +import org.jf.dexlib2.Opcode + +object BottomPanelOverlayTextFingerprint : MethodFingerprint( + opcodes = listOf( + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT_OBJECT, + Opcode.IPUT_OBJECT + ), + customFingerprint = { it, _ -> it.isWideLiteralExists(BottomPanelOverlayText) } +) \ No newline at end of file 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 new file mode 100644 index 000000000..02271d0b7 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/general/mixplaylists/patch/MixPlaylistsPatch.kt @@ -0,0 +1,100 @@ +package app.revanced.patches.youtube.general.mixplaylists.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +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.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.youtube.general.mixplaylists.fingerprints.BottomPanelOverlayTextFingerprint +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch +import app.revanced.util.bytecode.getStringIndex +import app.revanced.util.integrations.Constants.GENERAL +import org.jf.dexlib2.Opcode +import org.jf.dexlib2.iface.instruction.OneRegisterInstruction +import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction + +@Patch +@Name("hide-mix-playlists") +@Description("Removes mix playlists from home feed and video player.") +@DependsOn([SettingsPatch::class]) +@YouTubeCompatibility +@Version("0.0.1") +class MixPlaylistsPatch : BytecodePatch( + listOf( + BottomPanelOverlayTextFingerprint, + EmptyComponentBuilderFingerprint + ) +) { + override fun execute(context: BytecodeContext): PatchResult { + + /** + * Hide MixPlaylists when tablet UI is turned on + * Required only for RVX Patches + */ + BottomPanelOverlayTextFingerprint.result?.let { + it.mutableMethod.apply { + val insertIndex = it.scanResult.patternScanResult!!.endIndex + val insertRegister = getInstruction(insertIndex).registerA + + addInstruction( + insertIndex, + "invoke-static {v$insertRegister}, $GENERAL->hideMixPlaylists(Landroid/view/View;)V" + ) + } + } ?: return BottomPanelOverlayTextFingerprint.toErrorResult() + + /** + * Separated from bytebuffer patch + * Target method is only used for Hide MixPlaylists patch + */ + EmptyComponentBuilderFingerprint.result?.let { + it.mutableMethod.apply { + val freeIndex = implementation!!.instructions.indexOfFirst { instruction -> + instruction.opcode == Opcode.CONST_4 + } + val jumpIndex = getStringIndex("Failed to convert Element to Flatbuffers: %s") + 2 + val insertIndex = freeIndex + 5 + + val freeRegister = getInstruction(freeIndex).registerA + 1 + + addInstructionsWithLabels( + insertIndex, """ + invoke-static {v$freeRegister}, $GENERAL->hideMixPlaylists([B)Z + move-result v$freeRegister + if-nez v$freeRegister, :not_an_ad + """, ExternalLabel("not_an_ad", getInstruction(jumpIndex)) + ) + + addInstruction( + 0, + "move-object/from16 v$freeRegister, p3" + ) + } + } ?: return EmptyComponentBuilderFingerprint.toErrorResult() + + /** + * Add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: GENERAL_SETTINGS", + "SETTINGS: HIDE_MIX_PLAYLISTS" + ) + ) + + SettingsPatch.updatePatchStatus("hide-mix-playlists") + + return PatchResultSuccess() + } +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/personalinformation/fingerprints/AccountSwitcherAccessibilityLabelFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/personalinformation/fingerprints/AccountSwitcherAccessibilityLabelFingerprint.kt similarity index 59% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/personalinformation/fingerprints/AccountSwitcherAccessibilityLabelFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/personalinformation/fingerprints/AccountSwitcherAccessibilityLabelFingerprint.kt index 14fb497d0..3b99621b8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/personalinformation/fingerprints/AccountSwitcherAccessibilityLabelFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/personalinformation/fingerprints/AccountSwitcherAccessibilityLabelFingerprint.kt @@ -1,7 +1,7 @@ -package app.revanced.patches.youtube.layout.general.personalinformation.fingerprints +package app.revanced.patches.youtube.general.personalinformation.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.accountSwitcherAccessibilityId +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.AccountSwitcherAccessibility import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.Opcode @@ -15,5 +15,5 @@ object AccountSwitcherAccessibilityLabelFingerprint : MethodFingerprint( Opcode.APUT_OBJECT, Opcode.CONST ), - customFingerprint = { it, _ -> it.isWideLiteralExists(accountSwitcherAccessibilityId) } + customFingerprint = { it, _ -> it.isWideLiteralExists(AccountSwitcherAccessibility) } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/personalinformation/patch/HideEmailAddressPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/personalinformation/patch/HideEmailAddressPatch.kt similarity index 72% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/personalinformation/patch/HideEmailAddressPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/personalinformation/patch/HideEmailAddressPatch.kt index a6524b90a..ae92332f5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/personalinformation/patch/HideEmailAddressPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/personalinformation/patch/HideEmailAddressPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.personalinformation.patch +package app.revanced.patches.youtube.general.personalinformation.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -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.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.layout.general.personalinformation.fingerprints.AccountSwitcherAccessibilityLabelFingerprint -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @@ -31,14 +31,14 @@ class HideEmailAddressPatch : BytecodePatch( AccountSwitcherAccessibilityLabelFingerprint.result?.let { it.mutableMethod.apply { - val insertIndex = it.scanResult.patternScanResult!!.endIndex - val register = getInstruction(insertIndex - 2).registerA + val targetIndex = it.scanResult.patternScanResult!!.endIndex - 2 + val targetRegister = getInstruction(targetIndex).registerA addInstructions( - insertIndex, """ - invoke-static {v$register}, $GENERAL->hideEmailAddress(I)I - move-result v$register - """ + targetIndex + 2, """ + invoke-static {v$targetRegister}, $GENERAL->hideEmailAddress(I)I + move-result v$targetRegister + """ ) } } ?: return AccountSwitcherAccessibilityLabelFingerprint.toErrorResult() diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/searchterms/fingerprints/SearchEndpointFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/searchterms/fingerprints/SearchEndpointFingerprint.kt similarity index 86% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/searchterms/fingerprints/SearchEndpointFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/searchterms/fingerprints/SearchEndpointFingerprint.kt index dc3db855a..3eeb4ff9b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/searchterms/fingerprints/SearchEndpointFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/searchterms/fingerprints/SearchEndpointFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.searchterms.fingerprints +package app.revanced.patches.youtube.general.searchterms.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/searchterms/fingerprints/SearchEndpointParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/searchterms/fingerprints/SearchEndpointParentFingerprint.kt similarity index 82% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/searchterms/fingerprints/SearchEndpointParentFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/searchterms/fingerprints/SearchEndpointParentFingerprint.kt index e7134c281..d384bc54a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/searchterms/fingerprints/SearchEndpointParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/searchterms/fingerprints/SearchEndpointParentFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.searchterms.fingerprints +package app.revanced.patches.youtube.general.searchterms.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/searchterms/fingerprints/SearchSuggestionEntryFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/searchterms/fingerprints/SearchSuggestionEntryFingerprint.kt new file mode 100644 index 000000000..eca6ca369 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/general/searchterms/fingerprints/SearchSuggestionEntryFingerprint.kt @@ -0,0 +1,9 @@ +package app.revanced.patches.youtube.general.searchterms.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.SearchSuggestionEntry +import app.revanced.util.bytecode.isWideLiteralExists + +object SearchSuggestionEntryFingerprint : MethodFingerprint( + customFingerprint = { it, _ -> it.isWideLiteralExists(SearchSuggestionEntry) } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/searchterms/patch/SearchTermsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/searchterms/patch/SearchTermsPatch.kt similarity index 81% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/searchterms/patch/SearchTermsPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/searchterms/patch/SearchTermsPatch.kt index 41ca72358..f6574f7c1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/searchterms/patch/SearchTermsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/searchterms/patch/SearchTermsPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.searchterms.patch +package app.revanced.patches.youtube.general.searchterms.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -14,10 +14,12 @@ 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.layout.general.searchterms.fingerprints.* -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.searchSuggestionEntryId -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.SearchSuggestionEntry +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.bytecode.getWideLiteralIndex import app.revanced.util.integrations.Constants.GENERAL import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @@ -56,7 +58,7 @@ class SearchTermsPatch : BytecodePatch( } ?: return SearchEndpointParentFingerprint.toErrorResult() SearchSuggestionEntryFingerprint.result?.mutableMethod?.let { - val targetIndex = it.getWideLiteralIndex(searchSuggestionEntryId) + 2 + val targetIndex = it.getWideLiteralIndex(SearchSuggestionEntry) + 2 val targetRegister = it.getInstruction(targetIndex).registerA it.addInstruction( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/snackbar/fingerprints/HideSnackBarFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/snackbar/fingerprints/HideSnackBarFingerprint.kt similarity index 84% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/snackbar/fingerprints/HideSnackBarFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/snackbar/fingerprints/HideSnackBarFingerprint.kt index 1f55c1e8a..c2ccbed63 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/snackbar/fingerprints/HideSnackBarFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/snackbar/fingerprints/HideSnackBarFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.snackbar.fingerprints +package app.revanced.patches.youtube.general.snackbar.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/snackbar/patch/HideSnackBarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/snackbar/patch/HideSnackBarPatch.kt similarity index 69% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/snackbar/patch/HideSnackBarPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/snackbar/patch/HideSnackBarPatch.kt index 6844831be..c4b48b01b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/snackbar/patch/HideSnackBarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/snackbar/patch/HideSnackBarPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.snackbar.patch +package app.revanced.patches.youtube.general.snackbar.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -14,8 +14,8 @@ 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.layout.general.snackbar.fingerprints.HideSnackBarFingerprint -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 @Patch @@ -29,15 +29,17 @@ class HideSnackBarPatch : BytecodePatch( ) { override fun execute(context: BytecodeContext): PatchResult { - HideSnackBarFingerprint.result?.mutableMethod?.let { - it.addInstructionsWithLabels( - 0, """ - invoke-static {}, $GENERAL->hideSnackBar()Z - move-result v0 - if-eqz v0, :default - return-void - """, ExternalLabel("default", it.getInstruction(0)) - ) + HideSnackBarFingerprint.result?.let { + it.mutableMethod.apply { + addInstructionsWithLabels( + 0, """ + invoke-static {}, $GENERAL->hideSnackBar()Z + move-result v0 + if-eqz v0, :default + return-void + """, ExternalLabel("default", getInstruction(0)) + ) + } } ?: return HideSnackBarFingerprint.toErrorResult() /** diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/stories/patch/HideStoriesPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/stories/patch/HideStoriesPatch.kt similarity index 77% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/stories/patch/HideStoriesPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/stories/patch/HideStoriesPatch.kt index 9e965f94b..8c3f59a62 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/stories/patch/HideStoriesPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/stories/patch/HideStoriesPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.stories.patch +package app.revanced.patches.youtube.general.stories.patch import app.revanced.extensions.findMutableMethodOf import app.revanced.extensions.injectHideCall @@ -14,7 +14,7 @@ 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.misc.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.formats.Instruction22c import org.jf.dexlib2.iface.instruction.formats.Instruction31i @@ -35,7 +35,8 @@ class HideStoriesPatch : BytecodePatch() { // list of resource names to get the id of private val resourceIds = arrayOf( "reel_multiple_items_shelf", - "reel_item_container" + "reel_item_container", + "reel_multiple_items_shelf_title_layout" ).map { name -> ResourceMappingPatch.resourceMappings.single { it.name == name }.id } @@ -49,7 +50,7 @@ class HideStoriesPatch : BytecodePatch() { when (instruction.opcode) { Opcode.CONST -> { when ((instruction as Instruction31i).wideLiteral) { - resourceIds[0], resourceIds[1] -> { // reel ads + resourceIds[0], resourceIds[1] -> { val insertIndex = index + 4 val iPutInstruction = instructions.elementAt(insertIndex) if (iPutInstruction.opcode != Opcode.IPUT_OBJECT) return@forEachIndexed @@ -62,6 +63,19 @@ class HideStoriesPatch : BytecodePatch() { patchSuccessArray[0] = true patchSuccessArray[1] = true } + + resourceIds[2] -> { + val insertIndex = index - 1 + val iPutInstruction = instructions.elementAt(insertIndex) + if (iPutInstruction.opcode != Opcode.IPUT_OBJECT) return@forEachIndexed + + val mutableMethod = context.proxy(classDef).mutableClass.findMutableMethodOf(method) + + 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/layout/general/tabletminiplayer/fingerprints/MiniPlayerDimensionsCalculatorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/tabletminiplayer/fingerprints/MiniPlayerDimensionsCalculatorFingerprint.kt similarity index 56% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/fingerprints/MiniPlayerDimensionsCalculatorFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/tabletminiplayer/fingerprints/MiniPlayerDimensionsCalculatorFingerprint.kt index 8a5477a71..72a116117 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/fingerprints/MiniPlayerDimensionsCalculatorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/tabletminiplayer/fingerprints/MiniPlayerDimensionsCalculatorFingerprint.kt @@ -1,13 +1,13 @@ -package app.revanced.patches.youtube.layout.general.tabletminiplayer.fingerprints +package app.revanced.patches.youtube.general.tabletminiplayer.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.floatyBarTopMarginId +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.FloatyBarTopMargin import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.AccessFlags object MiniPlayerDimensionsCalculatorFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, - customFingerprint = { it, _ -> it.isWideLiteralExists(floatyBarTopMarginId) } + customFingerprint = { it, _ -> it.isWideLiteralExists(FloatyBarTopMargin) } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/fingerprints/MiniPlayerOverrideFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/tabletminiplayer/fingerprints/MiniPlayerOverrideFingerprint.kt similarity index 75% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/fingerprints/MiniPlayerOverrideFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/tabletminiplayer/fingerprints/MiniPlayerOverrideFingerprint.kt index 178983fd1..7cac4b39d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/fingerprints/MiniPlayerOverrideFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/tabletminiplayer/fingerprints/MiniPlayerOverrideFingerprint.kt @@ -1,9 +1,8 @@ -package app.revanced.patches.youtube.layout.general.tabletminiplayer.fingerprints +package app.revanced.patches.youtube.general.tabletminiplayer.fingerprints 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 MiniPlayerOverrideFingerprint : MethodFingerprint( returnType = "L", diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/fingerprints/MiniPlayerOverrideNoContextFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/tabletminiplayer/fingerprints/MiniPlayerOverrideNoContextFingerprint.kt similarity index 82% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/fingerprints/MiniPlayerOverrideNoContextFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/tabletminiplayer/fingerprints/MiniPlayerOverrideNoContextFingerprint.kt index 368cd9697..962e0934b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/fingerprints/MiniPlayerOverrideNoContextFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/tabletminiplayer/fingerprints/MiniPlayerOverrideNoContextFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.tabletminiplayer.fingerprints +package app.revanced.patches.youtube.general.tabletminiplayer.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/fingerprints/MiniPlayerResponseModelSizeCheckFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/tabletminiplayer/fingerprints/MiniPlayerResponseModelSizeCheckFingerprint.kt similarity index 82% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/fingerprints/MiniPlayerResponseModelSizeCheckFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/tabletminiplayer/fingerprints/MiniPlayerResponseModelSizeCheckFingerprint.kt index d5df8fee9..91174168e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/fingerprints/MiniPlayerResponseModelSizeCheckFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/tabletminiplayer/fingerprints/MiniPlayerResponseModelSizeCheckFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.tabletminiplayer.fingerprints +package app.revanced.patches.youtube.general.tabletminiplayer.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint @@ -10,7 +10,6 @@ object MiniPlayerResponseModelSizeCheckFingerprint : MethodFingerprint( accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, parameters = listOf("L", "L"), opcodes = listOf( - Opcode.RETURN_OBJECT, Opcode.CHECK_CAST, Opcode.CHECK_CAST, Opcode.INVOKE_STATIC, diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/patch/TabletMiniPlayerPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/tabletminiplayer/patch/TabletMiniPlayerPatch.kt similarity index 83% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/patch/TabletMiniPlayerPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/general/tabletminiplayer/patch/TabletMiniPlayerPatch.kt index ebe4c8828..f2dfb8c7b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/patch/TabletMiniPlayerPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/tabletminiplayer/patch/TabletMiniPlayerPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.tabletminiplayer.patch +package app.revanced.patches.youtube.general.tabletminiplayer.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -17,9 +17,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.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.layout.general.tabletminiplayer.fingerprints.* -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 +import app.revanced.patches.youtube.general.tabletminiplayer.fingerprints.MiniPlayerResponseModelSizeCheckFingerprint +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.bytecode.getStringIndex import app.revanced.util.integrations.Constants.GENERAL import org.jf.dexlib2.Opcode @@ -61,7 +64,8 @@ class TabletMiniPlayerPatch : BytecodePatch( } } ?: return MiniPlayerOverrideFingerprint.toErrorResult() - MiniPlayerResponseModelSizeCheckFingerprint.result?.addProxyCall() ?: return MiniPlayerResponseModelSizeCheckFingerprint.toErrorResult() + MiniPlayerResponseModelSizeCheckFingerprint.result?.addProxyCall() + ?: return MiniPlayerResponseModelSizeCheckFingerprint.toErrorResult() /** * Add settings @@ -101,7 +105,7 @@ class TabletMiniPlayerPatch : BytecodePatch( val insertInstructions = this.implementation!!.instructions for ((index, instruction) in insertInstructions.withIndex()) { if (instruction.opcode != Opcode.RETURN) continue - val parameterRegister = getInstruction(index).registerA + val parameterRegister = this.getInstruction(index).registerA this.insertOverride(index, parameterRegister) this.insertOverride(insertInstructions.size - 1, parameterRegister) break diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/widesearchbar/fingerprints/SetActionBarRingoFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/widesearchbar/fingerprints/SetActionBarRingoFingerprint.kt new file mode 100644 index 000000000..bdd0a1c0a --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/general/widesearchbar/fingerprints/SetActionBarRingoFingerprint.kt @@ -0,0 +1,18 @@ +package app.revanced.patches.youtube.general.widesearchbar.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.ActionBarRingo +import app.revanced.util.bytecode.isWideLiteralExists +import org.jf.dexlib2.Opcode + +object SetActionBarRingoFingerprint : MethodFingerprint( + returnType = "L", + parameters = listOf("L", "L"), + opcodes = listOf( + Opcode.IF_NEZ, + Opcode.SGET_OBJECT, + Opcode.IGET_OBJECT, + Opcode.INVOKE_STATIC + ), + customFingerprint = { it, _ -> it.isWideLiteralExists(ActionBarRingo) } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/widesearchbar/fingerprints/SetToolBarPaddingFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/widesearchbar/fingerprints/SetToolBarPaddingFingerprint.kt new file mode 100644 index 000000000..793a7b13c --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/general/widesearchbar/fingerprints/SetToolBarPaddingFingerprint.kt @@ -0,0 +1,17 @@ +package app.revanced.patches.youtube.general.widesearchbar.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.ToolBarPaddingHome +import app.revanced.util.bytecode.isWideLiteralExists +import org.jf.dexlib2.Opcode + +object SetToolBarPaddingFingerprint : MethodFingerprint( + returnType = "V", + parameters = listOf("I", "I"), + opcodes = listOf( + Opcode.INVOKE_VIRTUAL, + Opcode.IGET_OBJECT, + Opcode.INVOKE_STATIC + ), + customFingerprint = { it, _ -> it.isWideLiteralExists(ToolBarPaddingHome) } +) \ No newline at end of file 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 new file mode 100644 index 000000000..ea748525d --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/general/widesearchbar/patch/WideSearchbarPatch.kt @@ -0,0 +1,101 @@ +package app.revanced.patches.youtube.general.widesearchbar.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.data.toMethodWalker +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +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.patcher.patch.annotations.Patch +import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod +import app.revanced.patches.shared.annotation.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 +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.GENERAL + +@Patch +@Name("enable-wide-searchbar") +@Description("Replaces the search icon with a wide search bar. This will hide the YouTube logo when active.") +@DependsOn( + [ + SettingsPatch::class, + SharedResourceIdPatch::class + ] +) +@YouTubeCompatibility +@Version("0.0.1") +class WideSearchbarPatch : BytecodePatch( + listOf( + SetActionBarRingoFingerprint, + SetToolBarPaddingFingerprint + ) +) { + override fun execute(context: BytecodeContext): PatchResult { + + arrayOf( + SetActionBarRingoFingerprint, + SetToolBarPaddingFingerprint + ).forEach { + it.injectHook(context) + } + + /** + * Set Wide SearchBar Start Margin + */ + contexts.xmlEditor[TARGET_RESOURCE_PATH].use { editor -> + val document = editor.file + + with(document.getElementsByTagName("RelativeLayout").item(0)) { + if (attributes.getNamedItem(FLAG) != null) return@with + + document.createAttribute(FLAG) + .apply { value = "8.0dip" } + .let(attributes::setNamedItem) + } + } + + /** + * Add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: GENERAL_SETTINGS", + "SETTINGS: ENABLE_WIDE_SEARCHBAR" + ) + ) + + SettingsPatch.updatePatchStatus("enable-wide-searchbar") + + return PatchResultSuccess() + } + + private companion object { + const val FLAG = "android:paddingStart" + const val TARGET_RESOURCE_PATH = "res/layout/action_bar_ringo_background.xml" + + fun MethodFingerprint.injectHook(context: BytecodeContext) { + result?.let { + (context + .toMethodWalker(it.method) + .nextMethod(it.scanResult.patternScanResult!!.endIndex, true) + .getMethod() as MutableMethod).apply { + addInstructions( + implementation!!.instructions.size - 1, """ + invoke-static {}, $GENERAL->enableWideSearchbar()Z + move-result p0 + """ + ) + } + } ?: throw toErrorResult() + } + } +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/branding/icon/patch/CustomBrandingIconMMTPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingIconMMTPatch.kt similarity index 87% rename from src/main/kotlin/app/revanced/patches/youtube/layout/etc/branding/icon/patch/CustomBrandingIconMMTPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingIconMMTPatch.kt index 148417433..95ef4a69a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/branding/icon/patch/CustomBrandingIconMMTPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingIconMMTPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.etc.branding.icon.patch +package app.revanced.patches.youtube.layout.branding.icon.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -10,7 +10,7 @@ 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.misc.settings.resource.patch.SettingsPatch +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/etc/branding/icon/patch/CustomBrandingIconRevancifyBluePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingIconRevancifyBluePatch.kt similarity index 88% rename from src/main/kotlin/app/revanced/patches/youtube/layout/etc/branding/icon/patch/CustomBrandingIconRevancifyBluePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingIconRevancifyBluePatch.kt index 06294cb75..5058aeef0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/branding/icon/patch/CustomBrandingIconRevancifyBluePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingIconRevancifyBluePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.etc.branding.icon.patch +package app.revanced.patches.youtube.layout.branding.icon.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -10,7 +10,7 @@ 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.misc.settings.resource.patch.SettingsPatch +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/etc/branding/icon/patch/CustomBrandingIconRevancifyRedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingIconRevancifyRedPatch.kt similarity index 88% rename from src/main/kotlin/app/revanced/patches/youtube/layout/etc/branding/icon/patch/CustomBrandingIconRevancifyRedPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingIconRevancifyRedPatch.kt index 0fbd9ae4f..3b0034876 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/branding/icon/patch/CustomBrandingIconRevancifyRedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingIconRevancifyRedPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.etc.branding.icon.patch +package app.revanced.patches.youtube.layout.branding.icon.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -10,7 +10,7 @@ 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.misc.settings.resource.patch.SettingsPatch +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/etc/branding/name/patch/CustomBrandingNamePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/name/patch/CustomBrandingNamePatch.kt similarity index 94% rename from src/main/kotlin/app/revanced/patches/youtube/layout/etc/branding/name/patch/CustomBrandingNamePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/branding/name/patch/CustomBrandingNamePatch.kt index d784bb469..a3d0223d1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/branding/name/patch/CustomBrandingNamePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/name/patch/CustomBrandingNamePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.etc.branding.name.patch +package app.revanced.patches.youtube.layout.branding.name.patch import app.revanced.extensions.startsWithAny import app.revanced.patcher.annotation.Description @@ -9,7 +9,7 @@ import app.revanced.patcher.patch.* 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.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.resources.ResourceHelper.updatePatchStatusLabel import org.w3c.dom.Element diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/doubletapbackground/patch/DoubleTapOverlayBackgroundPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/doubletapbackground/patch/DoubleTapOverlayBackgroundPatch.kt similarity index 93% rename from src/main/kotlin/app/revanced/patches/youtube/layout/etc/doubletapbackground/patch/DoubleTapOverlayBackgroundPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/doubletapbackground/patch/DoubleTapOverlayBackgroundPatch.kt index 75a18cf7d..81279fb26 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/doubletapbackground/patch/DoubleTapOverlayBackgroundPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/doubletapbackground/patch/DoubleTapOverlayBackgroundPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.etc.doubletapbackground.patch +package app.revanced.patches.youtube.layout.doubletapbackground.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -10,7 +10,7 @@ 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.misc.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch @Patch(false) @Name("hide-double-tap-overlay-filter") diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/doubletaplength/patch/DoubleTapLengthPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/doubletaplength/patch/DoubleTapLengthPatch.kt similarity index 94% rename from src/main/kotlin/app/revanced/patches/youtube/layout/etc/doubletaplength/patch/DoubleTapLengthPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/doubletaplength/patch/DoubleTapLengthPatch.kt index 3b02d835e..2ed31d7fc 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/doubletaplength/patch/DoubleTapLengthPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/doubletaplength/patch/DoubleTapLengthPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.etc.doubletaplength.patch +package app.revanced.patches.youtube.layout.doubletaplength.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -9,7 +9,7 @@ import app.revanced.patcher.patch.* 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.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.resources.ResourceHelper.addEntryValues import app.revanced.util.resources.ResourceUtils import app.revanced.util.resources.ResourceUtils.copyResources diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/forcebackground/patch/PlayerButtonBackgroundPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/forcebackground/patch/PlayerButtonBackgroundPatch.kt similarity index 92% rename from src/main/kotlin/app/revanced/patches/youtube/layout/etc/forcebackground/patch/PlayerButtonBackgroundPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/forcebackground/patch/PlayerButtonBackgroundPatch.kt index 72971cdaf..dc0091bd8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/forcebackground/patch/PlayerButtonBackgroundPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/forcebackground/patch/PlayerButtonBackgroundPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.etc.forcebackground.patch +package app.revanced.patches.youtube.layout.forcebackground.patch import app.revanced.extensions.doRecursively import app.revanced.patcher.annotation.Description @@ -11,7 +11,7 @@ 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.misc.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import org.w3c.dom.Element @Patch(false) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/forceheader/patch/PremiumHeadingPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/forceheader/patch/PremiumHeadingPatch.kt similarity index 94% rename from src/main/kotlin/app/revanced/patches/youtube/layout/etc/forceheader/patch/PremiumHeadingPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/forceheader/patch/PremiumHeadingPatch.kt index 6ddff8040..f7aa1d37c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/forceheader/patch/PremiumHeadingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/forceheader/patch/PremiumHeadingPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.etc.forceheader.patch +package app.revanced.patches.youtube.layout.forceheader.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -11,7 +11,7 @@ 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.misc.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import java.nio.file.Files import java.nio.file.StandardCopyOption import kotlin.io.path.exists diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/endscreenoverlay/fingerprints/EndScreenResultsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/endscreenoverlay/fingerprints/EndScreenResultsFingerprint.kt deleted file mode 100644 index faab943c3..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/endscreenoverlay/fingerprints/EndScreenResultsFingerprint.kt +++ /dev/null @@ -1,10 +0,0 @@ -package app.revanced.patches.youtube.layout.fullscreen.endscreenoverlay.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.appRelatedEndScreenResultsId -import app.revanced.util.bytecode.isWideLiteralExists - -object EndScreenResultsFingerprint : MethodFingerprint( - returnType = "V", - customFingerprint = { it, _ -> it.isWideLiteralExists(appRelatedEndScreenResultsId) } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/flimstripoverlay/fingerprints/ScrubbingLabelFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/flimstripoverlay/fingerprints/ScrubbingLabelFingerprint.kt deleted file mode 100644 index ef0806c09..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/flimstripoverlay/fingerprints/ScrubbingLabelFingerprint.kt +++ /dev/null @@ -1,14 +0,0 @@ -package app.revanced.patches.youtube.layout.fullscreen.flimstripoverlay.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.scrubbingId -import app.revanced.util.bytecode.isWideLiteralExists -import org.jf.dexlib2.Opcode - -object ScrubbingLabelFingerprint : MethodFingerprint( - opcodes = listOf( - Opcode.IPUT_BOOLEAN, - Opcode.CONST_WIDE_32 - ), - customFingerprint = { it, _ -> it.isWideLiteralExists(scrubbingId) } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/flimstripoverlay/patch/HideFilmstripOverlayPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/flimstripoverlay/patch/HideFilmstripOverlayPatch.kt deleted file mode 100644 index 1a01c7c15..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/flimstripoverlay/patch/HideFilmstripOverlayPatch.kt +++ /dev/null @@ -1,76 +0,0 @@ -package app.revanced.patches.youtube.layout.fullscreen.flimstripoverlay.patch - -import app.revanced.extensions.toErrorResult -import app.revanced.patcher.annotation.Description -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions -import app.revanced.patcher.extensions.InstructionExtensions.getInstruction -import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction -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.patcher.patch.annotations.Patch -import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.layout.fullscreen.flimstripoverlay.fingerprints.ScrubbingLabelFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.integrations.Constants.FULLSCREEN -import org.jf.dexlib2.iface.instruction.ReferenceInstruction -import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction - -@Patch -@Name("hide-filmstrip-overlay") -@Description("Hide flimstrip overlay on swipe controls.") -@DependsOn( - [ - SettingsPatch::class, - SharedResourceIdPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class HideFilmstripOverlayPatch : BytecodePatch( - listOf(ScrubbingLabelFingerprint) -) { - override fun execute(context: BytecodeContext): PatchResult { - - val result = ScrubbingLabelFingerprint.result?: return ScrubbingLabelFingerprint.toErrorResult() - - result.mutableMethod.hook(result.scanResult.patternScanResult!!.endIndex - 1) - - /** - * Add settings - */ - SettingsPatch.addPreference( - arrayOf( - "PREFERENCE: FULLSCREEN_SETTINGS", - "SETTINGS: HIDE_FILMSTRIP_OVERLAY" - ) - ) - - SettingsPatch.updatePatchStatus("hide-filmstrip-overlay") - - return PatchResultSuccess() - } - private companion object { - fun MutableMethod.hook(index: Int) { - val targetInstruction = getInstruction(index) - val fieldReference = getInstruction(index).reference - replaceInstruction( - index, - "invoke-static {v${targetInstruction.registerA}}, $FULLSCREEN->hideFilmstripOverlay(Z)Z" - ) - - addInstructions( - index + 1, """ - move-result v${targetInstruction.registerA} - iput-boolean v${targetInstruction.registerA}, v${targetInstruction.registerB}, $fieldReference - """ - ) - } - } -} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/fingerprints/SeekHapticsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/fingerprints/SeekHapticsFingerprint.kt deleted file mode 100644 index 814b4b3c6..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/fingerprints/SeekHapticsFingerprint.kt +++ /dev/null @@ -1,14 +0,0 @@ -package app.revanced.patches.youtube.layout.fullscreen.hapticfeedback.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import org.jf.dexlib2.Opcode - -object SeekHapticsFingerprint : MethodFingerprint( - opcodes = listOf( - Opcode.CHECK_CAST, - Opcode.CHECK_CAST, - Opcode.INVOKE_VIRTUAL, - Opcode.RETURN_VOID - ), - strings = listOf("Failed to easy seek haptics vibrate.") -) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/patch/HapticFeedBackPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/patch/HapticFeedBackPatch.kt deleted file mode 100644 index 858d49819..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/patch/HapticFeedBackPatch.kt +++ /dev/null @@ -1,118 +0,0 @@ -package app.revanced.patches.youtube.layout.fullscreen.hapticfeedback.patch - -import app.revanced.extensions.toErrorResult -import app.revanced.patcher.annotation.Description -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels -import app.revanced.patcher.extensions.InstructionExtensions.getInstruction -import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult -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.patcher.patch.annotations.Patch -import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.layout.fullscreen.hapticfeedback.fingerprints.MarkerHapticsFingerprint -import app.revanced.patches.youtube.layout.fullscreen.hapticfeedback.fingerprints.ScrubbingHapticsFingerprint -import app.revanced.patches.youtube.layout.fullscreen.hapticfeedback.fingerprints.SeekHapticsFingerprint -import app.revanced.patches.youtube.layout.fullscreen.hapticfeedback.fingerprints.ZoomHapticsFingerprint -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.integrations.Constants.FULLSCREEN -import org.jf.dexlib2.iface.instruction.OneRegisterInstruction - -@Patch -@Name("disable-haptic-feedback") -@Description("Disable haptic feedback when swiping.") -@DependsOn([SettingsPatch::class]) -@YouTubeCompatibility -@Version("0.0.1") -class HapticFeedBackPatch : BytecodePatch( - listOf( - MarkerHapticsFingerprint, - SeekHapticsFingerprint, - ScrubbingHapticsFingerprint, - ZoomHapticsFingerprint - ) -) { - override fun execute(context: BytecodeContext): PatchResult { - - arrayOf( - SeekHapticsFingerprint to "disableSeekVibrate", - ScrubbingHapticsFingerprint to "disableScrubbingVibrate", - MarkerHapticsFingerprint to "disableChapterVibrate", - ZoomHapticsFingerprint to "disableZoomVibrate" - ).map { (fingerprint, name) -> - fingerprint.result?.let { - if (fingerprint == SeekHapticsFingerprint) - it.disableHaptics(name) - else - it.voidHaptics(name) - } ?: return fingerprint.toErrorResult() - } - - /** - * Add settings - */ - SettingsPatch.addPreference( - arrayOf( - "PREFERENCE: FULLSCREEN_SETTINGS", - "SETTINGS: DISABLE_HAPTIC_FEEDBACK" - ) - ) - - SettingsPatch.updatePatchStatus("disable-haptic-feedback") - - return PatchResultSuccess() - } - - private companion object { - fun MethodFingerprintResult.disableHaptics(targetMethodName: String) { - mutableMethod.apply { - val startIndex = scanResult.patternScanResult!!.startIndex - val endIndex = scanResult.patternScanResult!!.endIndex - val insertIndex = endIndex + 4 - val targetRegister = getInstruction(insertIndex).registerA - val dummyRegister = targetRegister + 1 - - removeInstruction(insertIndex) - - addInstructionsWithLabels( - insertIndex, """ - invoke-static {}, $FULLSCREEN->$targetMethodName()Z - move-result v$dummyRegister - if-eqz v$dummyRegister, :vibrate - const-wide/16 v$targetRegister, 0x0 - goto :exit - :vibrate - const-wide/16 v$targetRegister, 0x19 - """, ExternalLabel("exit", getInstruction(insertIndex)) - ) - - addInstructionsWithLabels( - startIndex, """ - invoke-static {}, $FULLSCREEN->$targetMethodName()Z - move-result v$dummyRegister - if-eqz v$dummyRegister, :vibrate - return-void - """, ExternalLabel("vibrate", getInstruction(startIndex)) - ) - } - } - - fun MethodFingerprintResult.voidHaptics(targetMethodName: String) { - mutableMethod.addInstructionsWithLabels( - 0, """ - invoke-static {}, $FULLSCREEN->$targetMethodName()Z - move-result v0 - if-eqz v0, :vibrate - return-void - """, ExternalLabel("vibrate", mutableMethod.getInstruction(0)) - ) - } - } -} - diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/seekmessage/fingerprints/SeekEduContainerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/seekmessage/fingerprints/SeekEduContainerFingerprint.kt deleted file mode 100644 index 6e37f70a7..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/seekmessage/fingerprints/SeekEduContainerFingerprint.kt +++ /dev/null @@ -1,10 +0,0 @@ -package app.revanced.patches.youtube.layout.fullscreen.seekmessage.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.easySeekEduContainerId -import app.revanced.util.bytecode.isWideLiteralExists - -object SeekEduContainerFingerprint : MethodFingerprint( - returnType = "V", - customFingerprint = { it, _ -> it.isWideLiteralExists(easySeekEduContainerId) } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/categorybar/patch/CategoryBarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/categorybar/patch/CategoryBarPatch.kt deleted file mode 100644 index 4cc722d34..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/categorybar/patch/CategoryBarPatch.kt +++ /dev/null @@ -1,110 +0,0 @@ -package app.revanced.patches.youtube.layout.general.categorybar.patch - -import app.revanced.extensions.toErrorResult -import app.revanced.patcher.annotation.Description -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstruction -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions -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.patcher.patch.annotations.DependsOn -import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.layout.general.categorybar.fingerprints.FilterBarHeightFingerprint -import app.revanced.patches.youtube.layout.general.categorybar.fingerprints.RelatedChipCloudFingerprint -import app.revanced.patches.youtube.layout.general.categorybar.fingerprints.SearchResultsChipBarFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.integrations.Constants.GENERAL -import org.jf.dexlib2.iface.instruction.OneRegisterInstruction -import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction - -@Patch -@Name("hide-category-bar") -@Description("Hide the category bar at the top of the feed and at the top of related videos.") -@DependsOn( - [ - SettingsPatch::class, - SharedResourceIdPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class CategoryBarPatch : BytecodePatch( - listOf( - FilterBarHeightFingerprint, - RelatedChipCloudFingerprint, - SearchResultsChipBarFingerprint - ) -) { - override fun execute(context: BytecodeContext): PatchResult { - - /** - * Category Bar in feed - * Home feed and subscriptions feed - */ - FilterBarHeightFingerprint.result?.let { - it.mutableMethod.apply { - val insertIndex = it.scanResult.patternScanResult!!.endIndex - val register = getInstruction(insertIndex).registerA - - addInstructions( - insertIndex, """ - invoke-static {v$register}, $GENERAL->hideCategoryBarInFeed(I)I - move-result v$register - """ - ) - } - } ?: return FilterBarHeightFingerprint.toErrorResult() - - /** - * Category Bar in related video - */ - RelatedChipCloudFingerprint.result?.let { - it.mutableMethod.apply { - val insertIndex = it.scanResult.patternScanResult!!.endIndex - val register = getInstruction(insertIndex).registerA - - addInstruction( - insertIndex + 1, - "invoke-static {v$register}, $GENERAL->hideCategoryBarInRelatedVideo(Landroid/view/View;)V" - ) - } - } ?: return RelatedChipCloudFingerprint.toErrorResult() - - /** - * Category Bar in search results - */ - SearchResultsChipBarFingerprint.result?.let { - it.mutableMethod.apply { - val targetIndex = it.scanResult.patternScanResult!!.endIndex - 2 - val register = getInstruction(targetIndex).registerA - - addInstructions( - targetIndex + 1, """ - invoke-static {v$register}, $GENERAL->hideCategoryBarInSearchResults(I)I - move-result v$register - """ - ) - } - } ?: return SearchResultsChipBarFingerprint.toErrorResult() - - /** - * Add settings - */ - SettingsPatch.addPreference( - arrayOf( - "PREFERENCE: GENERAL_SETTINGS", - "SETTINGS: HIDE_CATEGORY_BAR" - ) - ) - - SettingsPatch.updatePatchStatus("hide-category-bar") - - return PatchResultSuccess() - } -} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/headerswitch/patch/HeaderSwitchPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/headerswitch/patch/HeaderSwitchPatch.kt deleted file mode 100644 index bab907a5a..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/headerswitch/patch/HeaderSwitchPatch.kt +++ /dev/null @@ -1,95 +0,0 @@ -package app.revanced.patches.youtube.layout.general.headerswitch.patch - -import app.revanced.extensions.findMutableMethodOf -import app.revanced.patcher.annotation.Description -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions -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.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.integrations.Constants.GENERAL -import org.jf.dexlib2.Opcode -import org.jf.dexlib2.iface.instruction.formats.Instruction31i - -@Patch -@Name("header-switch") -@Description("Add switch to change header.") -@DependsOn( - [ - ResourceMappingPatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class HeaderSwitchPatch : BytecodePatch() { - - // list of resource names to get the id of - private val resourceIds = arrayOf( - "ytWordmarkHeader" - ).map { name -> - ResourceMappingPatch.resourceMappings.single { it.name == name }.id - } - private var patchSuccessArray = Array(resourceIds.size) {false} - - override fun execute(context: BytecodeContext): PatchResult { - context.classes.forEach { classDef -> - classDef.methods.forEach { method -> - with(method.implementation) { - this?.instructions?.forEachIndexed { index, instruction -> - when (instruction.opcode) { - Opcode.CONST -> { - when ((instruction as Instruction31i).wideLiteral) { - resourceIds[0] -> { // header - val insertIndex = index + 1 - - val mutableMethod = context.proxy(classDef).mutableClass.findMutableMethodOf(method) - - val viewRegister = (instructions.elementAt(index) as Instruction31i).registerA - - mutableMethod.addInstructions( - insertIndex, """ - invoke-static {v$viewRegister}, $GENERAL->enablePremiumHeader(I)I - move-result v$viewRegister - """ - ) - - patchSuccessArray[0] = true - } - } - } - else -> return@forEachIndexed - } - } - } - } - } - - val errorIndex: Int = patchSuccessArray.indexOf(false) - - if (errorIndex == -1) { - /** - * Add settings - */ - SettingsPatch.addPreference( - arrayOf( - "PREFERENCE: GENERAL_SETTINGS", - "SETTINGS: HEADER_SWITCH" - ) - ) - - SettingsPatch.updatePatchStatus("header-switch") - - return PatchResultSuccess() - } else - return PatchResultError("Instruction not found: $errorIndex") - } -} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/searchterms/fingerprints/SearchSuggestionEntryFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/searchterms/fingerprints/SearchSuggestionEntryFingerprint.kt deleted file mode 100644 index 4e5ea5373..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/searchterms/fingerprints/SearchSuggestionEntryFingerprint.kt +++ /dev/null @@ -1,9 +0,0 @@ -package app.revanced.patches.youtube.layout.general.searchterms.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.searchSuggestionEntryId -import app.revanced.util.bytecode.isWideLiteralExists - -object SearchSuggestionEntryFingerprint : MethodFingerprint( - customFingerprint = { it, _ -> it.isWideLiteralExists(searchSuggestionEntryId) } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/bytecode/fingerprints/WideSearchbarOneFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/bytecode/fingerprints/WideSearchbarOneFingerprint.kt deleted file mode 100644 index 03116ddc2..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/bytecode/fingerprints/WideSearchbarOneFingerprint.kt +++ /dev/null @@ -1,18 +0,0 @@ -package app.revanced.patches.youtube.layout.general.widesearchbar.bytecode.fingerprints - -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 WideSearchbarOneFingerprint : MethodFingerprint( - returnType = "L", - accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, - parameters = listOf("L", "L"), - opcodes = listOf( - Opcode.IF_NEZ, - Opcode.SGET_OBJECT, - Opcode.IGET_OBJECT, - Opcode.INVOKE_STATIC - ) -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/bytecode/fingerprints/WideSearchbarOneParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/bytecode/fingerprints/WideSearchbarOneParentFingerprint.kt deleted file mode 100644 index 694785664..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/bytecode/fingerprints/WideSearchbarOneParentFingerprint.kt +++ /dev/null @@ -1,15 +0,0 @@ -package app.revanced.patches.youtube.layout.general.widesearchbar.bytecode.fingerprints - -import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import org.jf.dexlib2.AccessFlags - -object WideSearchbarOneParentFingerprint : MethodFingerprint( - returnType = "V", accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL, - parameters = listOf("L"), - strings = listOf( - "FEhistory", - "FEmy_videos", - "FEpurchases" - ) -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/bytecode/fingerprints/WideSearchbarTwoFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/bytecode/fingerprints/WideSearchbarTwoFingerprint.kt deleted file mode 100644 index 9bb402c26..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/bytecode/fingerprints/WideSearchbarTwoFingerprint.kt +++ /dev/null @@ -1,17 +0,0 @@ -package app.revanced.patches.youtube.layout.general.widesearchbar.bytecode.fingerprints - -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 WideSearchbarTwoFingerprint : MethodFingerprint( - returnType = "L", - accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC, - opcodes = listOf( - Opcode.INVOKE_STATIC, - Opcode.MOVE_RESULT, - Opcode.IF_EQZ, - Opcode.NEW_INSTANCE - ) -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/bytecode/fingerprints/WideSearchbarTwoParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/bytecode/fingerprints/WideSearchbarTwoParentFingerprint.kt deleted file mode 100644 index 251be30bb..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/bytecode/fingerprints/WideSearchbarTwoParentFingerprint.kt +++ /dev/null @@ -1,14 +0,0 @@ -package app.revanced.patches.youtube.layout.general.widesearchbar.bytecode.fingerprints - -import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import org.jf.dexlib2.AccessFlags - -object WideSearchbarTwoParentFingerprint : MethodFingerprint( - returnType = "L", - accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC, - strings = listOf( - "Callback already registered.", - "Failed to create SpotlightModeController." - ) -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/bytecode/patch/WideSearchbarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/bytecode/patch/WideSearchbarPatch.kt deleted file mode 100644 index a8f03f907..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/bytecode/patch/WideSearchbarPatch.kt +++ /dev/null @@ -1,85 +0,0 @@ -package app.revanced.patches.youtube.layout.general.widesearchbar.bytecode.patch - -import app.revanced.extensions.toErrorResult -import app.revanced.patcher.annotation.Description -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.data.toMethodWalker -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions -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.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.layout.general.widesearchbar.bytecode.fingerprints.* -import app.revanced.patches.youtube.layout.general.widesearchbar.resource.patch.WideSearchbarResourcePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.integrations.Constants.GENERAL - -@Patch -@Name("enable-wide-searchbar") -@Description("Replaces the search icon with a wide search bar. This will hide the YouTube logo when active.") -@DependsOn( - [ - SettingsPatch::class, - WideSearchbarResourcePatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class WideSearchbarPatch : BytecodePatch( - listOf( - WideSearchbarOneParentFingerprint, - WideSearchbarTwoParentFingerprint - ) -) { - override fun execute(context: BytecodeContext): PatchResult { - - arrayOf( - WideSearchbarOneParentFingerprint to WideSearchbarOneFingerprint, - WideSearchbarTwoParentFingerprint to WideSearchbarTwoFingerprint - ).map { (parentFingerprint, fingerprint) -> - parentFingerprint.result?.classDef?.let { classDef -> - fingerprint.also { it.resolve(context, classDef) }.result?.let { - val index = if (fingerprint == WideSearchbarOneFingerprint) it.scanResult.patternScanResult!!.endIndex - else it.scanResult.patternScanResult!!.startIndex - - val targetMethod = - context - .toMethodWalker(it.method) - .nextMethod(index, true) - .getMethod() as MutableMethod - - targetMethod.injectSearchBarHook() - } ?: return fingerprint.toErrorResult() - } ?: return parentFingerprint.toErrorResult() - } - - /** - * Add settings - */ - SettingsPatch.addPreference( - arrayOf( - "PREFERENCE: GENERAL_SETTINGS", - "SETTINGS: ENABLE_WIDE_SEARCHBAR" - ) - ) - - SettingsPatch.updatePatchStatus("enable-wide-searchbar") - - return PatchResultSuccess() - } - - private fun MutableMethod.injectSearchBarHook() { - addInstructions( - implementation!!.instructions.size - 1, """ - invoke-static {}, $GENERAL->enableWideSearchbar()Z - move-result p0 - """ - ) - } -} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/resource/patch/WideSearchbarResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/resource/patch/WideSearchbarResourcePatch.kt deleted file mode 100644 index 3a0b669d1..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/resource/patch/WideSearchbarResourcePatch.kt +++ /dev/null @@ -1,35 +0,0 @@ -package app.revanced.patches.youtube.layout.general.widesearchbar.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.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -import app.revanced.patches.shared.annotation.YouTubeCompatibility - -@Name("enable-wide-searchbar-resource-patch") -@YouTubeCompatibility -@Version("0.0.1") -class WideSearchbarResourcePatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - context.xmlEditor["res/layout/action_bar_ringo_background.xml"].use { editor -> - val document = editor.file - - with(document.getElementsByTagName("RelativeLayout").item(0)) { - if (attributes.getNamedItem(FLAG) != null) return@with - - document.createAttribute(FLAG) - .apply { value = "8.0dip" } - .let(attributes::setNamedItem) - - } - } - - return PatchResultSuccess() - } - - private companion object { - const val FLAG = "android:paddingStart" - } -} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/materialyou/patch/MaterialYouPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/materialyou/patch/MaterialYouPatch.kt similarity index 85% rename from src/main/kotlin/app/revanced/patches/youtube/layout/etc/materialyou/patch/MaterialYouPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/materialyou/patch/MaterialYouPatch.kt index 8e4dd4c17..3cfc33eee 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/materialyou/patch/MaterialYouPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/materialyou/patch/MaterialYouPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.etc.materialyou.patch +package app.revanced.patches.youtube.layout.materialyou.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -10,9 +10,9 @@ 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.layout.etc.theme.patch.GeneralThemePatch -import app.revanced.patches.youtube.layout.etc.theme.patch.GeneralThemePatch.Companion.isMonetPatchIncluded -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 import app.revanced.util.resources.ResourceHelper.updatePatchStatusTheme import app.revanced.util.resources.ResourceUtils import app.revanced.util.resources.ResourceUtils.copyResources diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/optimize/patch/OptimizeResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/optimize/patch/OptimizeResourcePatch.kt similarity index 87% rename from src/main/kotlin/app/revanced/patches/youtube/layout/etc/optimize/patch/OptimizeResourcePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/optimize/patch/OptimizeResourcePatch.kt index 1b86597a8..74f9f3362 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/optimize/patch/OptimizeResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/optimize/patch/OptimizeResourcePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.etc.optimize.patch +package app.revanced.patches.youtube.layout.optimize.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -10,7 +10,7 @@ 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.misc.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch @Patch @Name("optimize-resource") diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/optimize/patch/RedundantResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/optimize/patch/RedundantResourcePatch.kt similarity index 99% rename from src/main/kotlin/app/revanced/patches/youtube/layout/etc/optimize/patch/RedundantResourcePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/optimize/patch/RedundantResourcePatch.kt index f87e065b3..8342744f9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/optimize/patch/RedundantResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/optimize/patch/RedundantResourcePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.etc.optimize.patch +package app.revanced.patches.youtube.layout.optimize.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/pipnotification/fingerprints/PrimaryPiPFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/pipnotification/fingerprints/PrimaryPiPFingerprint.kt similarity index 88% rename from src/main/kotlin/app/revanced/patches/youtube/layout/etc/pipnotification/fingerprints/PrimaryPiPFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/pipnotification/fingerprints/PrimaryPiPFingerprint.kt index e591f62ba..d7609c618 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/pipnotification/fingerprints/PrimaryPiPFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/pipnotification/fingerprints/PrimaryPiPFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.etc.pipnotification.fingerprints +package app.revanced.patches.youtube.layout.pipnotification.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/pipnotification/fingerprints/SecondaryPiPFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/pipnotification/fingerprints/SecondaryPiPFingerprint.kt similarity index 74% rename from src/main/kotlin/app/revanced/patches/youtube/layout/etc/pipnotification/fingerprints/SecondaryPiPFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/pipnotification/fingerprints/SecondaryPiPFingerprint.kt index 2b5cec9c4..f840ffdfc 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/pipnotification/fingerprints/SecondaryPiPFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/pipnotification/fingerprints/SecondaryPiPFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.etc.pipnotification.fingerprints +package app.revanced.patches.youtube.layout.pipnotification.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint @@ -10,11 +10,11 @@ object SecondaryPiPFingerprint : MethodFingerprint( accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, parameters = listOf("L"), opcodes = listOf( + null, + Opcode.CHECK_CAST, Opcode.IGET_OBJECT, - Opcode.CHECK_CAST, - Opcode.INVOKE_VIRTUAL, - Opcode.CHECK_CAST, - Opcode.IGET_OBJECT + Opcode.IF_EQZ, + Opcode.INVOKE_VIRTUAL ), strings = listOf("honeycomb.Shell\$HomeActivity") ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/pipnotification/patch/PiPNotificationPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/pipnotification/patch/PiPNotificationPatch.kt similarity index 64% rename from src/main/kotlin/app/revanced/patches/youtube/layout/etc/pipnotification/patch/PiPNotificationPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/pipnotification/patch/PiPNotificationPatch.kt index 693d7f0ad..504b2e09e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/pipnotification/patch/PiPNotificationPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/pipnotification/patch/PiPNotificationPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.etc.pipnotification.patch +package app.revanced.patches.youtube.layout.pipnotification.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -12,8 +12,9 @@ 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.layout.etc.pipnotification.fingerprints.* -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 @Patch @Name("hide-pip-notification") @@ -32,14 +33,18 @@ class PiPNotificationPatch : BytecodePatch( arrayOf( PrimaryPiPFingerprint, SecondaryPiPFingerprint - ).map { - it.result ?: return it.toErrorResult() - }.forEach { - val index = it.scanResult.patternScanResult!!.startIndex + 1 - it.mutableMethod.addInstruction(index, "return-void") + ).forEach { fingerprint -> + fingerprint.result?.let { + it.mutableMethod.apply { + addInstruction( + it.scanResult.patternScanResult!!.endIndex - 4, + "return-void" + ) + } + } ?: return fingerprint.toErrorResult() } - /* + /** * Add settings */ SettingsPatch.updatePatchStatus("hide-pip-notification") diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/infocards/patch/HideInfocardsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/infocards/patch/HideInfocardsPatch.kt deleted file mode 100644 index 092e276d1..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/infocards/patch/HideInfocardsPatch.kt +++ /dev/null @@ -1,57 +0,0 @@ -package app.revanced.patches.youtube.layout.player.infocards.patch - -import app.revanced.extensions.toErrorResult -import app.revanced.patcher.annotation.Description -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions -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.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.layout.player.infocards.fingerprints.InfocardsIncognitoFingerprint -import app.revanced.patches.youtube.layout.player.infocards.fingerprints.InfocardsIncognitoParentFingerprint -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.integrations.Constants.PLAYER - -@Patch -@Name("hide-info-cards") -@Description("Hides info-cards in videos.") -@DependsOn([SettingsPatch::class]) -@YouTubeCompatibility -@Version("0.0.1") -class HideInfocardsPatch : BytecodePatch( - listOf(InfocardsIncognitoParentFingerprint) -) { - override fun execute(context: BytecodeContext): PatchResult { - InfocardsIncognitoParentFingerprint.result?.classDef?.let { classDef -> - InfocardsIncognitoFingerprint.also { - it.resolve(context, classDef) - }.result?.mutableMethod?. - addInstructions( - 1, """ - invoke-static {v0}, $PLAYER->hideInfoCard(Z)Z - move-result v0 - """ - ) ?: return InfocardsIncognitoFingerprint.toErrorResult() - } ?: return InfocardsIncognitoParentFingerprint.toErrorResult() - - /** - * Add settings - */ - SettingsPatch.addPreference( - arrayOf( - "PREFERENCE: PLAYER_SETTINGS", - "SETTINGS: HIDE_INFO_CARDS" - ) - ) - - SettingsPatch.updatePatchStatus("hide-info-cards") - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/playerbuttonbg/fingerprints/HidePlayerButtonFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/playerbuttonbg/fingerprints/HidePlayerButtonFingerprint.kt deleted file mode 100644 index a8c5e16aa..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/playerbuttonbg/fingerprints/HidePlayerButtonFingerprint.kt +++ /dev/null @@ -1,10 +0,0 @@ -package app.revanced.patches.youtube.layout.player.playerbuttonbg.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint - -object HidePlayerButtonFingerprint : MethodFingerprint ( - customFingerprint = { it, _ -> - it.definingClass == "Lapp/revanced/integrations/patches/layout/PlayerPatch;" - && it.name == "hidePlayerButton" - } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/playeroverlayfilter/fingerprints/ScrimOverlayFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/playeroverlayfilter/fingerprints/ScrimOverlayFingerprint.kt deleted file mode 100644 index 0ef4b872c..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/playeroverlayfilter/fingerprints/ScrimOverlayFingerprint.kt +++ /dev/null @@ -1,9 +0,0 @@ -package app.revanced.patches.youtube.layout.player.playeroverlayfilter.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.scrimOverlayId -import app.revanced.util.bytecode.isWideLiteralExists - -object ScrimOverlayFingerprint : MethodFingerprint( - customFingerprint = { it, _ -> it.definingClass.endsWith("YouTubeControlsOverlay;") && it.isWideLiteralExists(scrimOverlayId) } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/previousnextbutton/fingerprints/SupportsNextPreviousFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/previousnextbutton/fingerprints/SupportsNextPreviousFingerprint.kt deleted file mode 100644 index b179bfb17..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/previousnextbutton/fingerprints/SupportsNextPreviousFingerprint.kt +++ /dev/null @@ -1,16 +0,0 @@ -package app.revanced.patches.youtube.layout.player.previousnextbutton.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import org.jf.dexlib2.Opcode -import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction - -object SupportsNextPreviousFingerprint : MethodFingerprint( - returnType = "V", - parameters = listOf("Z"), - opcodes = listOf(Opcode.OR_INT_LIT8), - customFingerprint = { methodDef, _ -> - methodDef.implementation!!.instructions.any { - ((it as? NarrowLiteralInstruction)?.narrowLiteral == 64) - } - } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/previousnextbutton/patch/HidePreviousNextButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/previousnextbutton/patch/HidePreviousNextButtonPatch.kt deleted file mode 100644 index adbb84b43..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/previousnextbutton/patch/HidePreviousNextButtonPatch.kt +++ /dev/null @@ -1,55 +0,0 @@ -package app.revanced.patches.youtube.layout.player.previousnextbutton.patch - -import app.revanced.extensions.toErrorResult -import app.revanced.patcher.annotation.Description -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions -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.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.ControlsOverlayStyleFingerprint -import app.revanced.patches.youtube.layout.player.previousnextbutton.fingerprints.SupportsNextPreviousFingerprint -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.integrations.Constants.PLAYER - -@Patch -@Name("hide-previous-next-button") -@Description("Hides the previous and next button in the player controller.") -@DependsOn([SettingsPatch::class]) -@YouTubeCompatibility -@Version("0.0.1") -class HidePreviousNextButtonPatch : BytecodePatch( - listOf(ControlsOverlayStyleFingerprint) -) { - override fun execute(context: BytecodeContext): PatchResult { - - ControlsOverlayStyleFingerprint.result?.let { parentResult -> - SupportsNextPreviousFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.addInstructions( - 0, """ - invoke-static {p1}, $PLAYER->hidePreviousNextButton(Z)Z - move-result p1 - """ - ) ?: return SupportsNextPreviousFingerprint.toErrorResult() - } ?: return ControlsOverlayStyleFingerprint.toErrorResult() - - /** - * Add settings - */ - SettingsPatch.addPreference( - arrayOf( - "PREFERENCE: PLAYER_SETTINGS", - "SETTINGS: HIDE_PREVIOUS_NEXT_BUTTON" - ) - ) - - SettingsPatch.updatePatchStatus("hide-previous-next-button") - - return PatchResultSuccess() - } -} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbar/patch/HideSeekbarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbar/patch/HideSeekbarPatch.kt deleted file mode 100644 index a826c1608..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbar/patch/HideSeekbarPatch.kt +++ /dev/null @@ -1,59 +0,0 @@ -package app.revanced.patches.youtube.layout.seekbar.seekbar.patch - -import app.revanced.patcher.annotation.Description -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels -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.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.misc.settings.resource.patch.SettingsPatch -import app.revanced.patches.youtube.misc.timebar.patch.HookTimeBarPatch -import app.revanced.util.integrations.Constants.SEEKBAR - -@Patch -@Name("hide-seekbar") -@Description("Hides the seekbar and progressbar.") -@DependsOn( - [ - HookTimeBarPatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class HideSeekbarPatch : BytecodePatch() { - override fun execute(context: BytecodeContext): PatchResult { - - val insertMethod = HookTimeBarPatch.setTimeBarMethod - - insertMethod.addInstructionsWithLabels( - 0, """ - invoke-static {}, $SEEKBAR->hideSeekbar()Z - move-result v0 - if-eqz v0, :show_seekbar - return-void - """, ExternalLabel("show_seekbar", insertMethod.getInstruction(0)) - ) - - /** - * Add settings - */ - SettingsPatch.addPreference( - arrayOf( - "PREFERENCE: SEEKBAR_SETTINGS", - "SETTINGS: HIDE_SEEKBAR" - ) - ) - - SettingsPatch.updatePatchStatus("hide-seekbar") - - return PatchResultSuccess() - } -} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/bytecode/fingerprints/ControlsOverlayFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/bytecode/fingerprints/ControlsOverlayFingerprint.kt deleted file mode 100644 index e2f45b406..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/bytecode/fingerprints/ControlsOverlayFingerprint.kt +++ /dev/null @@ -1,8 +0,0 @@ -package app.revanced.patches.youtube.layout.seekbar.seekbarcolor.bytecode.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint - -object ControlsOverlayFingerprint : MethodFingerprint( - returnType = "V", - customFingerprint = { it, _ -> it.name == ""} -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/bytecode/fingerprints/ControlsOverlayParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/bytecode/fingerprints/ControlsOverlayParentFingerprint.kt deleted file mode 100644 index cf2134c38..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/bytecode/fingerprints/ControlsOverlayParentFingerprint.kt +++ /dev/null @@ -1,11 +0,0 @@ -package app.revanced.patches.youtube.layout.seekbar.seekbarcolor.bytecode.fingerprints - -import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import org.jf.dexlib2.AccessFlags - -object ControlsOverlayParentFingerprint : MethodFingerprint( - returnType = "V", - accessFlags = AccessFlags.PRIVATE or AccessFlags.STATIC or AccessFlags.FINAL, - strings = listOf("Error screen presenter should be present") -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/bytecode/fingerprints/SeekbarColorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/bytecode/fingerprints/SeekbarColorFingerprint.kt deleted file mode 100644 index cbe1a3040..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/bytecode/fingerprints/SeekbarColorFingerprint.kt +++ /dev/null @@ -1,9 +0,0 @@ -package app.revanced.patches.youtube.layout.seekbar.seekbarcolor.bytecode.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.inlineTimeBarColorizedBarPlayedColorDarkId -import app.revanced.util.bytecode.isWideLiteralExists - -object SeekbarColorFingerprint : MethodFingerprint( - customFingerprint = { it, _ -> it.isWideLiteralExists(inlineTimeBarColorizedBarPlayedColorDarkId) } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbartapping/fingerprints/SeekbarTappingFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbartapping/fingerprints/SeekbarTappingFingerprint.kt deleted file mode 100644 index 3d2c3c8ca..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbartapping/fingerprints/SeekbarTappingFingerprint.kt +++ /dev/null @@ -1,21 +0,0 @@ -package app.revanced.patches.youtube.layout.seekbar.seekbartapping.fingerprints - -import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.util.bytecode.isNarrowLiteralExists -import org.jf.dexlib2.AccessFlags -import org.jf.dexlib2.Opcode - -object SeekbarTappingFingerprint : MethodFingerprint( - returnType = "Z", - accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, - parameters = listOf("L"), - opcodes = listOf( - Opcode.NEW_INSTANCE, - Opcode.INVOKE_DIRECT, - Opcode.IPUT_OBJECT, - Opcode.INVOKE_VIRTUAL, - Opcode.RETURN - ), - customFingerprint = { it, _ -> it.name == "onTouchEvent" && it.isNarrowLiteralExists(2147483647) } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbartapping/fingerprints/SeekbarTappingParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbartapping/fingerprints/SeekbarTappingParentFingerprint.kt deleted file mode 100644 index 0db0cfdb2..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbartapping/fingerprints/SeekbarTappingParentFingerprint.kt +++ /dev/null @@ -1,13 +0,0 @@ -package app.revanced.patches.youtube.layout.seekbar.seekbartapping.fingerprints - -import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.accessibilityProgressTimeId -import app.revanced.util.bytecode.isWideLiteralExists -import org.jf.dexlib2.AccessFlags - -object SeekbarTappingParentFingerprint : MethodFingerprint( - returnType = "L", - accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, - customFingerprint = { it, _ -> it.isWideLiteralExists(accessibilityProgressTimeId)} -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbartapping/patch/SeekbarTappingPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbartapping/patch/SeekbarTappingPatch.kt deleted file mode 100644 index de5f85de4..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbartapping/patch/SeekbarTappingPatch.kt +++ /dev/null @@ -1,103 +0,0 @@ -package app.revanced.patches.youtube.layout.seekbar.seekbartapping.patch - -import app.revanced.extensions.toErrorResult -import app.revanced.patcher.annotation.Description -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels -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.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.layout.seekbar.seekbartapping.fingerprints.SeekbarTappingFingerprint -import app.revanced.patches.youtube.layout.seekbar.seekbartapping.fingerprints.SeekbarTappingParentFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.integrations.Constants.SEEKBAR -import org.jf.dexlib2.Opcode -import org.jf.dexlib2.iface.Method -import org.jf.dexlib2.iface.instruction.formats.Instruction11n -import org.jf.dexlib2.iface.instruction.formats.Instruction35c - -@Patch -@Name("enable-seekbar-tapping") -@Description("Enables tap-to-seek on the seekbar of the video player.") -@DependsOn( - [ - SettingsPatch::class, - SharedResourceIdPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class SeekbarTappingPatch : BytecodePatch( - listOf( - SeekbarTappingParentFingerprint, - SeekbarTappingFingerprint - ) -) { - override fun execute(context: BytecodeContext): PatchResult { - val tapSeekMethods = mutableMapOf() - - SeekbarTappingParentFingerprint.result?.let { parentResult -> - for (it in parentResult.classDef.methods) { - if (it.implementation == null) continue - - val instructions = it.implementation!!.instructions - // here we make sure we actually find the method because it has more than 7 instructions - if (instructions.count() < 7) continue - - // we know that the 7th instruction has the opcode CONST_4 - val instruction = instructions.elementAt(6) - if (instruction.opcode != Opcode.CONST_4) continue - - // the literal for this instruction has to be either 1 or 2 - val literal = (instruction as Instruction11n).narrowLiteral - - // method founds - if (literal == 1) tapSeekMethods["P"] = it - if (literal == 2) tapSeekMethods["O"] = it - } - } ?: return SeekbarTappingParentFingerprint.toErrorResult() - - SeekbarTappingFingerprint.result?.let { - val insertIndex = it.scanResult.patternScanResult!!.endIndex - - it.mutableMethod.apply { - val register = getInstruction(insertIndex - 1).registerC - - val pMethod = tapSeekMethods["P"]!! - val oMethod = tapSeekMethods["O"]!! - - addInstructionsWithLabels( - insertIndex, """ - invoke-static {}, $SEEKBAR->enableSeekbarTapping()Z - move-result v0 - if-eqz v0, :off - invoke-virtual { v$register, v2 }, ${oMethod.definingClass}->${oMethod.name}(I)V - invoke-virtual { v$register, v2 }, ${pMethod.definingClass}->${pMethod.name}(I)V - """, ExternalLabel("off", getInstruction(insertIndex)) - ) - } - } ?: return SeekbarTappingFingerprint.toErrorResult() - - /** - * Add settings - */ - SettingsPatch.addPreference( - arrayOf( - "PREFERENCE: SEEKBAR_SETTINGS", - "SETTINGS: ENABLE_SEEKBAR_TAPPING" - ) - ) - - SettingsPatch.updatePatchStatus("enable-seekbar-tapping") - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/fingerprints/ShortsCommentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/fingerprints/ShortsCommentFingerprint.kt deleted file mode 100644 index f47bf598d..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/fingerprints/ShortsCommentFingerprint.kt +++ /dev/null @@ -1,9 +0,0 @@ -package app.revanced.patches.youtube.layout.shorts.shortscomponent.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.rightCommentId -import app.revanced.util.bytecode.isWideLiteralExists - -object ShortsCommentFingerprint : MethodFingerprint( - customFingerprint = { it, _ -> it.isWideLiteralExists(rightCommentId) } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/fingerprints/ShortsInfoPanelFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/fingerprints/ShortsInfoPanelFingerprint.kt deleted file mode 100644 index a130a85de..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/fingerprints/ShortsInfoPanelFingerprint.kt +++ /dev/null @@ -1,10 +0,0 @@ -package app.revanced.patches.youtube.layout.shorts.shortscomponent.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.reelPlayerInfoPanelId -import app.revanced.util.bytecode.isWideLiteralExists - -object ShortsInfoPanelFingerprint : MethodFingerprint( - returnType = "V", - customFingerprint = { it, _ -> it.isWideLiteralExists(reelPlayerInfoPanelId) } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/fingerprints/ShortsPaidContentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/fingerprints/ShortsPaidContentFingerprint.kt deleted file mode 100644 index 5898627bf..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/fingerprints/ShortsPaidContentFingerprint.kt +++ /dev/null @@ -1,9 +0,0 @@ -package app.revanced.patches.youtube.layout.shorts.shortscomponent.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.reelPlayerBadgeId -import app.revanced.util.bytecode.isWideLiteralExists - -object ShortsPaidContentFingerprint : MethodFingerprint( - customFingerprint = { it, _ -> it.isWideLiteralExists(reelPlayerBadgeId) } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/fingerprints/ShortsRemixFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/fingerprints/ShortsRemixFingerprint.kt deleted file mode 100644 index adf89e59d..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/fingerprints/ShortsRemixFingerprint.kt +++ /dev/null @@ -1,9 +0,0 @@ -package app.revanced.patches.youtube.layout.shorts.shortscomponent.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.reelRemixId -import app.revanced.util.bytecode.isWideLiteralExists - -object ShortsRemixFingerprint : MethodFingerprint( - customFingerprint = { it, _ -> it.isWideLiteralExists(reelRemixId) } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/fingerprints/ShortsSubscriptionsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/fingerprints/ShortsSubscriptionsFingerprint.kt deleted file mode 100644 index 56807e528..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/fingerprints/ShortsSubscriptionsFingerprint.kt +++ /dev/null @@ -1,9 +0,0 @@ -package app.revanced.patches.youtube.layout.shorts.shortscomponent.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.reelPlayerPausedId -import app.revanced.util.bytecode.isWideLiteralExists - -object ShortsSubscriptionsFingerprint : MethodFingerprint( - customFingerprint = { it, _ -> it.isWideLiteralExists(reelPlayerPausedId) } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/fingerprints/ShortsSubscriptionsTabletParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/fingerprints/ShortsSubscriptionsTabletParentFingerprint.kt deleted file mode 100644 index 72e3e7207..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/fingerprints/ShortsSubscriptionsTabletParentFingerprint.kt +++ /dev/null @@ -1,9 +0,0 @@ -package app.revanced.patches.youtube.layout.shorts.shortscomponent.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.reelPlayerFooterId -import app.revanced.util.bytecode.isWideLiteralExists - -object ShortsSubscriptionsTabletParentFingerprint : MethodFingerprint( - customFingerprint = { it, _ -> it.isWideLiteralExists(reelPlayerFooterId) } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/theme/patch/GeneralThemePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/patch/GeneralThemePatch.kt similarity index 92% rename from src/main/kotlin/app/revanced/patches/youtube/layout/etc/theme/patch/GeneralThemePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/theme/patch/GeneralThemePatch.kt index 6008e6bce..7d775fd06 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/theme/patch/GeneralThemePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/patch/GeneralThemePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.etc.theme.patch +package app.revanced.patches.youtube.layout.theme.patch import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version @@ -8,7 +8,7 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patches.youtube.misc.litho.patch.LithoThemePatch -import app.revanced.util.integrations.Constants +import app.revanced.util.integrations.Constants.UTILS_PATH import org.w3c.dom.Element @Name("general-theme-patch") @@ -17,7 +17,7 @@ import org.w3c.dom.Element class GeneralThemePatch : ResourcePatch { override fun execute(context: ResourceContext): PatchResult { - LithoThemePatch.injectCall("${Constants.UTILS_PATH}/LithoThemePatch;->applyLithoTheme(I)I") + LithoThemePatch.injectCall("$UTILS_PATH/LithoThemePatch;->applyLithoTheme(I)I") // edit the resource files to change the splash screen color val attrsPath = "res/values/attrs.xml" @@ -80,8 +80,8 @@ class GeneralThemePatch : ResourcePatch { } } - arrayOf("drawable", "drawable-sw600dp").forEach { quantumLaunchscreenPath -> - context.xmlEditor["res/$quantumLaunchscreenPath/quantum_launchscreen_youtube.xml"].use { editor -> + arrayOf("drawable", "drawable-sw600dp").forEach { quantumLaunchScreenPath -> + context.xmlEditor["res/$quantumLaunchScreenPath/quantum_launchscreen_youtube.xml"].use { editor -> val resourcesNode = editor.file.getElementsByTagName("item").item(0) as Element if (resourcesNode.attributes.getNamedItem("android:drawable") != null) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/theme/patch/ThemePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/patch/ThemePatch.kt similarity index 90% rename from src/main/kotlin/app/revanced/patches/youtube/layout/etc/theme/patch/ThemePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/theme/patch/ThemePatch.kt index 25a041abd..4173c7a05 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/theme/patch/ThemePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/patch/ThemePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.etc.theme.patch +package app.revanced.patches.youtube.layout.theme.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -8,8 +8,8 @@ import app.revanced.patcher.patch.* 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.layout.etc.theme.patch.GeneralThemePatch.Companion.isMonetPatchIncluded -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 import org.w3c.dom.Element diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/tooltip/fingerprints/TooltipContentViewFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/tooltip/fingerprints/TooltipContentViewFingerprint.kt similarity index 59% rename from src/main/kotlin/app/revanced/patches/youtube/layout/etc/tooltip/fingerprints/TooltipContentViewFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/tooltip/fingerprints/TooltipContentViewFingerprint.kt index 49e9d89c2..408ae20fb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/tooltip/fingerprints/TooltipContentViewFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/tooltip/fingerprints/TooltipContentViewFingerprint.kt @@ -1,8 +1,8 @@ -package app.revanced.patches.youtube.layout.etc.tooltip.fingerprints +package app.revanced.patches.youtube.layout.tooltip.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.toolTipId +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.ToolTipContentView import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.AccessFlags @@ -10,5 +10,5 @@ object TooltipContentViewFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, parameters = listOf("L"), - customFingerprint = { it, _ -> it.isWideLiteralExists(toolTipId) } + customFingerprint = { it, _ -> it.isWideLiteralExists(ToolTipContentView) } ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/tooltip/patch/TooltipContentViewPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/tooltip/patch/TooltipContentViewPatch.kt similarity index 78% rename from src/main/kotlin/app/revanced/patches/youtube/layout/etc/tooltip/patch/TooltipContentViewPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/tooltip/patch/TooltipContentViewPatch.kt index 90a2ccaf2..670fb21e2 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/tooltip/patch/TooltipContentViewPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/tooltip/patch/TooltipContentViewPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.etc.tooltip.patch +package app.revanced.patches.youtube.layout.tooltip.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -12,9 +12,9 @@ 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.layout.etc.tooltip.fingerprints.TooltipContentViewFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 @Patch @Name("hide-tooltip-content") @@ -28,9 +28,7 @@ import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch @YouTubeCompatibility @Version("0.0.1") class TooltipContentViewPatch : BytecodePatch( - listOf( - TooltipContentViewFingerprint - ) + listOf(TooltipContentViewFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { 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 c95ade5fc..f4b8b0b2b 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 @@ -6,6 +6,7 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError @@ -14,7 +15,7 @@ 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.ambientmode.fingerprints.PowerSaveModeFingerprint -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.MISC_PATH import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @@ -32,28 +33,30 @@ class PowerSaveModePatch : BytecodePatch( ) { override fun execute(context: BytecodeContext): PatchResult { - PowerSaveModeFingerprint.result?.mutableMethod?.let { method -> - val instructions = method.implementation!!.instructions - var powerManagerIndex = -1 + PowerSaveModeFingerprint.result?.let { + it.mutableMethod.apply { + var insertIndex = -1 - for ((index, instruction) in instructions.withIndex()) { - if (instruction.opcode != Opcode.INVOKE_VIRTUAL) continue + for ((index, instruction) in implementation!!.instructions.withIndex()) { + if (instruction.opcode != Opcode.INVOKE_VIRTUAL) continue - val invokeInstruction = instruction as Instruction35c - if ((invokeInstruction.reference as MethodReference).name != "isPowerSaveMode") continue + val invokeInstruction = instruction as Instruction35c + if ((invokeInstruction.reference as MethodReference).name != "isPowerSaveMode") continue - powerManagerIndex = index + 1 + val targetRegister = getInstruction(index + 1).registerA - val targetRegister = (instructions.elementAt(powerManagerIndex) as OneRegisterInstruction).registerA + insertIndex = index + 2 - method.addInstructions( - powerManagerIndex + 1, """ - invoke-static {v$targetRegister}, $MISC_PATH/PowerSaveModePatch;->bypassPowerSaveModeRestrictions(Z)Z - move-result v$targetRegister - """ - ) + addInstructions( + insertIndex, """ + invoke-static {v$targetRegister}, $MISC_PATH/PowerSaveModePatch;->bypassPowerSaveModeRestrictions(Z)Z + move-result v$targetRegister + """ + ) + } + if (insertIndex == -1) + return PatchResultError("Couldn't find PowerManager reference") } - if (powerManagerIndex == -1) return PatchResultError("Couldn't find PowerManager reference") } ?: return PowerSaveModeFingerprint.toErrorResult() /** 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 65c008feb..22d5ec649 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 @@ -14,7 +14,7 @@ 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.misc.settings.resource.patch.SettingsPatch +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 @@ -37,18 +37,20 @@ class ExternalBrowserPatch : BytecodePatch( ExternalBrowserPrimaryFingerprint, ExternalBrowserSecondaryFingerprint, ExternalBrowserTertiaryFingerprint - ).forEach { - val result = it.result?: return it.toErrorResult() - it.result?.mutableMethod?.apply { - val endIndex = result.scanResult.patternScanResult!!.endIndex - val register = getInstruction(endIndex).registerA - addInstructions( - endIndex + 1, """ - invoke-static {v$register}, $MISC_PATH/ExternalBrowserPatch;->enableExternalBrowser(Ljava/lang/String;)Ljava/lang/String; - move-result-object v$register - """ - ) - } + ).forEach { fingerprint -> + fingerprint.result?.let { + it.mutableMethod.apply { + val endIndex = it.scanResult.patternScanResult!!.endIndex + val register = getInstruction(endIndex).registerA + + addInstructions( + endIndex + 1, """ + invoke-static {v$register}, $MISC_PATH/ExternalBrowserPatch;->enableExternalBrowser(Ljava/lang/String;)Ljava/lang/String; + move-result-object v$register + """ + ) + } + } ?: return fingerprint.toErrorResult() } /** 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 c41f5ec08..5ad8d82e3 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 @@ -19,7 +19,7 @@ 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.misc.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.MISC_PATH import org.jf.dexlib2.Opcode import org.jf.dexlib2.dexbacked.reference.DexBackedFieldReference @@ -128,7 +128,7 @@ class ForceVP9CodecPatch : BytecodePatch( invoke-static {v$register}, $INTEGRATIONS_CLASS_METHOD_REFERENCE move-result v$register return v$register - """ + """ ) } @@ -136,12 +136,11 @@ class ForceVP9CodecPatch : BytecodePatch( fieldName: String, descriptor: String ) { - val insertInstructions = implementation!!.instructions val targetString = "Landroid/os/Build;->" + fieldName + ":Ljava/lang/String;" - for ((index, instruction) in insertInstructions.withIndex()) { + for ((index, instruction) in implementation!!.instructions.withIndex()) { if (instruction.opcode != Opcode.SGET_OBJECT) continue val indexString = ((instruction as? ReferenceInstruction)?.reference as? DexBackedFieldReference).toString() diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/InitFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/InitFingerprint.kt deleted file mode 100644 index 7cd854c23..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/InitFingerprint.kt +++ /dev/null @@ -1,7 +0,0 @@ -package app.revanced.patches.youtube.misc.integrations.fingerprints - -import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint - -object InitFingerprint : IntegrationsFingerprint( - strings = listOf("Application.onCreate") -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/ServiceFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/ServiceFingerprint.kt deleted file mode 100644 index 4d1795bbd..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/ServiceFingerprint.kt +++ /dev/null @@ -1,8 +0,0 @@ -package app.revanced.patches.youtube.misc.integrations.fingerprints - -import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint - -object ServiceFingerprint : IntegrationsFingerprint( - customFingerprint = { it, _ -> it.definingClass.endsWith("ApiPlayerService;") && it.name == "" }, - contextRegisterResolver = { it.implementation!!.registerCount - it.parameters.size } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/StandalonePlayerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/StandalonePlayerFingerprint.kt deleted file mode 100644 index 27d9aa151..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/StandalonePlayerFingerprint.kt +++ /dev/null @@ -1,10 +0,0 @@ -package app.revanced.patches.youtube.misc.integrations.fingerprints - -import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint - -object StandalonePlayerFingerprint : IntegrationsFingerprint( - strings = listOf( - "Invalid PlaybackStartDescriptor. Returning the instance itself.", - "com.google.android.music", - ), -) \ No newline at end of file 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 1512c0fad..79d3caf22 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 @@ -18,7 +18,7 @@ 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.misc.layoutswitch.fingerprints.* -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.MISC_PATH @Patch diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/litho/patch/ByteBufferFilterPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/litho/patch/ByteBufferFilterPatch.kt index 0bd2bd652..20a720d3f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/litho/patch/ByteBufferFilterPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/litho/patch/ByteBufferFilterPatch.kt @@ -10,7 +10,7 @@ import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch +import app.revanced.patches.youtube.utils.playertype.patch.PlayerTypeHookPatch @DependsOn( [ diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackSettingsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackSettingsFingerprint.kt index 73185b417..2c05597ee 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackSettingsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackSettingsFingerprint.kt @@ -2,7 +2,7 @@ package app.revanced.patches.youtube.misc.minimizedplayback.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.backgroundCategoryId +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.BackgroundCategory import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @@ -19,5 +19,5 @@ object MinimizedPlaybackSettingsFingerprint : MethodFingerprint( Opcode.IF_NEZ, Opcode.GOTO ), - customFingerprint = { it, _ -> it.isWideLiteralExists(backgroundCategoryId) } + customFingerprint = { it, _ -> it.isWideLiteralExists(BackgroundCategory) } ) 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 c22c4215c..c5d8e0462 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 @@ -15,10 +15,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.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch import app.revanced.patches.youtube.misc.minimizedplayback.fingerprints.* -import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch +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 import app.revanced.util.integrations.Constants.MISC_PATH import org.jf.dexlib2.iface.instruction.ReferenceInstruction import org.jf.dexlib2.iface.reference.MethodReference @@ -75,7 +75,7 @@ class MinimizedPlaybackPatch : BytecodePatch( invoke-static {}, $INTEGRATIONS_METHOD_REFERENCE move-result v0 return v0 - """ + """ ) } 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 ed9e641c9..c13a8d086 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 @@ -14,7 +14,7 @@ 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.misc.settings.resource.patch.SettingsPatch +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 @@ -35,16 +35,18 @@ class OpenLinksDirectlyPatch : BytecodePatch( arrayOf( OpenLinksDirectlyFingerprintPrimary, OpenLinksDirectlyFingerprintSecondary - ).forEach { - val result = it.result?: return it.toErrorResult() - val insertIndex = result.scanResult.patternScanResult!!.startIndex - result.mutableMethod.apply { - val register = getInstruction(insertIndex).registerC - replaceInstruction( - insertIndex, + ).forEach { fingerprint -> + fingerprint.result?.let { + it.mutableMethod.apply { + val insertIndex = it.scanResult.patternScanResult!!.startIndex + val register = getInstruction(insertIndex).registerC + + replaceInstruction( + insertIndex, "invoke-static {v$register}, $MISC_PATH/OpenLinksDirectlyPatch;->enableBypassRedirect(Ljava/lang/String;)Landroid/net/Uri;" - ) - } + ) + } + } ?: return fingerprint.toErrorResult() } /** diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/overridespeed/bytecode/fingerprints/VideoSpeedSettingsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/overridespeed/bytecode/fingerprints/VideoSpeedSettingsFingerprint.kt deleted file mode 100644 index 8c6386575..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/overridespeed/bytecode/fingerprints/VideoSpeedSettingsFingerprint.kt +++ /dev/null @@ -1,12 +0,0 @@ -package app.revanced.patches.youtube.misc.overridespeed.bytecode.fingerprints - -import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import org.jf.dexlib2.AccessFlags - -object VideoSpeedSettingsFingerprint : MethodFingerprint( - returnType = "V", - accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, - parameters = listOf("[L", "I"), - strings = listOf("menu_item_playback_speed") -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/overridespeed/resource/patch/OverrideSpeedHookResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/overridespeed/resource/patch/OverrideSpeedHookResourcePatch.kt deleted file mode 100644 index c8c57da7a..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/overridespeed/resource/patch/OverrideSpeedHookResourcePatch.kt +++ /dev/null @@ -1,25 +0,0 @@ -package app.revanced.patches.youtube.misc.overridespeed.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.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.util.resources.ResourceUtils.copyXmlNode - -@Name("override-speed-hook-resource-patch") -@YouTubeCompatibility -@Version("0.0.1") -class OverrideSpeedHookResourcePatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /** - * Copy arrays - */ - context.copyXmlNode("youtube/speed/host", "values/arrays.xml", "resources") - - return PatchResultSuccess() - } -} diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playerbutton/fingerprints/LiveChatFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playerbutton/fingerprints/LiveChatFingerprint.kt deleted file mode 100644 index e4cc22818..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playerbutton/fingerprints/LiveChatFingerprint.kt +++ /dev/null @@ -1,11 +0,0 @@ -package app.revanced.patches.youtube.misc.playerbutton.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.liveChatButtonId -import app.revanced.util.bytecode.isWideLiteralExists -import org.jf.dexlib2.Opcode - -object LiveChatFingerprint : MethodFingerprint( - opcodes = listOf(Opcode.NEW_INSTANCE), - customFingerprint = { it, _ -> it.isWideLiteralExists(liveChatButtonId) } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/patch/PlayerControlsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/patch/PlayerControlsPatch.kt deleted file mode 100644 index 657424c93..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/patch/PlayerControlsPatch.kt +++ /dev/null @@ -1,96 +0,0 @@ -package app.revanced.patches.youtube.misc.playercontrols.patch - -import app.revanced.extensions.toErrorResult -import app.revanced.patcher.annotation.Description -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstruction -import app.revanced.patcher.extensions.InstructionExtensions.getInstruction -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult -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.misc.playercontrols.fingerprints.* -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch -import org.jf.dexlib2.iface.instruction.OneRegisterInstruction - -@Name("player-controls-bytecode-patch") -@DependsOn([SharedResourceIdPatch::class]) -@Description("Manages the code for the player controls of the YouTube player.") -@YouTubeCompatibility -@Version("0.0.1") -class PlayerControlsPatch : BytecodePatch( - listOf( - BottomControlsInflateFingerprint, - ControlsLayoutInflateFingerprint, - PlayerControlsVisibilityFingerprint, - PlayerControlsVisibilityModelFingerprint - ) -) { - override fun execute(context: BytecodeContext): PatchResult { - - val playerControlsVisibilityModelClassDef = PlayerControlsVisibilityModelFingerprint.result?.classDef?: return PlayerControlsVisibilityModelFingerprint.toErrorResult() - - SeekEDUVisibleFingerprint.resolve(context, playerControlsVisibilityModelClassDef) - seekEDUVisibleResult = SeekEDUVisibleFingerprint.result?: return SeekEDUVisibleFingerprint.toErrorResult() - - UserScrubbingFingerprint.resolve(context, playerControlsVisibilityModelClassDef) - userScrubbingResult = UserScrubbingFingerprint.result?: return UserScrubbingFingerprint.toErrorResult() - - playerControlsVisibilityResult = PlayerControlsVisibilityFingerprint.result?: return PlayerControlsVisibilityFingerprint.toErrorResult() - controlsLayoutInflateResult = ControlsLayoutInflateFingerprint.result?: return ControlsLayoutInflateFingerprint.toErrorResult() - inflateResult = BottomControlsInflateFingerprint.result?: return BottomControlsInflateFingerprint.toErrorResult() - - return PatchResultSuccess() - } - - internal companion object { - lateinit var controlsLayoutInflateResult: MethodFingerprintResult - lateinit var inflateResult: MethodFingerprintResult - lateinit var playerControlsVisibilityResult: MethodFingerprintResult - lateinit var seekEDUVisibleResult: MethodFingerprintResult - lateinit var userScrubbingResult: MethodFingerprintResult - - private fun MethodFingerprintResult.injectVisibilityCall( - descriptor: String, - fieldName: String - ) { - mutableMethod.addInstruction( - 0, - "invoke-static {p1}, $descriptor->$fieldName(Z)V" - ) - } - - private fun MethodFingerprintResult.injectCalls( - descriptor: String - ) { - val endIndex = scanResult.patternScanResult!!.endIndex - with (mutableMethod) { - val viewRegister = (getInstruction(endIndex) as OneRegisterInstruction).registerA - addInstruction( - endIndex + 1, - "invoke-static {v$viewRegister}, $descriptor->initialize(Ljava/lang/Object;)V" - ) - } - } - - fun injectVisibility(descriptor: String) { - playerControlsVisibilityResult.injectVisibilityCall(descriptor, "changeVisibility") - seekEDUVisibleResult.injectVisibilityCall(descriptor, "changeVisibilityNegatedImmediate") - userScrubbingResult.injectVisibilityCall(descriptor, "changeVisibilityNegatedImmediate") - } - - fun initializeSB(descriptor: String) { - controlsLayoutInflateResult.injectCalls(descriptor) - } - - fun initializeControl(descriptor: String) { - inflateResult.injectCalls(descriptor) - } - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/fingerprint/PlayerOverlaysOnFinishInflateFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/fingerprint/PlayerOverlaysOnFinishInflateFingerprint.kt deleted file mode 100644 index 3cf1e8993..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/fingerprint/PlayerOverlaysOnFinishInflateFingerprint.kt +++ /dev/null @@ -1,9 +0,0 @@ -package app.revanced.patches.youtube.misc.playeroverlay.fingerprint - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint - -object PlayerOverlaysOnFinishInflateFingerprint : MethodFingerprint( - customFingerprint = { it, _ -> - it.definingClass.endsWith("YouTubePlayerOverlaysLayout;") && it.name == "onFinishInflate" - } -) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/patch/PlayerTypeHookPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/patch/PlayerTypeHookPatch.kt deleted file mode 100644 index c425b9e25..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/patch/PlayerTypeHookPatch.kt +++ /dev/null @@ -1,34 +0,0 @@ -package app.revanced.patches.youtube.misc.playertype.patch - -import app.revanced.extensions.toErrorResult -import app.revanced.patcher.annotation.Description -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.BytecodeContext -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.misc.playertype.fingerprint.UpdatePlayerTypeFingerprint -import app.revanced.util.integrations.Constants.UTILS_PATH - -@Name("player-type-hook") -@Description("Hook to get the current player type of WatchWhileActivity") -@YouTubeCompatibility -@Version("0.0.1") -class PlayerTypeHookPatch : BytecodePatch( - listOf( - UpdatePlayerTypeFingerprint - ) -) { - override fun execute(context: BytecodeContext): PatchResult { - // hook YouTubePlayerOverlaysLayout.updatePlayerLayout() - UpdatePlayerTypeFingerprint.result?.mutableMethod?.addInstruction( - 0, - "invoke-static { p1 }, $UTILS_PATH/PlayerTypeHookPatch;->YouTubePlayerOverlaysLayout_updatePlayerTypeHookEX(Ljava/lang/Object;)V" - ) ?: return UpdatePlayerTypeFingerprint.toErrorResult() - - return PatchResultSuccess() - } -} diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/quic/fingerprints/CronetEngineBuilderFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/quic/fingerprints/CronetEngineBuilderFingerprint.kt index 0964094f9..1169bc16d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/quic/fingerprints/CronetEngineBuilderFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/quic/fingerprints/CronetEngineBuilderFingerprint.kt @@ -7,5 +7,5 @@ object CronetEngineBuilderFingerprint : MethodFingerprint( returnType = "L", accessFlags = AccessFlags.PUBLIC.value, parameters = listOf("Z"), - customFingerprint = { it, _ -> it.definingClass == "Lorg/chromium/net/CronetEngine\$Builder;" && it.name == "enableQuic" } + customFingerprint = { it, _ -> it.definingClass.endsWith("CronetEngine\$Builder;") && it.name == "enableQuic" } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/quic/fingerprints/ExperimentalCronetEngineBuilderFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/quic/fingerprints/ExperimentalCronetEngineBuilderFingerprint.kt index 15312d6c6..56c083544 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/quic/fingerprints/ExperimentalCronetEngineBuilderFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/quic/fingerprints/ExperimentalCronetEngineBuilderFingerprint.kt @@ -7,5 +7,5 @@ object ExperimentalCronetEngineBuilderFingerprint : MethodFingerprint( returnType = "L", accessFlags = AccessFlags.PUBLIC.value, parameters = listOf("Z"), - customFingerprint = { it, _ -> it.definingClass == "Lorg/chromium/net/ExperimentalCronetEngine\$Builder;" && it.name == "enableQuic" } + customFingerprint = { it, _ -> it.definingClass.endsWith("ExperimentalCronetEngine\$Builder;") && it.name == "enableQuic" } ) \ No newline at end of file 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 d9a9bb885..b5e160491 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 @@ -13,7 +13,7 @@ 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.misc.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.MISC_PATH @Patch diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/resourceid/patch/SharedResourceIdPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/resourceid/patch/SharedResourceIdPatch.kt deleted file mode 100644 index 1613d11f0..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/resourceid/patch/SharedResourceIdPatch.kt +++ /dev/null @@ -1,124 +0,0 @@ -package app.revanced.patches.youtube.misc.resourceid.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.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.util.enum.ResourceType -import app.revanced.util.enum.ResourceType.* - -@Name("shared-resource-id") -@DependsOn([ResourceMappingPatch::class]) -@YouTubeCompatibility -@Version("0.0.1") -class SharedResourceIdPatch : ResourcePatch { - internal companion object { - var accessibilityProgressTimeId: Long = -1 - var accountSwitcherAccessibilityId: Long = -1 - var adAttributionId: Long = -1 - var appearanceStringId: Long = -1 - var appRelatedEndScreenResultsId: Long = -1 - var autoNavPreviewId: Long = -1 - var backgroundCategoryId: Long = -1 - var barContainerHeightId: Long = -1 - var bottomUiContainerResourceId: Long = -1 - var channelListSubMenuId: Long = -1 - var chapterRepeatOnResourceId: Long = -1 - var compactLinkId: Long = -1 - var controlsLayoutStubResourceId: Long = -1 - var dislikeButtonId: Long = -1 - var donationCompanionResourceId: Long = -1 - var easySeekEduContainerId: Long = -1 - var expandButtonId: Long = -1 - var fabId: Long = -1 - var filterBarHeightId: Long = -1 - var floatyBarTopMarginId: Long = -1 - var horizontalCardListId: Long = -1 - var imageOnlyTabId: Long = -1 - var inlineTimeBarColorizedBarPlayedColorDarkId: Long = -1 - var inlineTimeBarPlayedNotHighlightedColorId: Long = -1 - var insetOverlayViewLayoutId: Long = -1 - var layoutCircleId: Long = -1 - var layoutIconId: Long = -1 - var layoutVideoId: Long = -1 - var likeButtonId: Long = -1 - var liveChatButtonId: Long = -1 - var reelPlayerBadgeId: Long = -1 - var reelPlayerBadge2Id: Long = -1 - var reelPlayerFooterId: Long = -1 - var reelPlayerInfoPanelId: Long = -1 - var reelPlayerPausedId: Long = -1 - var reelRemixId: Long = -1 - var relatedChipCloudMarginId: Long = -1 - var rightCommentId: Long = -1 - var scrimOverlayId: Long = -1 - var searchSuggestionEntryId: Long = -1 - var scrubbingId: Long = -1 - var slimMetadataToggleButtonId: Long = -1 - var suggestedActionId: Long = -1 - var totalTimeId: Long = -1 - var toolTipId: Long = -1 - var videoQualityFragmentId: Long = -1 - } - - override fun execute(context: ResourceContext): PatchResult { - - fun find(type: ResourceType, name: String) = ResourceMappingPatch - .resourceMappings - .single { it.type == type.value && it.name == name }.id - - accessibilityProgressTimeId = find(STRING, "accessibility_player_progress_time") - accountSwitcherAccessibilityId = find(STRING, "account_switcher_accessibility_label") - adAttributionId = find(ID, "ad_attribution") - appearanceStringId = find(STRING, "app_theme_appearance_dark") - appRelatedEndScreenResultsId = find(LAYOUT, "app_related_endscreen_results") - autoNavPreviewId = find(ID, "autonav_preview_stub") - backgroundCategoryId = find(STRING, "pref_background_and_offline_category") - barContainerHeightId = find(DIMEN, "bar_container_height") - bottomUiContainerResourceId = find(ID, "bottom_ui_container_stub") - channelListSubMenuId = find(LAYOUT, "channel_list_sub_menu") - chapterRepeatOnResourceId = find(STRING, "chapter_repeat_on") - compactLinkId = find(LAYOUT, "compact_link") - controlsLayoutStubResourceId = find(ID, "controls_layout_stub") - dislikeButtonId = find(ID, "dislike_button") - donationCompanionResourceId = find(LAYOUT, "donation_companion") - easySeekEduContainerId = find(ID, "easy_seek_edu_container") - expandButtonId = find(LAYOUT, "expand_button_down") - fabId = find(ID, "fab") - filterBarHeightId = find(DIMEN, "filter_bar_height") - floatyBarTopMarginId = find(DIMEN, "floaty_bar_button_top_margin") - horizontalCardListId = find(LAYOUT, "horizontal_card_list") - imageOnlyTabId = find(LAYOUT, "image_only_tab") - inlineTimeBarColorizedBarPlayedColorDarkId = find(COLOR, "inline_time_bar_colorized_bar_played_color_dark") - inlineTimeBarPlayedNotHighlightedColorId = find(COLOR, "inline_time_bar_played_not_highlighted_color") - insetOverlayViewLayoutId = find(ID, "inset_overlay_view_layout") - layoutCircleId = find(LAYOUT, "endscreen_element_layout_circle") - layoutIconId = find(LAYOUT, "endscreen_element_layout_icon") - layoutVideoId = find(LAYOUT, "endscreen_element_layout_video") - likeButtonId = find(ID, "like_button") - liveChatButtonId = find(ID, "live_chat_overlay_button") - reelPlayerBadgeId = find(ID, "reel_player_badge") - reelPlayerBadge2Id = find(ID, "reel_player_badge2") - reelPlayerFooterId = find(LAYOUT, "reel_player_dyn_footer_vert_stories3") - reelPlayerInfoPanelId = find(ID, "reel_player_info_panel") - reelPlayerPausedId = find(ID, "reel_player_paused_state_buttons") - reelRemixId = find(ID, "reel_dyn_remix") - relatedChipCloudMarginId = find(LAYOUT, "related_chip_cloud_reduced_margins") - rightCommentId = find(DRAWABLE, "ic_right_comment_32c") - scrimOverlayId = find(ID, "scrim_overlay") - searchSuggestionEntryId = find(LAYOUT, "search_suggestion_entry") - scrubbingId = find(DIMEN, "vertical_touch_offset_to_enter_fine_scrubbing") - slimMetadataToggleButtonId = find(COLOR, "slim_metadata_toggle_button") - suggestedActionId = find(LAYOUT, "suggested_action") - totalTimeId = find(STRING, "total_time") - toolTipId = find(LAYOUT, "tooltip_content_view") - videoQualityFragmentId = find(LAYOUT, "video_quality_bottom_sheet_list_fragment_title") - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/oldlayout/fingerprints/ButtonTagOnClickFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/oldlayout/fingerprints/ButtonTagOnClickFingerprint.kt deleted file mode 100644 index 1af65fd9c..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/oldlayout/fingerprints/ButtonTagOnClickFingerprint.kt +++ /dev/null @@ -1,14 +0,0 @@ -package app.revanced.patches.youtube.misc.returnyoutubedislike.oldlayout.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import org.jf.dexlib2.Opcode - -object ButtonTagOnClickFingerprint : MethodFingerprint( - returnType = "V", - parameters = listOf("L"), - opcodes = listOf( - Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT - ), - customFingerprint = { it, _ -> it.name == "onClick" } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/oldlayout/fingerprints/SlimMetadataButtonParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/oldlayout/fingerprints/SlimMetadataButtonParentFingerprint.kt deleted file mode 100644 index ab1ae9a5d..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/oldlayout/fingerprints/SlimMetadataButtonParentFingerprint.kt +++ /dev/null @@ -1,10 +0,0 @@ -package app.revanced.patches.youtube.misc.returnyoutubedislike.oldlayout.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.slimMetadataToggleButtonId -import app.revanced.util.bytecode.isWideLiteralExists - -object SlimMetadataButtonParentFingerprint : MethodFingerprint( - returnType = "I", - customFingerprint = { it, _ -> it.isWideLiteralExists(slimMetadataToggleButtonId) } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/oldlayout/patch/ReturnYouTubeDislikeOldLayoutPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/oldlayout/patch/ReturnYouTubeDislikeOldLayoutPatch.kt deleted file mode 100644 index eacef5ade..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/oldlayout/patch/ReturnYouTubeDislikeOldLayoutPatch.kt +++ /dev/null @@ -1,118 +0,0 @@ -package app.revanced.patches.youtube.misc.returnyoutubedislike.oldlayout.patch - -import app.revanced.extensions.toErrorResult -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions -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.PatchResultSuccess -import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.dislikeButtonId -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.likeButtonId -import app.revanced.patches.youtube.misc.returnyoutubedislike.oldlayout.fingerprints.* -import app.revanced.util.bytecode.getWideLiteralIndex -import app.revanced.util.integrations.Constants.UTILS_PATH -import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction -import org.jf.dexlib2.iface.instruction.OneRegisterInstruction -import org.jf.dexlib2.iface.instruction.ReferenceInstruction -import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction -import org.jf.dexlib2.iface.reference.Reference - -@Name("return-youtube-dislike-old-layout") -@DependsOn([SharedResourceIdPatch::class]) -@YouTubeCompatibility -@Version("0.0.1") -class ReturnYouTubeDislikeOldLayoutPatch : BytecodePatch( - listOf( - SlimMetadataButtonParentFingerprint, - ButtonTagFingerprint - ) -) { - override fun execute(context: BytecodeContext): PatchResult { - - SlimMetadataButtonParentFingerprint.result?.let { parentResult -> - - SlimMetadataButtonViewFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let { - it.mutableMethod.apply { - val startIndex = it.scanResult.patternScanResult!!.startIndex - slimMetadataButtonViewFieldReference = - getInstruction(startIndex).reference - } - } ?: return SlimMetadataButtonViewFingerprint.toErrorResult() - - SlimMetadataButtonTextFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let { - it.mutableMethod.apply { - val insertIndex = it.scanResult.patternScanResult!!.startIndex - val setTextInstruction = getInstruction(insertIndex) - - val tempRegister = - setTextInstruction.registerC + 1 - - val charSequenceRegister = - setTextInstruction.registerD - - addInstructions( - insertIndex, """ - iget-object v$tempRegister, p0, $slimMetadataButtonViewFieldReference - invoke-static {v$tempRegister, v$charSequenceRegister}, $INTEGRATIONS_RYD_CLASS_DESCRIPTOR->onSetText(Landroid/view/View;Ljava/lang/CharSequence;)Ljava/lang/CharSequence; - move-result-object v$charSequenceRegister - """ - ) - } - } ?: return SlimMetadataButtonTextFingerprint.toErrorResult() - } ?: return SlimMetadataButtonParentFingerprint.toErrorResult() - - - ButtonTagFingerprint.result?.let { parentResult -> - - ButtonTagOnClickFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let { - it.mutableMethod.apply { - val startIndex = it.scanResult.patternScanResult!!.startIndex - getActiveBooleanFieldReference = - getInstruction(startIndex).reference - } - } ?: return ButtonTagOnClickFingerprint.toErrorResult() - - parentResult.mutableMethod.apply { - val dislikeButtonIndex = getWideLiteralIndex(dislikeButtonId) - val dislikeButtonRegister = getInstruction(dislikeButtonIndex).registerA - val dislikeButtonInstruction = getInstruction(dislikeButtonIndex - 1) - - addInstructions( - dislikeButtonIndex, """ - invoke-virtual {v${dislikeButtonInstruction.registerB}}, $getActiveBooleanFieldReference - move-result v$dislikeButtonRegister - invoke-static {v${dislikeButtonInstruction.registerA}, v$dislikeButtonRegister}, $INTEGRATIONS_RYD_CLASS_DESCRIPTOR->setDislikeTag(Landroid/view/View;Z)V - """ - ) - - val likeButtonIndex = getWideLiteralIndex(likeButtonId) - val likeButtonRegister = getInstruction(likeButtonIndex).registerA - val likeButtonInstruction = getInstruction(likeButtonIndex - 1) - - addInstructions( - likeButtonIndex, """ - invoke-virtual {v${likeButtonInstruction.registerB}}, $getActiveBooleanFieldReference - move-result v$likeButtonRegister - invoke-static {v${likeButtonInstruction.registerA}, v$likeButtonRegister}, $INTEGRATIONS_RYD_CLASS_DESCRIPTOR->setLikeTag(Landroid/view/View;Z)V - """ - ) - } - } ?: return ButtonTagFingerprint.toErrorResult() - - return PatchResultSuccess() - } - private companion object { - const val INTEGRATIONS_RYD_CLASS_DESCRIPTOR = - "$UTILS_PATH/ReturnYouTubeDislikePatch;" - - lateinit var slimMetadataButtonViewFieldReference: Reference - lateinit var getActiveBooleanFieldReference: Reference - } -} diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/shorts/fingerprints/ShortsTextComponentParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/shorts/fingerprints/ShortsTextComponentParentFingerprint.kt deleted file mode 100644 index 461f1c37c..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/shorts/fingerprints/ShortsTextComponentParentFingerprint.kt +++ /dev/null @@ -1,23 +0,0 @@ -package app.revanced.patches.youtube.misc.returnyoutubedislike.shorts.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import org.jf.dexlib2.Opcode - -object ShortsTextComponentParentFingerprint : MethodFingerprint( - returnType = "V", - parameters = listOf("L", "L"), - opcodes = listOf( - Opcode.INVOKE_STATIC, - Opcode.MOVE_RESULT_OBJECT, - Opcode.GOTO, - Opcode.INVOKE_STATIC, - Opcode.MOVE_RESULT_OBJECT, - Opcode.INVOKE_VIRTUAL, - Opcode.RETURN_VOID, - Opcode.IGET_OBJECT, - Opcode.CHECK_CAST, - Opcode.IGET_BOOLEAN, - Opcode.IF_EQZ, - Opcode.INVOKE_STATIC - ) -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/shorts/patch/ReturnYouTubeDislikeShortsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/shorts/patch/ReturnYouTubeDislikeShortsPatch.kt deleted file mode 100644 index 09df9cedb..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/shorts/patch/ReturnYouTubeDislikeShortsPatch.kt +++ /dev/null @@ -1,61 +0,0 @@ -package app.revanced.patches.youtube.misc.returnyoutubedislike.shorts.patch - -import app.revanced.extensions.toErrorResult -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.data.toMethodWalker -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions -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.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.misc.returnyoutubedislike.shorts.fingerprints.ShortsTextComponentParentFingerprint -import app.revanced.util.integrations.Constants.UTILS_PATH -import org.jf.dexlib2.iface.instruction.OneRegisterInstruction - -@Name("return-youtube-dislike-shorts") -@YouTubeCompatibility -@Version("0.0.1") -class ReturnYouTubeDislikeShortsPatch : BytecodePatch( - listOf(ShortsTextComponentParentFingerprint) -) { - override fun execute(context: BytecodeContext): PatchResult { - ShortsTextComponentParentFingerprint.result?.let { - (context - .toMethodWalker(it.method) - .nextMethod(it.scanResult.patternScanResult!!.endIndex, true) - .getMethod() as MutableMethod - ).apply { - val insertIndex = implementation!!.instructions.size - 1 - val insertRegister = getInstruction(insertIndex).registerA - - this.insertShorts(insertIndex, insertRegister) - } - - it.mutableMethod.apply { - val insertIndex = it.scanResult.patternScanResult!!.startIndex + 2 - val insertRegister = getInstruction(insertIndex - 1).registerA - - this.insertShorts(insertIndex, insertRegister) - } - } ?: return ShortsTextComponentParentFingerprint.toErrorResult() - - return PatchResultSuccess() - } - private companion object { - const val INTEGRATIONS_RYD_CLASS_DESCRIPTOR = - "$UTILS_PATH/ReturnYouTubeDislikePatch;" - } - - private fun MutableMethod.insertShorts(index: Int, register: Int) { - addInstructions( - index, """ - invoke-static {v$register}, $INTEGRATIONS_RYD_CLASS_DESCRIPTOR->onShortsComponentCreated(Landroid/text/Spanned;)Landroid/text/Spanned; - move-result-object v$register - """ - ) - } -} 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 621640ae3..a4e2a8870 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 @@ -11,7 +11,7 @@ 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.GeneralVersionSpoofPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.MISC_PATH import app.revanced.util.resources.ResourceUtils.copyXmlNode diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/timebar/fingerprints/EmptyColorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/timebar/fingerprints/EmptyColorFingerprint.kt deleted file mode 100644 index a3b60a38f..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/timebar/fingerprints/EmptyColorFingerprint.kt +++ /dev/null @@ -1,20 +0,0 @@ -package app.revanced.patches.youtube.misc.timebar.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import org.jf.dexlib2.Opcode - -object EmptyColorFingerprint : MethodFingerprint( - returnType = "V", - opcodes = listOf( - Opcode.MOVE_RESULT_WIDE, - Opcode.CMP_LONG, - Opcode.IF_LEZ, - Opcode.IGET_OBJECT, - Opcode.CHECK_CAST, - Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT_WIDE, - Opcode.GOTO, - Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT_WIDE - ) -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/timebar/fingerprints/OnDrawFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/timebar/fingerprints/OnDrawFingerprint.kt deleted file mode 100644 index b5b90bb2c..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/timebar/fingerprints/OnDrawFingerprint.kt +++ /dev/null @@ -1,17 +0,0 @@ -package app.revanced.patches.youtube.misc.timebar.fingerprints - -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 OnDrawFingerprint : MethodFingerprint ( - returnType = "V", - accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, - parameters = listOf("L"), - opcodes = listOf( - Opcode.MOVE_OBJECT_FROM16, - Opcode.MOVE_OBJECT_FROM16 - ), - customFingerprint = { it, _ -> it.name == "onDraw"} -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/timebar/patch/HookTimeBarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/timebar/patch/HookTimeBarPatch.kt deleted file mode 100644 index 891583254..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/timebar/patch/HookTimeBarPatch.kt +++ /dev/null @@ -1,41 +0,0 @@ -package app.revanced.patches.youtube.misc.timebar.patch - -import app.revanced.extensions.toErrorResult -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult -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.misc.timebar.fingerprints.* - -@Name("hook-timebar-patch") -@YouTubeCompatibility -@Version("0.0.1") -class HookTimeBarPatch : BytecodePatch( - listOf(EmptyColorFingerprint) -) { - override fun execute(context: BytecodeContext): PatchResult { - - EmptyColorFingerprint.result?.let { parentResult -> - emptyColorResult = parentResult - emptyColorMethod = parentResult.mutableMethod - OnDrawFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.let { - setTimeBarMethod = it - } ?: return OnDrawFingerprint.toErrorResult() - } ?: return EmptyColorFingerprint.toErrorResult() - - - return PatchResultSuccess() - } - - internal companion object { - lateinit var emptyColorResult: MethodFingerprintResult - lateinit var emptyColorMethod: MutableMethod - lateinit var setTimeBarMethod: MutableMethod - } -} \ No newline at end of file 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 e991b759d..bb91dcce8 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 @@ -10,7 +10,7 @@ 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.misc.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.resources.ResourceHelper.addTranslations @Patch diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/mainstream/fingerprint/PlayerInitFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/mainstream/fingerprint/PlayerInitFingerprint.kt deleted file mode 100644 index b35e1df5c..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/mainstream/fingerprint/PlayerInitFingerprint.kt +++ /dev/null @@ -1,9 +0,0 @@ -package app.revanced.patches.youtube.misc.videoid.mainstream.fingerprint - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint - -object PlayerInitFingerprint : MethodFingerprint( - strings = listOf( - "playVideo called on player response with no videoStreamingData." - ), -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/homepage/fingerprints/IntentExceptionFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/navigation/homepage/fingerprints/IntentExceptionFingerprint.kt similarity index 80% rename from src/main/kotlin/app/revanced/patches/youtube/layout/navigation/homepage/fingerprints/IntentExceptionFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/navigation/homepage/fingerprints/IntentExceptionFingerprint.kt index 3e2eb746b..ef5f7adfb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/homepage/fingerprints/IntentExceptionFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/navigation/homepage/fingerprints/IntentExceptionFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.navigation.homepage.fingerprints +package app.revanced.patches.youtube.navigation.homepage.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/homepage/fingerprints/LauncherActivityFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/navigation/homepage/fingerprints/LauncherActivityFingerprint.kt similarity index 75% rename from src/main/kotlin/app/revanced/patches/youtube/layout/navigation/homepage/fingerprints/LauncherActivityFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/navigation/homepage/fingerprints/LauncherActivityFingerprint.kt index 6b969c87a..15938d425 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/homepage/fingerprints/LauncherActivityFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/navigation/homepage/fingerprints/LauncherActivityFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.navigation.homepage.fingerprints +package app.revanced.patches.youtube.navigation.homepage.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/homepage/patch/ChangeHomePagePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/navigation/homepage/patch/ChangeHomePagePatch.kt similarity index 66% rename from src/main/kotlin/app/revanced/patches/youtube/layout/navigation/homepage/patch/ChangeHomePagePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/navigation/homepage/patch/ChangeHomePagePatch.kt index 8f36aa6fa..04710c608 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/homepage/patch/ChangeHomePagePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/navigation/homepage/patch/ChangeHomePagePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.navigation.homepage.patch +package app.revanced.patches.youtube.navigation.homepage.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -15,9 +15,9 @@ 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.layout.navigation.homepage.fingerprints.IntentExceptionFingerprint -import app.revanced.patches.youtube.layout.navigation.homepage.fingerprints.LauncherActivityFingerprint -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 import app.revanced.util.integrations.Constants.NAVIGATION @Patch @@ -34,13 +34,15 @@ class ChangeHomePagePatch : BytecodePatch( ) { override fun execute(context: BytecodeContext): PatchResult { - LauncherActivityFingerprint.result?.mutableMethod?.let { - it.addInstructions( - it.implementation!!.instructions.size - 1, """ - move-object/from16 v0, p1 - invoke-static {v0}, $NAVIGATION->changeHomePage(Landroid/app/Activity;)V - """ - ) + LauncherActivityFingerprint.result?.let { + it.mutableMethod.apply { + addInstructions( + implementation!!.instructions.size - 1, """ + move-object/from16 v0, p1 + invoke-static {v0}, $NAVIGATION->changeHomePage(Landroid/app/Activity;)V + """ + ) + } } ?: return LauncherActivityFingerprint.toErrorResult() IntentExceptionFingerprint.result?.let { @@ -49,11 +51,11 @@ class ChangeHomePagePatch : BytecodePatch( addInstructionsWithLabels( index, """ - invoke-static {}, $NAVIGATION->changeHomePage()Z - move-result v0 - if-eqz v0, :default - return-void - """, ExternalLabel("default", getInstruction(index)) + invoke-static {}, $NAVIGATION->changeHomePage()Z + move-result v0 + if-eqz v0, :default + return-void + """, ExternalLabel("default", getInstruction(index)) ) } } ?: return IntentExceptionFingerprint.toErrorResult() diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/label/fingerprints/PivotBarSetTextFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/navigation/label/fingerprints/PivotBarSetTextFingerprint.kt similarity index 90% rename from src/main/kotlin/app/revanced/patches/youtube/layout/navigation/label/fingerprints/PivotBarSetTextFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/navigation/label/fingerprints/PivotBarSetTextFingerprint.kt index 17da1919e..0e3173b0e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/label/fingerprints/PivotBarSetTextFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/navigation/label/fingerprints/PivotBarSetTextFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.navigation.label.fingerprints +package app.revanced.patches.youtube.navigation.label.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/label/patch/NavigationLabelPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/navigation/label/patch/NavigationLabelPatch.kt similarity index 90% rename from src/main/kotlin/app/revanced/patches/youtube/layout/navigation/label/patch/NavigationLabelPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/navigation/label/patch/NavigationLabelPatch.kt index 807ebf549..273a54a11 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/label/patch/NavigationLabelPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/navigation/label/patch/NavigationLabelPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.navigation.label.patch +package app.revanced.patches.youtube.navigation.label.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -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.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.layout.navigation.label.fingerprints.PivotBarSetTextFingerprint -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 import org.jf.dexlib2.iface.instruction.OneRegisterInstruction import org.jf.dexlib2.iface.instruction.ReferenceInstruction @@ -34,9 +34,11 @@ class NavigationLabelPatch : BytecodePatch( it.mutableMethod.apply { val targetIndex = it.scanResult.patternScanResult!!.endIndex - 2 val targetReference = getInstruction(targetIndex).reference.toString() + val targetRegister = getInstruction(targetIndex).registerA + if (targetReference != "Landroid/widget/TextView;") return PivotBarSetTextFingerprint.toErrorResult() - val targetRegister = getInstruction(targetIndex).registerA + addInstruction( targetIndex + 1, "invoke-static {v$targetRegister}, $NAVIGATION->hideNavigationLabel(Landroid/widget/TextView;)V" diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/navigationbuttons/fingerprints/AutoMotiveFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/navigation/navigationbuttons/fingerprints/AutoMotiveFingerprint.kt similarity index 79% rename from src/main/kotlin/app/revanced/patches/youtube/layout/navigation/navigationbuttons/fingerprints/AutoMotiveFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/navigation/navigationbuttons/fingerprints/AutoMotiveFingerprint.kt index 0ec3fa0fb..18f07de7b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/navigationbuttons/fingerprints/AutoMotiveFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/navigation/navigationbuttons/fingerprints/AutoMotiveFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.navigation.navigationbuttons.fingerprints +package app.revanced.patches.youtube.navigation.navigationbuttons.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/navigationbuttons/fingerprints/PivotBarEnumFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/navigation/navigationbuttons/fingerprints/PivotBarEnumFingerprint.kt similarity index 81% rename from src/main/kotlin/app/revanced/patches/youtube/layout/navigation/navigationbuttons/fingerprints/PivotBarEnumFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/navigation/navigationbuttons/fingerprints/PivotBarEnumFingerprint.kt index 085dc32b0..fef851d88 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/navigationbuttons/fingerprints/PivotBarEnumFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/navigation/navigationbuttons/fingerprints/PivotBarEnumFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.navigation.navigationbuttons.fingerprints +package app.revanced.patches.youtube.navigation.navigationbuttons.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/navigationbuttons/fingerprints/PivotBarShortsButtonViewFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/navigation/navigationbuttons/fingerprints/PivotBarShortsButtonViewFingerprint.kt similarity index 78% rename from src/main/kotlin/app/revanced/patches/youtube/layout/navigation/navigationbuttons/fingerprints/PivotBarShortsButtonViewFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/navigation/navigationbuttons/fingerprints/PivotBarShortsButtonViewFingerprint.kt index a680f69c3..a1adc3a48 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/navigationbuttons/fingerprints/PivotBarShortsButtonViewFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/navigation/navigationbuttons/fingerprints/PivotBarShortsButtonViewFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.navigation.navigationbuttons.fingerprints +package app.revanced.patches.youtube.navigation.navigationbuttons.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/navigationbuttons/patch/NavigationButtonsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/navigation/navigationbuttons/patch/NavigationButtonsPatch.kt similarity index 89% rename from src/main/kotlin/app/revanced/patches/youtube/layout/navigation/navigationbuttons/patch/NavigationButtonsPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/navigation/navigationbuttons/patch/NavigationButtonsPatch.kt index cbb8aab92..0ae3ec497 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/navigationbuttons/patch/NavigationButtonsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/navigation/navigationbuttons/patch/NavigationButtonsPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.navigation.navigationbuttons.patch +package app.revanced.patches.youtube.navigation.navigationbuttons.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -15,9 +15,11 @@ 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.layout.navigation.navigationbuttons.fingerprints.* -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.NAVIGATION import app.revanced.util.pivotbar.InjectionUtils.REGISTER_TEMPLATE_REPLACEMENT import app.revanced.util.pivotbar.InjectionUtils.injectHook @@ -79,7 +81,7 @@ class NavigationButtonsPatch : BytecodePatch( /** * Create Button */ - with (parentResult.mutableMethod) { + parentResult.mutableMethod.apply { val insertIndex = implementation!!.instructions.let { val scanStart = parentResult.scanResult.patternScanResult!!.endIndex diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/shortsnavbar/fingerprints/NavigationEndpointFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/navigation/shortsnavbar/fingerprints/NavigationEndpointFingerprint.kt similarity index 82% rename from src/main/kotlin/app/revanced/patches/youtube/layout/navigation/shortsnavbar/fingerprints/NavigationEndpointFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/navigation/shortsnavbar/fingerprints/NavigationEndpointFingerprint.kt index a81ad3f44..688032dc0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/shortsnavbar/fingerprints/NavigationEndpointFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/navigation/shortsnavbar/fingerprints/NavigationEndpointFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.navigation.shortsnavbar.fingerprints +package app.revanced.patches.youtube.navigation.shortsnavbar.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/shortsnavbar/fingerprints/ReelWatchBundleFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/navigation/shortsnavbar/fingerprints/ReelWatchBundleFingerprint.kt similarity index 81% rename from src/main/kotlin/app/revanced/patches/youtube/layout/navigation/shortsnavbar/fingerprints/ReelWatchBundleFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/navigation/shortsnavbar/fingerprints/ReelWatchBundleFingerprint.kt index 5686d22dc..0a0031ccb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/shortsnavbar/fingerprints/ReelWatchBundleFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/navigation/shortsnavbar/fingerprints/ReelWatchBundleFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.navigation.shortsnavbar.fingerprints +package app.revanced.patches.youtube.navigation.shortsnavbar.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/shortsnavbar/fingerprints/ReelWatchEndpointFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/navigation/shortsnavbar/fingerprints/ReelWatchEndpointFingerprint.kt similarity index 72% rename from src/main/kotlin/app/revanced/patches/youtube/layout/navigation/shortsnavbar/fingerprints/ReelWatchEndpointFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/navigation/shortsnavbar/fingerprints/ReelWatchEndpointFingerprint.kt index c761f45db..bb689cda8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/shortsnavbar/fingerprints/ReelWatchEndpointFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/navigation/shortsnavbar/fingerprints/ReelWatchEndpointFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.navigation.shortsnavbar.fingerprints +package app.revanced.patches.youtube.navigation.shortsnavbar.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/shortsnavbar/fingerprints/ReelWatchEndpointParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/navigation/shortsnavbar/fingerprints/ReelWatchEndpointParentFingerprint.kt similarity index 74% rename from src/main/kotlin/app/revanced/patches/youtube/layout/navigation/shortsnavbar/fingerprints/ReelWatchEndpointParentFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/navigation/shortsnavbar/fingerprints/ReelWatchEndpointParentFingerprint.kt index cf0264432..a45953992 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/shortsnavbar/fingerprints/ReelWatchEndpointParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/navigation/shortsnavbar/fingerprints/ReelWatchEndpointParentFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.navigation.shortsnavbar.fingerprints +package app.revanced.patches.youtube.navigation.shortsnavbar.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/shortsnavbar/fingerprints/SetPivotBarFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/navigation/shortsnavbar/fingerprints/SetPivotBarFingerprint.kt similarity index 83% rename from src/main/kotlin/app/revanced/patches/youtube/layout/navigation/shortsnavbar/fingerprints/SetPivotBarFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/navigation/shortsnavbar/fingerprints/SetPivotBarFingerprint.kt index 69d7e7ad6..7064e8cf7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/shortsnavbar/fingerprints/SetPivotBarFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/navigation/shortsnavbar/fingerprints/SetPivotBarFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.navigation.shortsnavbar.fingerprints +package app.revanced.patches.youtube.navigation.shortsnavbar.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/shortsnavbar/patch/ShortsNavBarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/navigation/shortsnavbar/patch/ShortsNavBarPatch.kt similarity index 88% rename from src/main/kotlin/app/revanced/patches/youtube/layout/navigation/shortsnavbar/patch/ShortsNavBarPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/navigation/shortsnavbar/patch/ShortsNavBarPatch.kt index b85cdb7ea..5319bf672 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/shortsnavbar/patch/ShortsNavBarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/navigation/shortsnavbar/patch/ShortsNavBarPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.navigation.shortsnavbar.patch +package app.revanced.patches.youtube.navigation.shortsnavbar.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -18,10 +18,13 @@ 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.layout.navigation.shortsnavbar.fingerprints.* -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 +import app.revanced.patches.youtube.navigation.shortsnavbar.fingerprints.ReelWatchEndpointParentFingerprint +import app.revanced.patches.youtube.navigation.shortsnavbar.fingerprints.SetPivotBarFingerprint +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.NAVIGATION -import org.jf.dexlib2.dexbacked.reference.DexBackedTypeReference import org.jf.dexlib2.iface.instruction.OneRegisterInstruction import org.jf.dexlib2.iface.instruction.ReferenceInstruction import org.jf.dexlib2.iface.reference.FieldReference diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/tabletnavbar/fingerprints/PivotBarChangedFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/navigation/tabletnavbar/fingerprints/PivotBarChangedFingerprint.kt similarity index 82% rename from src/main/kotlin/app/revanced/patches/youtube/layout/navigation/tabletnavbar/fingerprints/PivotBarChangedFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/navigation/tabletnavbar/fingerprints/PivotBarChangedFingerprint.kt index a897aee23..4d3a54ad3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/tabletnavbar/fingerprints/PivotBarChangedFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/navigation/tabletnavbar/fingerprints/PivotBarChangedFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.navigation.tabletnavbar.fingerprints +package app.revanced.patches.youtube.navigation.tabletnavbar.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/tabletnavbar/fingerprints/PivotBarStyleFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/navigation/tabletnavbar/fingerprints/PivotBarStyleFingerprint.kt similarity index 83% rename from src/main/kotlin/app/revanced/patches/youtube/layout/navigation/tabletnavbar/fingerprints/PivotBarStyleFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/navigation/tabletnavbar/fingerprints/PivotBarStyleFingerprint.kt index a85411733..32975049c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/tabletnavbar/fingerprints/PivotBarStyleFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/navigation/tabletnavbar/fingerprints/PivotBarStyleFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.navigation.tabletnavbar.fingerprints +package app.revanced.patches.youtube.navigation.tabletnavbar.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/tabletnavbar/patch/TabletNavigationBarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/navigation/tabletnavbar/patch/TabletNavigationBarPatch.kt similarity index 84% rename from src/main/kotlin/app/revanced/patches/youtube/layout/navigation/tabletnavbar/patch/TabletNavigationBarPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/navigation/tabletnavbar/patch/TabletNavigationBarPatch.kt index 0cc925ecb..a620584f8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/tabletnavbar/patch/TabletNavigationBarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/navigation/tabletnavbar/patch/TabletNavigationBarPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.navigation.tabletnavbar.patch +package app.revanced.patches.youtube.navigation.tabletnavbar.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -14,8 +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.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.layout.navigation.tabletnavbar.fingerprints.* -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 import app.revanced.util.integrations.Constants.NAVIGATION import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @@ -56,7 +57,7 @@ class TabletNavigationBarPatch : BytecodePatch( } companion object { private fun MethodFingerprintResult.insertHook() { - val targetIndex = this.scanResult.patternScanResult!!.startIndex + 1 + val targetIndex = scanResult.patternScanResult!!.startIndex + 1 val register = mutableMethod.getInstruction(targetIndex).registerA mutableMethod.addInstructions( diff --git a/src/main/kotlin/app/revanced/patches/youtube/button/autorepeat/fingerprints/AutoNavInformerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/overlaybutton/autorepeat/fingerprints/AutoNavInformerFingerprint.kt similarity index 84% rename from src/main/kotlin/app/revanced/patches/youtube/button/autorepeat/fingerprints/AutoNavInformerFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/overlaybutton/autorepeat/fingerprints/AutoNavInformerFingerprint.kt index 3b87f3496..a46fe59ee 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/button/autorepeat/fingerprints/AutoNavInformerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/overlaybutton/autorepeat/fingerprints/AutoNavInformerFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.button.autorepeat.fingerprints +package app.revanced.patches.youtube.overlaybutton.autorepeat.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/button/autorepeat/fingerprints/RepeatListenerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/overlaybutton/autorepeat/fingerprints/RepeatListenerFingerprint.kt similarity index 87% rename from src/main/kotlin/app/revanced/patches/youtube/button/autorepeat/fingerprints/RepeatListenerFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/overlaybutton/autorepeat/fingerprints/RepeatListenerFingerprint.kt index d9cfae2d4..4cb24d6ba 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/button/autorepeat/fingerprints/RepeatListenerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/overlaybutton/autorepeat/fingerprints/RepeatListenerFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.button.autorepeat.fingerprints +package app.revanced.patches.youtube.overlaybutton.autorepeat.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/button/autorepeat/fingerprints/VideoEndFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/overlaybutton/autorepeat/fingerprints/VideoEndFingerprint.kt similarity index 84% rename from src/main/kotlin/app/revanced/patches/youtube/button/autorepeat/fingerprints/VideoEndFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/overlaybutton/autorepeat/fingerprints/VideoEndFingerprint.kt index 7253f4f3c..03ddeef5d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/button/autorepeat/fingerprints/VideoEndFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/overlaybutton/autorepeat/fingerprints/VideoEndFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.button.autorepeat.fingerprints +package app.revanced.patches.youtube.overlaybutton.autorepeat.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/button/autorepeat/fingerprints/VideoEndParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/overlaybutton/autorepeat/fingerprints/VideoEndParentFingerprint.kt similarity index 85% rename from src/main/kotlin/app/revanced/patches/youtube/button/autorepeat/fingerprints/VideoEndParentFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/overlaybutton/autorepeat/fingerprints/VideoEndParentFingerprint.kt index e6a2f3eaf..c4c018d16 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/button/autorepeat/fingerprints/VideoEndParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/overlaybutton/autorepeat/fingerprints/VideoEndParentFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.button.autorepeat.fingerprints +package app.revanced.patches.youtube.overlaybutton.autorepeat.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/button/autorepeat/patch/AutoRepeatPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/overlaybutton/autorepeat/patch/AutoRepeatPatch.kt similarity index 59% rename from src/main/kotlin/app/revanced/patches/youtube/button/autorepeat/patch/AutoRepeatPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/overlaybutton/autorepeat/patch/AutoRepeatPatch.kt index 3d928a2c2..b39cc2a80 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/button/autorepeat/patch/AutoRepeatPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/overlaybutton/autorepeat/patch/AutoRepeatPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.button.autorepeat.patch +package app.revanced.patches.youtube.overlaybutton.autorepeat.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Name @@ -14,15 +14,14 @@ 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.button.autorepeat.fingerprints.* +import app.revanced.patches.youtube.overlaybutton.autorepeat.fingerprints.* import app.revanced.util.integrations.Constants.UTILS_PATH import app.revanced.util.integrations.Constants.VIDEO_PATH import org.jf.dexlib2.builder.instruction.BuilderInstruction35c import org.jf.dexlib2.iface.instruction.OneRegisterInstruction import org.jf.dexlib2.iface.instruction.ReferenceInstruction -import org.jf.dexlib2.iface.instruction.formats.Instruction31i -@Name("always-autorepeat") +@Name("always-auto-repeat") @YouTubeCompatibility @Version("0.0.1") class AutoRepeatPatch : BytecodePatch( @@ -34,17 +33,17 @@ class AutoRepeatPatch : BytecodePatch( ) { override fun execute(context: BytecodeContext): PatchResult { VideoEndParentFingerprint.result?.classDef?.let { classDef -> - VideoEndFingerprint.also { - it.resolve(context, classDef) - }.result?.mutableMethod?.let { - it.addInstructionsWithLabels( - 0, """ - invoke-static {}, $VIDEO_PATH/VideoInformation;->shouldAutoRepeat()Z - move-result v0 - if-eqz v0, :notrepeat - return-void - """, ExternalLabel("notrepeat", it.getInstruction(0)) - ) + VideoEndFingerprint.also {it.resolve(context, classDef) }.result?.let { + it.mutableMethod.apply { + addInstructionsWithLabels( + 0, """ + invoke-static {}, $VIDEO_PATH/VideoInformation;->shouldAutoRepeat()Z + move-result v0 + if-eqz v0, :notrepeat + return-void + """, ExternalLabel("notrepeat", getInstruction(0)) + ) + } } ?: return VideoEndFingerprint.toErrorResult() } ?: return VideoEndParentFingerprint.toErrorResult() @@ -56,32 +55,33 @@ class AutoRepeatPatch : BytecodePatch( val registerC = getInstruction(targetIndex).registerC val registerD = getInstruction(targetIndex).registerD - val dummyRegister = (getInstruction(endIndex) as Instruction31i).registerA - + val dummyRegister = getInstruction(endIndex).registerA val targetReference = getInstruction(targetIndex).reference addInstructionsWithLabels( targetIndex + 1, """ - invoke-static {}, $UTILS_PATH/EnableAutoRepeatPatch;->shouldAutoRepeat()Z - move-result v$dummyRegister - if-nez v$dummyRegister, :bypass - invoke-virtual {v$registerC, v$registerD}, $targetReference - """, ExternalLabel("bypass", getInstruction(targetIndex + 1)) + invoke-static {}, $UTILS_PATH/EnableAutoRepeatPatch;->shouldAutoRepeat()Z + move-result v$dummyRegister + if-nez v$dummyRegister, :bypass + invoke-virtual {v$registerC, v$registerD}, $targetReference + """, ExternalLabel("bypass", getInstruction(targetIndex + 1)) ) removeInstruction(targetIndex) } } ?: return RepeatListenerFingerprint.toErrorResult() - AutoNavInformerFingerprint.result?.mutableMethod?.let { - val index = it.implementation!!.instructions.size - 1 - 1 - val register = it.getInstruction(index).registerA + AutoNavInformerFingerprint.result?.let { + it.mutableMethod.apply { + val index = implementation!!.instructions.size - 1 - 1 + val register = getInstruction(index).registerA - it.addInstructions( - index + 1, """ - invoke-static {v$register}, $UTILS_PATH/EnableAutoRepeatPatch;->enableAutoRepeat(Z)Z - move-result v0 - """ - ) + addInstructions( + index + 1, """ + invoke-static {v$register}, $UTILS_PATH/EnableAutoRepeatPatch;->enableAutoRepeat(Z)Z + move-result v0 + """ + ) + } } ?: return AutoNavInformerFingerprint.toErrorResult() return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/youtube/button/overlaybuttons/resource/patch/OverlayButtonsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/overlaybutton/general/patch/OverlayButtonsPatch.kt similarity index 83% rename from src/main/kotlin/app/revanced/patches/youtube/button/overlaybuttons/resource/patch/OverlayButtonsPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/overlaybutton/general/patch/OverlayButtonsPatch.kt index f1c707462..5221b9662 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/button/overlaybuttons/resource/patch/OverlayButtonsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/overlaybutton/general/patch/OverlayButtonsPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.button.overlaybuttons.resource.patch +package app.revanced.patches.youtube.overlaybutton.general.patch import app.revanced.extensions.doRecursively import app.revanced.patcher.annotation.Description @@ -11,10 +11,12 @@ 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.button.autorepeat.patch.AutoRepeatPatch -import app.revanced.patches.youtube.button.overlaybuttons.bytecode.patch.OverlayButtonsBytecodePatch -import app.revanced.patches.youtube.misc.overridespeed.bytecode.patch.OverrideSpeedHookPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 +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.BUTTON_PATH import app.revanced.util.resources.ResourceUtils import app.revanced.util.resources.ResourceUtils.copyResources import app.revanced.util.resources.ResourceUtils.copyXmlNode @@ -26,8 +28,9 @@ import org.w3c.dom.Element @DependsOn( [ AutoRepeatPatch::class, - OverlayButtonsBytecodePatch::class, + MainstreamVideoIdPatch::class, OverrideSpeedHookPatch::class, + PlayerControlsPatch::class, SettingsPatch::class ] ) @@ -36,6 +39,20 @@ import org.w3c.dom.Element class OverlayButtonsPatch : ResourcePatch { override fun execute(context: ResourceContext): PatchResult { + /** + * Inject hook + */ + arrayOf( + "Download", + "AutoRepeat", + "CopyWithTimeStamp", + "Copy", + "Speed" + ).forEach { + PlayerControlsPatch.initializeControl("$BUTTON_PATH/$it;") + PlayerControlsPatch.injectVisibility("$BUTTON_PATH/$it;") + } + /** * Copy arrays */ diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/autoplaybutton/patch/HideAutoplayButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/autoplaybutton/patch/HideAutoplayButtonPatch.kt similarity index 59% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/autoplaybutton/patch/HideAutoplayButtonPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/player/autoplaybutton/patch/HideAutoplayButtonPatch.kt index 82c0e0794..fc47a4b31 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/autoplaybutton/patch/HideAutoplayButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/autoplaybutton/patch/HideAutoplayButtonPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.player.autoplaybutton.patch +package app.revanced.patches.youtube.player.autoplaybutton.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -15,9 +15,9 @@ 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.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.autoNavPreviewId -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 import app.revanced.util.bytecode.getStringIndex import app.revanced.util.bytecode.getWideLiteralIndex import app.revanced.util.integrations.Constants.PLAYER @@ -42,25 +42,25 @@ class HideAutoplayButtonPatch : BytecodePatch( ) { override fun execute(context: BytecodeContext): PatchResult { - LayoutConstructorFingerprint.result?.mutableMethod?.let { - val insertInstruction = it.implementation!!.instructions + LayoutConstructorFingerprint.result?.let { + it.mutableMethod.apply { + val dummyRegister = getInstruction(getStringIndex("1.0x")).registerA + val insertIndex = getWideLiteralIndex(AutoNavPreviewStub) - val dummyRegister = it.getInstruction(it.getStringIndex("1.0x")).registerA - val insertIndex = it.getWideLiteralIndex(autoNavPreviewId) + val branchIndex = implementation!!.instructions.subList(insertIndex + 1, implementation!!.instructions.size - 1).indexOfFirst { instruction -> + ((instruction as? ReferenceInstruction)?.reference as? MethodReference)?.name == "addOnLayoutChangeListener" + } + 2 - val branchIndex = insertInstruction.subList(insertIndex + 1, insertInstruction.size - 1).indexOfFirst { instruction -> - ((instruction as? ReferenceInstruction)?.reference as? MethodReference)?.name == "addOnLayoutChangeListener" - } + 2 + val jumpInstruction = getInstruction(insertIndex + branchIndex) - val jumpInstruction = it.getInstruction(insertIndex + branchIndex) - - it.addInstructionsWithLabels( - insertIndex, """ - invoke-static {}, $PLAYER->hideAutoPlayButton()Z - move-result v$dummyRegister - if-nez v$dummyRegister, :hidden - """, ExternalLabel("hidden", jumpInstruction) - ) + addInstructionsWithLabels( + insertIndex, """ + invoke-static {}, $PLAYER->hideAutoPlayButton()Z + move-result v$dummyRegister + if-nez v$dummyRegister, :hidden + """, ExternalLabel("hidden", jumpInstruction) + ) + } } ?: return LayoutConstructorFingerprint.toErrorResult() /** diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/captionsbutton/patch/HideCaptionsButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/captionsbutton/patch/HideCaptionsButtonPatch.kt similarity index 61% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/captionsbutton/patch/HideCaptionsButtonPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/player/captionsbutton/patch/HideCaptionsButtonPatch.kt index a0748d72d..e9cd8915d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/captionsbutton/patch/HideCaptionsButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/captionsbutton/patch/HideCaptionsButtonPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.player.captionsbutton.patch +package app.revanced.patches.youtube.player.captionsbutton.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -6,6 +6,7 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +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 @@ -13,9 +14,10 @@ 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.misc.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.PLAYER import org.jf.dexlib2.Opcode +import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction @Patch @Name("hide-captions-button") @@ -28,18 +30,21 @@ class HideCaptionsButtonBytecodePatch : BytecodePatch( ) { override fun execute(context: BytecodeContext): PatchResult { - SubtitleButtonControllerFingerprint.result?.mutableMethod?.let { - it.implementation!!.instructions.apply { - for ((index, instruction) in this.withIndex()) { - if (instruction.opcode != Opcode.IGET_BOOLEAN) continue - - it.addInstruction( - index + 1, - "invoke-static {v0}, $PLAYER->hideCaptionsButton(Landroid/widget/ImageView;)V" - ) - - break + SubtitleButtonControllerFingerprint.result?.let { + it.mutableMethod.apply { + val targetIndex = implementation!!.instructions.indexOfFirst { instruction -> + instruction.opcode == Opcode.IGET_OBJECT } + val targetRegister = getInstruction(targetIndex).registerA + + val insertIndex = implementation!!.instructions.indexOfFirst { instruction -> + instruction.opcode == Opcode.IGET_BOOLEAN + } + 1 + + addInstruction( + insertIndex, + "invoke-static {v$targetRegister}, $PLAYER->hideCaptionsButton(Landroid/widget/ImageView;)V" + ) } } ?: return SubtitleButtonControllerFingerprint.toErrorResult() diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/castbutton/fingerprints/CastButtonFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/castbutton/fingerprints/CastButtonFingerprint.kt new file mode 100644 index 000000000..5035fa374 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/player/castbutton/fingerprints/CastButtonFingerprint.kt @@ -0,0 +1,7 @@ +package app.revanced.patches.youtube.player.castbutton.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +object CastButtonFingerprint : MethodFingerprint( + customFingerprint = { it, _ -> it.definingClass.endsWith("MediaRouteButton;") && it.name == "setVisibility" } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/castbutton/patch/HideCastButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/castbutton/patch/HideCastButtonPatch.kt similarity index 61% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/castbutton/patch/HideCastButtonPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/player/castbutton/patch/HideCastButtonPatch.kt index e032528b7..5e9829613 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/castbutton/patch/HideCastButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/castbutton/patch/HideCastButtonPatch.kt @@ -1,5 +1,6 @@ -package app.revanced.patches.youtube.layout.player.castbutton.patch +package app.revanced.patches.youtube.player.castbutton.patch +import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version @@ -11,7 +12,8 @@ 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.settings.resource.patch.SettingsPatch +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 @Patch @@ -20,23 +22,20 @@ import app.revanced.util.integrations.Constants.PLAYER @DependsOn([SettingsPatch::class]) @YouTubeCompatibility @Version("0.0.1") -class HideCastButtonPatch : BytecodePatch() { +class HideCastButtonPatch : BytecodePatch( + listOf(CastButtonFingerprint) +) { override fun execute(context: BytecodeContext): PatchResult { - context.classes.forEach { classDef -> - classDef.methods.forEach { method -> - if (classDef.type.endsWith("MediaRouteButton;") && method.name == "setVisibility") { - val setVisibilityMethod = - context.proxy(classDef).mutableClass.methods.first { it.name == "setVisibility" } - - setVisibilityMethod.addInstructions( - 0, """ - invoke-static {p1}, $PLAYER->hideCastButton(I)I - move-result p1 + CastButtonFingerprint.result?.let { + it.mutableMethod.apply { + addInstructions( + 0, """ + invoke-static {p1}, $PLAYER->hideCastButton(I)I + move-result p1 """ - ) - } + ) } - } + } ?: return CastButtonFingerprint.toErrorResult() /** * Add settings diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/collapsebutton/patch/HideCollapseButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/collapsebutton/patch/HideCollapseButtonPatch.kt similarity index 83% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/collapsebutton/patch/HideCollapseButtonPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/player/collapsebutton/patch/HideCollapseButtonPatch.kt index 5344f423b..810a01e6d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/collapsebutton/patch/HideCollapseButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/collapsebutton/patch/HideCollapseButtonPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.player.collapsebutton.patch +package app.revanced.patches.youtube.player.collapsebutton.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -10,8 +10,8 @@ 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.misc.playerbutton.patch.PlayerButtonPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.utils.playerbutton.patch.PlayerButtonPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch @Patch @Name("hide-collapse-button") diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/fingerprints/LayoutCircleFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/endscreencards/fingerprints/LayoutCircleFingerprint.kt similarity index 57% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/fingerprints/LayoutCircleFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/player/endscreencards/fingerprints/LayoutCircleFingerprint.kt index 655dc7de5..c5b792887 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/fingerprints/LayoutCircleFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/endscreencards/fingerprints/LayoutCircleFingerprint.kt @@ -1,7 +1,7 @@ -package app.revanced.patches.youtube.layout.player.endscreencards.fingerprints +package app.revanced.patches.youtube.player.endscreencards.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.layoutCircleId +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.EndScreenElementLayoutCircle import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.Opcode @@ -13,5 +13,5 @@ object LayoutCircleFingerprint : MethodFingerprint( Opcode.MOVE_RESULT_OBJECT, Opcode.CHECK_CAST, ), - customFingerprint = { it, _ -> it.isWideLiteralExists(layoutCircleId) } + customFingerprint = { it, _ -> it.isWideLiteralExists(EndScreenElementLayoutCircle) } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/fingerprints/LayoutIconFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/endscreencards/fingerprints/LayoutIconFingerprint.kt similarity index 57% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/fingerprints/LayoutIconFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/player/endscreencards/fingerprints/LayoutIconFingerprint.kt index 54ff2efb2..3dbc12fd7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/fingerprints/LayoutIconFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/endscreencards/fingerprints/LayoutIconFingerprint.kt @@ -1,7 +1,7 @@ -package app.revanced.patches.youtube.layout.player.endscreencards.fingerprints +package app.revanced.patches.youtube.player.endscreencards.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.layoutIconId +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.EndScreenElementLayoutIcon import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.Opcode @@ -13,5 +13,5 @@ object LayoutIconFingerprint : MethodFingerprint( Opcode.MOVE_RESULT_OBJECT, Opcode.CHECK_CAST, ), - customFingerprint = { it, _ -> it.isWideLiteralExists(layoutIconId) } + customFingerprint = { it, _ -> it.isWideLiteralExists(EndScreenElementLayoutIcon) } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/fingerprints/LayoutVideoFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/endscreencards/fingerprints/LayoutVideoFingerprint.kt similarity index 57% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/fingerprints/LayoutVideoFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/player/endscreencards/fingerprints/LayoutVideoFingerprint.kt index e055643d1..87a635efe 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/fingerprints/LayoutVideoFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/endscreencards/fingerprints/LayoutVideoFingerprint.kt @@ -1,7 +1,7 @@ -package app.revanced.patches.youtube.layout.player.endscreencards.fingerprints +package app.revanced.patches.youtube.player.endscreencards.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.layoutVideoId +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.EndScreenElementLayoutVideo import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.Opcode @@ -13,5 +13,5 @@ object LayoutVideoFingerprint : MethodFingerprint( Opcode.MOVE_RESULT_OBJECT, Opcode.CHECK_CAST, ), - customFingerprint = { it, _ -> it.isWideLiteralExists(layoutVideoId) } + customFingerprint = { it, _ -> it.isWideLiteralExists(EndScreenElementLayoutVideo) } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/patch/HideEndscreenCardsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/endscreencards/patch/HideEndScreenCardsPatch.kt similarity index 69% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/patch/HideEndscreenCardsPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/player/endscreencards/patch/HideEndScreenCardsPatch.kt index 178edfac1..9542d4969 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/patch/HideEndscreenCardsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/endscreencards/patch/HideEndScreenCardsPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.player.endscreencards.patch +package app.revanced.patches.youtube.player.endscreencards.patch import app.revanced.extensions.injectHideCall import app.revanced.extensions.toErrorResult @@ -14,9 +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.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.layout.player.endscreencards.fingerprints.* -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @Patch @@ -30,7 +32,7 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction ) @YouTubeCompatibility @Version("0.0.1") -class HideEndscreenCardsPatch : BytecodePatch( +class HideEndScreenCardsPatch : BytecodePatch( listOf( LayoutCircleFingerprint, LayoutIconFingerprint, @@ -40,10 +42,10 @@ class HideEndscreenCardsPatch : BytecodePatch( override fun execute(context: BytecodeContext): PatchResult { fun MethodFingerprintResult.injectHideCalls() { - val index = this.scanResult.patternScanResult!!.endIndex - this.mutableMethod.apply { - val register = getInstruction(index).registerA - this.implementation!!.injectHideCall(index + 1, register, "layout/PlayerPatch", "hideEndScreen") + val index = scanResult.patternScanResult!!.endIndex + mutableMethod.apply { + val register = this.getInstruction(index).registerA + implementation!!.injectHideCall(index + 1, register, "layout/PlayerPatch", "hideEndScreen") } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/filmstripoverlay/fingerprints/FilmStripOverlayConfigFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/filmstripoverlay/fingerprints/FilmStripOverlayConfigFingerprint.kt new file mode 100644 index 000000000..11dc2fe0c --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/player/filmstripoverlay/fingerprints/FilmStripOverlayConfigFingerprint.kt @@ -0,0 +1,10 @@ +package app.revanced.patches.youtube.player.filmstripoverlay.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.util.bytecode.isWide32LiteralExists + +object FilmStripOverlayConfigFingerprint : MethodFingerprint( + returnType = "Z", + parameters = listOf(), + customFingerprint = { it, _ -> it.isWide32LiteralExists(45381958) } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/filmstripoverlay/fingerprints/FilmStripOverlayInteractionFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/filmstripoverlay/fingerprints/FilmStripOverlayInteractionFingerprint.kt new file mode 100644 index 000000000..f78cfa546 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/player/filmstripoverlay/fingerprints/FilmStripOverlayInteractionFingerprint.kt @@ -0,0 +1,11 @@ +package app.revanced.patches.youtube.player.filmstripoverlay.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags + +object FilmStripOverlayInteractionFingerprint : MethodFingerprint( + returnType = "Z", + accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC, + parameters = listOf("L") +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/filmstripoverlay/fingerprints/FilmStripOverlayParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/filmstripoverlay/fingerprints/FilmStripOverlayParentFingerprint.kt new file mode 100644 index 000000000..6cab63276 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/player/filmstripoverlay/fingerprints/FilmStripOverlayParentFingerprint.kt @@ -0,0 +1,13 @@ +package app.revanced.patches.youtube.player.filmstripoverlay.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.Scrubbing +import app.revanced.util.bytecode.isWideLiteralExists +import org.jf.dexlib2.AccessFlags + +object FilmStripOverlayParentFingerprint : MethodFingerprint( + returnType = "V", + accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, + customFingerprint = { it, _ -> it.isWideLiteralExists(Scrubbing) } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/filmstripoverlay/fingerprints/FilmStripOverlayPreviewFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/filmstripoverlay/fingerprints/FilmStripOverlayPreviewFingerprint.kt new file mode 100644 index 000000000..f56472385 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/player/filmstripoverlay/fingerprints/FilmStripOverlayPreviewFingerprint.kt @@ -0,0 +1,14 @@ +package app.revanced.patches.youtube.player.filmstripoverlay.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.Opcode + +object FilmStripOverlayPreviewFingerprint : MethodFingerprint( + returnType = "Z", + parameters = listOf("F"), + opcodes = listOf( + Opcode.SUB_FLOAT, + Opcode.INVOKE_STATIC, + Opcode.MOVE_RESULT + ) +) \ No newline at end of file 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 new file mode 100644 index 000000000..321f79cf0 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/player/filmstripoverlay/fingerprints/TimeBarOnClickListenerFingerprint.kt @@ -0,0 +1,10 @@ +package app.revanced.patches.youtube.player.filmstripoverlay.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.WatchWhileTimeBarOverlayStub +import app.revanced.util.bytecode.isWideLiteralExists + +object TimeBarOnClickListenerFingerprint : MethodFingerprint( + returnType = "V", + 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 new file mode 100644 index 000000000..6a3bdd17f --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/player/filmstripoverlay/patch/HideFilmstripOverlayPatch.kt @@ -0,0 +1,113 @@ +package app.revanced.patches.youtube.player.filmstripoverlay.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +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.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.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.resourceid.patch.SharedResourceIdPatch +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.WatchWhileTimeBarOverlayStub +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch +import app.revanced.util.bytecode.getWideLiteralIndex +import app.revanced.util.integrations.Constants.PLAYER +import org.jf.dexlib2.Opcode +import org.jf.dexlib2.iface.instruction.OneRegisterInstruction +import org.jf.dexlib2.iface.instruction.formats.Instruction35c +import org.jf.dexlib2.iface.reference.MethodReference + +@Patch +@Name("hide-filmstrip-overlay") +@Description("Hide filmstrip overlay on swipe controls.") +@DependsOn( + [ + SettingsPatch::class, + SharedResourceIdPatch::class + ] +) +@YouTubeCompatibility +@Version("0.0.1") +class HideFilmstripOverlayPatch : BytecodePatch( + listOf( + FilmStripOverlayParentFingerprint, + TimeBarOnClickListenerFingerprint + ) +) { + override fun execute(context: BytecodeContext): PatchResult { + + FilmStripOverlayParentFingerprint.result?.classDef?.let { classDef -> + arrayOf( + FilmStripOverlayConfigFingerprint, + FilmStripOverlayInteractionFingerprint, + FilmStripOverlayPreviewFingerprint + ).forEach { fingerprint -> + fingerprint.also { it.resolve(context, classDef) }.result?.mutableMethod?.injectHook() + ?: return fingerprint.toErrorResult() + } + } ?: return FilmStripOverlayParentFingerprint.toErrorResult() + + TimeBarOnClickListenerFingerprint.result?.let { + it.mutableMethod.apply { + val freeIndex = getWideLiteralIndex(WatchWhileTimeBarOverlayStub) + val freeRegister = getInstruction(freeIndex).registerA + + val insertIndex = getIndex("bringChildToFront") + 1 + val jumpIndex = getIndex("setOnClickListener") + 3 + + addInstructionsWithLabels( + insertIndex, """ + invoke-static {}, $PLAYER->hideFilmstripOverlay()Z + move-result v$freeRegister + if-nez v$freeRegister, :hidden + """, ExternalLabel("hidden", getInstruction(jumpIndex)) + ) + } + } ?: return TimeBarOnClickListenerFingerprint.toErrorResult() + + /** + * Add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: PLAYER_SETTINGS", + "SETTINGS: HIDE_FILMSTRIP_OVERLAY" + ) + ) + + SettingsPatch.updatePatchStatus("hide-filmstrip-overlay") + + return PatchResultSuccess() + } + private companion object { + fun MutableMethod.injectHook() { + addInstructionsWithLabels( + 0, """ + invoke-static {}, $PLAYER->hideFilmstripOverlay()Z + move-result v0 + if-eqz v0, :shown + const/4 v0, 0x0 + return v0 + """, ExternalLabel("shown", getInstruction(0)) + ) + } + + fun MutableMethod.getIndex(methodName: String): Int { + return implementation!!.instructions.indexOfFirst { instruction -> + if (instruction.opcode != Opcode.INVOKE_VIRTUAL) return@indexOfFirst false + + return@indexOfFirst ((instruction as Instruction35c).reference as MethodReference).name == methodName + } + } + } +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/fingerprints/MarkerHapticsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/hapticfeedback/fingerprints/MarkerHapticsFingerprint.kt similarity index 67% rename from src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/fingerprints/MarkerHapticsFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/player/hapticfeedback/fingerprints/MarkerHapticsFingerprint.kt index d140c2452..d11cc9253 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/fingerprints/MarkerHapticsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/hapticfeedback/fingerprints/MarkerHapticsFingerprint.kt @@ -1,7 +1,8 @@ -package app.revanced.patches.youtube.layout.fullscreen.hapticfeedback.fingerprints +package app.revanced.patches.youtube.player.hapticfeedback.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint object MarkerHapticsFingerprint : MethodFingerprint( + returnType = "V", strings = listOf("Failed to execute markers haptics vibrate.") ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/fingerprints/ScrubbingHapticsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/hapticfeedback/fingerprints/ScrubbingHapticsFingerprint.kt similarity index 68% rename from src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/fingerprints/ScrubbingHapticsFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/player/hapticfeedback/fingerprints/ScrubbingHapticsFingerprint.kt index c78605e12..907f61153 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/fingerprints/ScrubbingHapticsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/hapticfeedback/fingerprints/ScrubbingHapticsFingerprint.kt @@ -1,7 +1,8 @@ -package app.revanced.patches.youtube.layout.fullscreen.hapticfeedback.fingerprints +package app.revanced.patches.youtube.player.hapticfeedback.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint object ScrubbingHapticsFingerprint : MethodFingerprint( + returnType = "V", strings = listOf("Failed to haptics vibrate for fine scrubbing.") ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/hapticfeedback/fingerprints/SeekHapticsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/hapticfeedback/fingerprints/SeekHapticsFingerprint.kt new file mode 100644 index 000000000..59b06d200 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/player/hapticfeedback/fingerprints/SeekHapticsFingerprint.kt @@ -0,0 +1,15 @@ +package app.revanced.patches.youtube.player.hapticfeedback.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.Opcode + +object SeekHapticsFingerprint : MethodFingerprint( + returnType = "V", + opcodes = listOf( + Opcode.SGET, + Opcode.CONST_16, + Opcode.IF_LE + ), + strings = listOf("Failed to easy seek haptics vibrate."), + customFingerprint = { it, _ -> it.name == "run" } +) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/fingerprints/ZoomHapticsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/hapticfeedback/fingerprints/ZoomHapticsFingerprint.kt similarity index 66% rename from src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/fingerprints/ZoomHapticsFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/player/hapticfeedback/fingerprints/ZoomHapticsFingerprint.kt index 6ac8fb782..0c463104b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/fingerprints/ZoomHapticsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/hapticfeedback/fingerprints/ZoomHapticsFingerprint.kt @@ -1,7 +1,8 @@ -package app.revanced.patches.youtube.layout.fullscreen.hapticfeedback.fingerprints +package app.revanced.patches.youtube.player.hapticfeedback.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint object ZoomHapticsFingerprint : MethodFingerprint( + returnType = "V", strings = listOf("Failed to haptics vibrate for video zoom") ) \ No newline at end of file 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 new file mode 100644 index 000000000..cbe818202 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/player/hapticfeedback/patch/HapticFeedBackPatch.kt @@ -0,0 +1,95 @@ +package app.revanced.patches.youtube.player.hapticfeedback.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +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.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.settings.resource.patch.SettingsPatch +import app.revanced.util.integrations.Constants.PLAYER +import org.jf.dexlib2.iface.instruction.OneRegisterInstruction + +@Patch +@Name("disable-haptic-feedback") +@Description("Disable haptic feedback when swiping.") +@DependsOn([SettingsPatch::class]) +@YouTubeCompatibility +@Version("0.0.1") +class HapticFeedBackPatch : BytecodePatch( + listOf( + MarkerHapticsFingerprint, + SeekHapticsFingerprint, + ScrubbingHapticsFingerprint, + ZoomHapticsFingerprint + ) +) { + override fun execute(context: BytecodeContext): PatchResult { + + arrayOf( + SeekHapticsFingerprint to "disableSeekVibrate", + ScrubbingHapticsFingerprint to "disableScrubbingVibrate", + MarkerHapticsFingerprint to "disableChapterVibrate", + ZoomHapticsFingerprint to "disableZoomVibrate" + ).map { (fingerprint, name) -> fingerprint.injectHook(name) } + + /** + * Add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: PLAYER_SETTINGS", + "SETTINGS: DISABLE_HAPTIC_FEEDBACK" + ) + ) + + SettingsPatch.updatePatchStatus("disable-haptic-feedback") + + return PatchResultSuccess() + } + + private companion object { + fun MethodFingerprint.injectHook(methodName: String) { + result?.let { + it.mutableMethod.apply { + var index = 0 + var register = 0 + + if (this.name == "run") { + index = it.scanResult.patternScanResult!!.startIndex + register = getInstruction(index).registerA + } + + injectHook(index, register, methodName) + } + } ?: throw toErrorResult() + } + + fun MutableMethod.injectHook( + index: Int, + register: Int, + name: String + ) { + addInstructionsWithLabels( + index, """ + invoke-static {}, $PLAYER->$name()Z + move-result v$register + if-eqz v$register, :vibrate + return-void + """, ExternalLabel("vibrate", getInstruction(index)) + ) + } + } +} + diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/infocards/fingerprints/InfocardsIncognitoFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/infocards/fingerprints/InfoCardsIncognitoFingerprint.kt similarity index 57% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/infocards/fingerprints/InfocardsIncognitoFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/player/infocards/fingerprints/InfoCardsIncognitoFingerprint.kt index b97e7f286..3dd9b99df 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/infocards/fingerprints/InfocardsIncognitoFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/infocards/fingerprints/InfoCardsIncognitoFingerprint.kt @@ -1,11 +1,13 @@ -package app.revanced.patches.youtube.layout.player.infocards.fingerprints +package app.revanced.patches.youtube.player.infocards.fingerprints 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 InfocardsIncognitoFingerprint : MethodFingerprint( +object InfoCardsIncognitoFingerprint : MethodFingerprint( returnType = "L", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + opcodes = listOf(Opcode.IGET_BOOLEAN), strings = listOf("vibrator") ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/infocards/fingerprints/InfocardsIncognitoParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/infocards/fingerprints/InfoCardsIncognitoParentFingerprint.kt similarity index 67% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/infocards/fingerprints/InfocardsIncognitoParentFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/player/infocards/fingerprints/InfoCardsIncognitoParentFingerprint.kt index 88f50b306..d8dd09516 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/infocards/fingerprints/InfocardsIncognitoParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/infocards/fingerprints/InfoCardsIncognitoParentFingerprint.kt @@ -1,10 +1,10 @@ -package app.revanced.patches.youtube.layout.player.infocards.fingerprints +package app.revanced.patches.youtube.player.infocards.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.AccessFlags -object InfocardsIncognitoParentFingerprint : MethodFingerprint( +object InfoCardsIncognitoParentFingerprint : MethodFingerprint( returnType = "L", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, strings = listOf("player_overlay_info_card_teaser"), 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 new file mode 100644 index 000000000..fc17f41c6 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/player/infocards/patch/HideInfoCardsPatch.kt @@ -0,0 +1,63 @@ +package app.revanced.patches.youtube.player.infocards.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +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.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.player.infocards.fingerprints.InfoCardsIncognitoFingerprint +import app.revanced.patches.youtube.player.infocards.fingerprints.InfoCardsIncognitoParentFingerprint +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch +import app.revanced.util.integrations.Constants.PLAYER +import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction + +@Patch +@Name("hide-info-cards") +@Description("Hides info-cards in videos.") +@DependsOn([SettingsPatch::class]) +@YouTubeCompatibility +@Version("0.0.1") +class HideInfoCardsPatch : BytecodePatch( + listOf(InfoCardsIncognitoParentFingerprint) +) { + override fun execute(context: BytecodeContext): PatchResult { + InfoCardsIncognitoParentFingerprint.result?.classDef?.let { classDef -> + InfoCardsIncognitoFingerprint.also { it.resolve(context, classDef) }.result?.let { + it.mutableMethod.apply { + val targetIndex = it.scanResult.patternScanResult!!.startIndex + val targetRegister = getInstruction(targetIndex).registerA + + addInstructions( + targetIndex + 1, """ + invoke-static {v$targetRegister}, $PLAYER->hideInfoCard(Z)Z + move-result v$targetRegister + """ + ) + } + } ?: return InfoCardsIncognitoFingerprint.toErrorResult() + } ?: return InfoCardsIncognitoParentFingerprint.toErrorResult() + + /** + * Add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: PLAYER_SETTINGS", + "SETTINGS: HIDE_INFO_CARDS" + ) + ) + + SettingsPatch.updatePatchStatus("hide-info-cards") + + return PatchResultSuccess() + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/livechatbutton/patch/HideLiveChatButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/livechatbutton/patch/HideLiveChatButtonPatch.kt similarity index 84% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/livechatbutton/patch/HideLiveChatButtonPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/player/livechatbutton/patch/HideLiveChatButtonPatch.kt index a4fd86f76..3c21bddb6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/livechatbutton/patch/HideLiveChatButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/livechatbutton/patch/HideLiveChatButtonPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.player.livechatbutton.patch +package app.revanced.patches.youtube.player.livechatbutton.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -10,8 +10,8 @@ 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.misc.playerbutton.patch.PlayerButtonPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.utils.playerbutton.patch.PlayerButtonPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch @Patch @Name("hide-live-chat-button") diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/musicbutton/fingerprints/MusicAppDeeplinkButtonFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/musicbutton/fingerprints/MusicAppDeeplinkButtonFingerprint.kt similarity index 79% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/musicbutton/fingerprints/MusicAppDeeplinkButtonFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/player/musicbutton/fingerprints/MusicAppDeeplinkButtonFingerprint.kt index 841957472..2fb20072d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/musicbutton/fingerprints/MusicAppDeeplinkButtonFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/musicbutton/fingerprints/MusicAppDeeplinkButtonFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.player.musicbutton.fingerprints +package app.revanced.patches.youtube.player.musicbutton.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/musicbutton/patch/HideMusicButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/musicbutton/patch/HideMusicButtonPatch.kt similarity index 65% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/musicbutton/patch/HideMusicButtonPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/player/musicbutton/patch/HideMusicButtonPatch.kt index 21ac136e7..c94662b40 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/musicbutton/patch/HideMusicButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/musicbutton/patch/HideMusicButtonPatch.kt @@ -1,12 +1,12 @@ -package app.revanced.patches.youtube.layout.player.musicbutton.patch +package app.revanced.patches.youtube.player.musicbutton.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +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 @@ -14,10 +14,9 @@ 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.layout.player.musicbutton.fingerprints.MusicAppDeeplinkButtonFingerprint -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 -import org.jf.dexlib2.iface.instruction.Instruction @Patch @Name("hide-music-button") @@ -30,15 +29,14 @@ class HideMusicButtonPatch : BytecodePatch( ){ override fun execute(context: BytecodeContext): PatchResult { - MusicAppDeeplinkButtonFingerprint.result?.mutableMethod?.let { - it.implementation!!.instructions.apply { - val jumpInstruction = this[size - 1] as Instruction - it.addInstructionsWithLabels( + MusicAppDeeplinkButtonFingerprint.result?.let { + it.mutableMethod.apply { + addInstructionsWithLabels( 0, """ - invoke-static {}, $PLAYER->hideMusicButton()Z - move-result v0 - if-nez v0, :hidden - """, ExternalLabel("hidden", jumpInstruction) + invoke-static {}, $PLAYER->hideMusicButton()Z + move-result v0 + if-nez v0, :hidden + """, 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 new file mode 100644 index 000000000..7235b2511 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/player/playerbuttonbg/fingerprints/HidePlayerButtonFingerprint.kt @@ -0,0 +1,7 @@ +package app.revanced.patches.youtube.player.playerbuttonbg.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.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/layout/player/playerbuttonbg/patch/HidePlayerButtonBackgroundPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/playerbuttonbg/patch/HidePlayerButtonBackgroundPatch.kt similarity index 76% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/playerbuttonbg/patch/HidePlayerButtonBackgroundPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/player/playerbuttonbg/patch/HidePlayerButtonBackgroundPatch.kt index 91ca72c31..366790559 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/playerbuttonbg/patch/HidePlayerButtonBackgroundPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/playerbuttonbg/patch/HidePlayerButtonBackgroundPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.player.playerbuttonbg.patch +package app.revanced.patches.youtube.player.playerbuttonbg.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -12,9 +12,9 @@ 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.layout.player.playerbuttonbg.fingerprints.HidePlayerButtonFingerprint -import app.revanced.patches.youtube.misc.playerbutton.patch.PlayerButtonPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 import app.revanced.util.integrations.Constants.INTEGRATIONS_PATH @Patch @@ -35,7 +35,9 @@ class HidePlayerButtonBackgroundPatch : BytecodePatch( HidePlayerButtonFingerprint.result?.mutableMethod?.addInstruction( 0, - "invoke-static { p0 }, $INTEGRATIONS_PATH/utils/ResourceHelper;->hidePlayerButtonBackground(Landroid/view/View;)V" + "invoke-static {p0}, " + + "$INTEGRATIONS_PATH/utils/ResourceHelper;->" + + "hidePlayerButtonBackground(Landroid/view/View;)V" ) ?: return HidePlayerButtonFingerprint.toErrorResult() /** 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 new file mode 100644 index 000000000..957dbe38c --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/player/playeroverlayfilter/fingerprints/ScrimOverlayFingerprint.kt @@ -0,0 +1,9 @@ +package app.revanced.patches.youtube.player.playeroverlayfilter.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.ScrimOverlay +import app.revanced.util.bytecode.isWideLiteralExists + +object ScrimOverlayFingerprint : MethodFingerprint( + 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/layout/player/playeroverlayfilter/patch/PlayerOverlayFilterPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/playeroverlayfilter/patch/PlayerOverlayFilterPatch.kt similarity index 60% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/playeroverlayfilter/patch/PlayerOverlayFilterPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/player/playeroverlayfilter/patch/PlayerOverlayFilterPatch.kt index 7397a95c3..8abcf2a6f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/playeroverlayfilter/patch/PlayerOverlayFilterPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/playeroverlayfilter/patch/PlayerOverlayFilterPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.player.playeroverlayfilter.patch +package app.revanced.patches.youtube.player.playeroverlayfilter.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -14,10 +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.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.layout.player.playeroverlayfilter.fingerprints.ScrimOverlayFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.scrimOverlayId -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.bytecode.getWideLiteralIndex import app.revanced.util.integrations.Constants.PLAYER import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @@ -39,18 +39,20 @@ class PlayerOverlayFilterPatch : BytecodePatch( ) { override fun execute(context: BytecodeContext): PatchResult { - ScrimOverlayFingerprint.result?.mutableMethod?.let { - val targetIndex = it.getWideLiteralIndex(scrimOverlayId) + 3 - val targetParameter = it.getInstruction(targetIndex).reference - val targetRegister = it.getInstruction(targetIndex).registerA + ScrimOverlayFingerprint.result?.let { + it.mutableMethod.apply { + val targetIndex = getWideLiteralIndex(ScrimOverlay) + 3 + val targetParameter = getInstruction(targetIndex).reference + val targetRegister = getInstruction(targetIndex).registerA - if (!targetParameter.toString().endsWith("Landroid/widget/ImageView;")) - return PatchResultError("Method signature parameter did not match: $targetParameter") + if (!targetParameter.toString().endsWith("Landroid/widget/ImageView;")) + return PatchResultError("Method signature parameter did not match: $targetParameter") - it.addInstruction( - targetIndex + 1, - "invoke-static {v$targetRegister}, $PLAYER->hidePlayerOverlayFilter(Landroid/widget/ImageView;)V" - ) + addInstruction( + targetIndex + 1, + "invoke-static {v$targetRegister}, $PLAYER->hidePlayerOverlayFilter(Landroid/widget/ImageView;)V" + ) + } } ?: return ScrimOverlayFingerprint.toErrorResult() /** diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/patch/MixPlaylistsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/previousnextbutton/patch/HidePreviousNextButtonPatch.kt similarity index 58% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/patch/MixPlaylistsPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/player/previousnextbutton/patch/HidePreviousNextButtonPatch.kt index 785fde312..9ab346bb8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/patch/MixPlaylistsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/previousnextbutton/patch/HidePreviousNextButtonPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.mixplaylists.patch +package app.revanced.patches.youtube.player.previousnextbutton.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -10,21 +10,21 @@ 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.litho.patch.ByteBufferFilterPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.utils.playerbutton.patch.PlayerButtonPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch @Patch -@Name("hide-mix-playlists") -@Description("Removes mix playlists from home feed and video player.") +@Name("hide-previous-next-button") +@Description("Hides the previous and next button in the player controller.") @DependsOn( [ - ByteBufferFilterPatch::class, + PlayerButtonPatch::class, SettingsPatch::class ] ) @YouTubeCompatibility @Version("0.0.1") -class MixPlaylistsPatch : BytecodePatch() { +class HidePreviousNextButtonPatch : BytecodePatch() { override fun execute(context: BytecodeContext): PatchResult { /** @@ -32,12 +32,12 @@ class MixPlaylistsPatch : BytecodePatch() { */ SettingsPatch.addPreference( arrayOf( - "PREFERENCE: GENERAL_SETTINGS", - "SETTINGS: HIDE_MIX_PLAYLISTS" + "PREFERENCE: PLAYER_SETTINGS", + "SETTINGS: HIDE_PREVIOUS_NEXT_BUTTON" ) ) - SettingsPatch.updatePatchStatus("hide-mix-playlists") + SettingsPatch.updatePatchStatus("hide-previous-next-button") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/seekmessage/fingerprints/SeekEduContainerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/seekmessage/fingerprints/SeekEduContainerFingerprint.kt new file mode 100644 index 000000000..955502332 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/player/seekmessage/fingerprints/SeekEduContainerFingerprint.kt @@ -0,0 +1,10 @@ +package app.revanced.patches.youtube.player.seekmessage.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.EasySeekEduContainer +import app.revanced.util.bytecode.isWideLiteralExists + +object SeekEduContainerFingerprint : MethodFingerprint( + returnType = "V", + customFingerprint = { it, _ -> it.isWideLiteralExists(EasySeekEduContainer) } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/seekmessage/patch/SeekMessagePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/seekmessage/patch/SeekMessagePatch.kt similarity index 59% rename from src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/seekmessage/patch/SeekMessagePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/player/seekmessage/patch/SeekMessagePatch.kt index 0af8e8cd2..c69c21314 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/seekmessage/patch/SeekMessagePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/seekmessage/patch/SeekMessagePatch.kt @@ -1,5 +1,6 @@ -package app.revanced.patches.youtube.layout.fullscreen.seekmessage.patch +package app.revanced.patches.youtube.player.seekmessage.patch +import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version @@ -13,10 +14,10 @@ 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.layout.fullscreen.seekmessage.fingerprints.SeekEduContainerFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.integrations.Constants.FULLSCREEN +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 +import app.revanced.util.integrations.Constants.PLAYER @Patch @Name("hide-seek-message") @@ -34,23 +35,25 @@ class SeekMessagePatch : BytecodePatch( ) { override fun execute(context: BytecodeContext): PatchResult { - SeekEduContainerFingerprint.result?.mutableMethod?.let { - it.addInstructionsWithLabels( - 0, """ - invoke-static {}, $FULLSCREEN->hideSeekMessage()Z - move-result v0 - if-eqz v0, :default - return-void - """, ExternalLabel("default", it.getInstruction(0)) - ) - } + SeekEduContainerFingerprint.result?.let { + it.mutableMethod.apply { + addInstructionsWithLabels( + 0, """ + invoke-static {}, $PLAYER->hideSeekMessage()Z + move-result v0 + if-eqz v0, :default + return-void + """, ExternalLabel("default", getInstruction(0)) + ) + } + } ?: return SeekEduContainerFingerprint.toErrorResult() /** * Add settings */ SettingsPatch.addPreference( arrayOf( - "PREFERENCE: FULLSCREEN_SETTINGS", + "PREFERENCE: PLAYER_SETTINGS", "SETTINGS: HIDE_SEEK_MESSAGE" ) ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/suggestactions/fingerprints/SuggestedActionsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/suggestactions/fingerprints/SuggestedActionsFingerprint.kt similarity index 58% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/suggestactions/fingerprints/SuggestedActionsFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/player/suggestactions/fingerprints/SuggestedActionsFingerprint.kt index c9ce39278..0eae3375f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/suggestactions/fingerprints/SuggestedActionsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/suggestactions/fingerprints/SuggestedActionsFingerprint.kt @@ -1,7 +1,7 @@ -package app.revanced.patches.youtube.layout.player.suggestactions.fingerprints +package app.revanced.patches.youtube.player.suggestactions.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.suggestedActionId +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.SuggestedAction import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.Opcode @@ -13,5 +13,5 @@ object SuggestedActionsFingerprint : MethodFingerprint( Opcode.INVOKE_VIRTUAL, Opcode.MOVE_RESULT_OBJECT ), - customFingerprint = { it, _ -> it.isWideLiteralExists(suggestedActionId) } + customFingerprint = { it, _ -> it.isWideLiteralExists(SuggestedAction) } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/suggestactions/patch/SuggestedActionsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/suggestactions/patch/SuggestedActionsPatch.kt similarity index 81% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/suggestactions/patch/SuggestedActionsPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/player/suggestactions/patch/SuggestedActionsPatch.kt index 635db0bca..82792ea1b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/suggestactions/patch/SuggestedActionsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/suggestactions/patch/SuggestedActionsPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.player.suggestactions.patch +package app.revanced.patches.youtube.player.suggestactions.patch import app.revanced.extensions.injectHideCall import app.revanced.extensions.toErrorResult @@ -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.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.layout.player.suggestactions.fingerprints.SuggestedActionsFingerprint -import app.revanced.patches.youtube.misc.litho.patch.ByteBufferFilterPatch -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.player.suggestactions.fingerprints.SuggestedActionsFingerprint +import app.revanced.patches.youtube.misc.litho.patch.LithoFilterPatch +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @Patch @@ -24,7 +24,7 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @Description("Hide the suggested actions bar inside the player.") @DependsOn( [ - ByteBufferFilterPatch::class, + LithoFilterPatch::class, SettingsPatch::class, SharedResourceIdPatch::class ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/watermark/fingerprints/HideWatermarkFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/watermark/fingerprints/HideWatermarkFingerprint.kt similarity index 86% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/watermark/fingerprints/HideWatermarkFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/player/watermark/fingerprints/HideWatermarkFingerprint.kt index e62d600da..ffa1eac4a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/watermark/fingerprints/HideWatermarkFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/watermark/fingerprints/HideWatermarkFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.player.watermark.fingerprints +package app.revanced.patches.youtube.player.watermark.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/watermark/fingerprints/HideWatermarkParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/watermark/fingerprints/HideWatermarkParentFingerprint.kt similarity index 82% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/watermark/fingerprints/HideWatermarkParentFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/player/watermark/fingerprints/HideWatermarkParentFingerprint.kt index f082b6f43..6c5d60e8b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/watermark/fingerprints/HideWatermarkParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/watermark/fingerprints/HideWatermarkParentFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.player.watermark.fingerprints +package app.revanced.patches.youtube.player.watermark.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/watermark/patch/HideChannelWatermarkPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/watermark/patch/HideChannelWatermarkPatch.kt similarity index 87% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/watermark/patch/HideChannelWatermarkPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/player/watermark/patch/HideChannelWatermarkPatch.kt index 3c3d9b8e8..20c86438d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/watermark/patch/HideChannelWatermarkPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/watermark/patch/HideChannelWatermarkPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.player.watermark.patch +package app.revanced.patches.youtube.player.watermark.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -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.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.layout.player.watermark.fingerprints.HideWatermarkFingerprint -import app.revanced.patches.youtube.layout.player.watermark.fingerprints.HideWatermarkParentFingerprint -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 import app.revanced.util.integrations.Constants.PLAYER import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction 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 new file mode 100644 index 000000000..1b280b057 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbar/patch/HideSeekbarPatch.kt @@ -0,0 +1,70 @@ +package app.revanced.patches.youtube.seekbar.seekbar.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +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.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.seekbar.seekbarcolor.resource.patch.SeekbarColorResourcePatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch +import app.revanced.util.integrations.Constants.SEEKBAR + +@Patch +@Name("hide-seekbar") +@Description("Hides the seekbar in video player and video thumbnails.") +@DependsOn( + [ + SeekbarColorResourcePatch::class, + SettingsPatch::class + ] +) +@YouTubeCompatibility +@Version("0.0.1") +class HideSeekbarPatch : BytecodePatch( + listOf(SeekbarFingerprint) +) { + override fun execute(context: BytecodeContext): PatchResult { + + SeekbarFingerprint.result?.mutableClass?.let { mutableClass -> + SeekbarOnDrawFingerprint.also { it.resolve(context, mutableClass) }.result?.let { + it.mutableMethod.apply { + addInstructionsWithLabels( + 0, """ + invoke-static {}, $SEEKBAR->hideSeekbar()Z + move-result v0 + if-eqz v0, :show_seekbar + return-void + """, ExternalLabel("show_seekbar", getInstruction(0)) + ) + } + } ?: return SeekbarOnDrawFingerprint.toErrorResult() + } ?: return SeekbarFingerprint.toErrorResult() + + /** + * Add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: SEEKBAR_SETTINGS", + "SETTINGS: HIDE_SEEKBAR", + "SETTINGS: HIDE_SEEKBAR_THUMBNAIL" + ) + ) + + SettingsPatch.updatePatchStatus("hide-seekbar") + + return PatchResultSuccess() + } +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/bytecode/fingerprints/ProgressColorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/bytecode/fingerprints/ProgressColorFingerprint.kt similarity index 74% rename from src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/bytecode/fingerprints/ProgressColorFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/bytecode/fingerprints/ProgressColorFingerprint.kt index 72c85a1a9..7169fe854 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/bytecode/fingerprints/ProgressColorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/bytecode/fingerprints/ProgressColorFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.seekbar.seekbarcolor.bytecode.fingerprints +package app.revanced.patches.youtube.seekbar.seekbarcolor.bytecode.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/bytecode/fingerprints/SeekbarColorFingerprint.kt new file mode 100644 index 000000000..240a5eb76 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/bytecode/fingerprints/SeekbarColorFingerprint.kt @@ -0,0 +1,9 @@ +package app.revanced.patches.youtube.seekbar.seekbarcolor.bytecode.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.InlineTimeBarColorizedBarPlayedColorDark +import app.revanced.util.bytecode.isWideLiteralExists + +object SeekbarColorFingerprint : MethodFingerprint( + customFingerprint = { it, _ -> it.isWideLiteralExists(InlineTimeBarColorizedBarPlayedColorDark) } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/bytecode/patch/SeekbarColorBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/bytecode/patch/SeekbarColorPatch.kt similarity index 57% rename from src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/bytecode/patch/SeekbarColorBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/bytecode/patch/SeekbarColorPatch.kt index e865444f3..97630ecb7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/bytecode/patch/SeekbarColorBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/bytecode/patch/SeekbarColorPatch.kt @@ -1,10 +1,10 @@ -package app.revanced.patches.youtube.layout.seekbar.seekbarcolor.bytecode.patch +package app.revanced.patches.youtube.seekbar.seekbarcolor.bytecode.patch import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve @@ -12,39 +12,45 @@ 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.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.layout.seekbar.seekbarcolor.bytecode.fingerprints.* +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.misc.litho.patch.LithoThemePatch -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.inlineTimeBarColorizedBarPlayedColorDarkId -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.inlineTimeBarPlayedNotHighlightedColorId +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.util.bytecode.getWideLiteralIndex -import app.revanced.util.integrations.Constants.INTEGRATIONS_PATH import app.revanced.util.integrations.Constants.SEEKBAR import org.jf.dexlib2.iface.instruction.OneRegisterInstruction -@Name("custom-seekbar-color-bytecode-patch") +@Patch +@Name("custom-seekbar-color") +@Description("Change seekbar color in video player and video thumbnails.") @DependsOn( [ LithoThemePatch::class, - SharedResourceIdPatch::class + SeekbarColorResourcePatch::class, + SettingsPatch::class, + SharedResourceIdPatch::class, ] ) @YouTubeCompatibility @Version("0.0.1") -class SeekbarColorBytecodePatch : BytecodePatch( +class SeekbarColorPatch : BytecodePatch( listOf( - ControlsOverlayParentFingerprint, ControlsOverlayStyleFingerprint, SeekbarColorFingerprint ) ) { override fun execute(context: BytecodeContext): PatchResult { SeekbarColorFingerprint.result?.mutableMethod?.let { - it.hook(it.getWideLiteralIndex(inlineTimeBarColorizedBarPlayedColorDarkId) + 2) - it.hook(it.getWideLiteralIndex(inlineTimeBarPlayedNotHighlightedColorId) + 2) + it.hook(it.getWideLiteralIndex(InlineTimeBarColorizedBarPlayedColorDark) + 2) + it.hook(it.getWideLiteralIndex(InlineTimeBarPlayedNotHighlightedColor) + 2) } ?: return SeekbarColorFingerprint.toErrorResult() ControlsOverlayStyleFingerprint.result?.let { parentResult -> @@ -56,21 +62,19 @@ class SeekbarColorBytecodePatch : BytecodePatch( ) ?: return ProgressColorFingerprint.toErrorResult() } ?: return ControlsOverlayStyleFingerprint.toErrorResult() + LithoThemePatch.injectCall("$SEEKBAR->getLithoColor(I)I") /** - * Context called when playing a video in the PlayStore - * If this context is not overridden, Exception occurs when reading a value from SharedPreference (ROOT Build) - * - * TODO: merging into abstract integrations patch + * Add settings */ - ControlsOverlayParentFingerprint.result?.let { parentResult -> - ControlsOverlayFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.addInstruction( - 0, - "sput-object p1, $INTEGRATIONS_PATH/utils/ReVancedUtils;->context:Landroid/content/Context;" - ) ?: return ControlsOverlayFingerprint.toErrorResult() - } ?: return ControlsOverlayParentFingerprint.toErrorResult() + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: SEEKBAR_SETTINGS", + "SETTINGS: CUSTOM_SEEKBAR_COLOR" + ) + ) - LithoThemePatch.injectCall("$SEEKBAR->resumedProgressBarColor(I)I") + SettingsPatch.updatePatchStatus("custom-seekbar-color") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/resource/patch/SeekbarColorPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/resource/patch/SeekbarColorResourcePatch.kt similarity index 59% rename from src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/resource/patch/SeekbarColorPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/resource/patch/SeekbarColorResourcePatch.kt index 4c9dbf8a9..b06319369 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/resource/patch/SeekbarColorPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/resource/patch/SeekbarColorResourcePatch.kt @@ -1,6 +1,5 @@ -package app.revanced.patches.youtube.layout.seekbar.seekbarcolor.resource.patch +package app.revanced.patches.youtube.seekbar.seekbarcolor.resource.patch -import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.ResourceContext @@ -8,25 +7,13 @@ 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.layout.seekbar.seekbarcolor.bytecode.patch.SeekbarColorBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import org.w3c.dom.Element -@Patch -@Name("custom-seekbar-color") -@Description("Change seekbar color and progressbar color.") -@DependsOn( - [ - SeekbarColorBytecodePatch::class, - SettingsPatch::class - ] -) +@Name("custom-seekbar-color-resource-patch") @YouTubeCompatibility @Version("0.0.1") -class SeekbarColorPatch : ResourcePatch { +class SeekbarColorResourcePatch : ResourcePatch { override fun execute(context: ResourceContext): PatchResult { context.xmlEditor["res/drawable/resume_playback_progressbar_drawable.xml"].use { @@ -42,18 +29,6 @@ class SeekbarColorPatch : ResourcePatch { scaleNode.replaceChild(replacementNode, shapeNode) } - /** - * Add settings - */ - SettingsPatch.addPreference( - arrayOf( - "PREFERENCE: SEEKBAR_SETTINGS", - "SETTINGS: CUSTOM_SEEKBAR_COLOR" - ) - ) - - SettingsPatch.updatePatchStatus("custom-seekbar-color") - return PatchResultSuccess() } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/speed/patch/AppendSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/seekbar/speed/patch/AppendSpeedPatch.kt similarity index 71% rename from src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/speed/patch/AppendSpeedPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/seekbar/speed/patch/AppendSpeedPatch.kt index f39361b9d..5c6e69b66 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/speed/patch/AppendSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/seekbar/speed/patch/AppendSpeedPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.seekbar.speed.patch +package app.revanced.patches.youtube.seekbar.speed.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -15,9 +15,9 @@ 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.misc.overridespeed.bytecode.patch.OverrideSpeedHookPatch -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 import app.revanced.util.integrations.Constants.SEEKBAR import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.ReferenceInstruction @@ -39,28 +39,27 @@ class AppendSpeedPatch : BytecodePatch( listOf(TotalTimeFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { - TotalTimeFingerprint.result?.mutableMethod?.let { - it.implementation!!.instructions.apply { + TotalTimeFingerprint.result?.let { + it.mutableMethod.apply { var insertIndex = -1 - for ((targetIndex, targetInstruction) in withIndex()) { + for ((targetIndex, targetInstruction) in implementation!!.instructions.withIndex()) { if (targetInstruction.opcode != Opcode.INVOKE_VIRTUAL) continue - if (it.getInstruction(targetIndex).reference.toString() == + if (getInstruction(targetIndex).reference.toString() == "Landroid/widget/TextView;->getText()Ljava/lang/CharSequence;") { insertIndex = targetIndex + 2 - val insertRegister = it.getInstruction(insertIndex).registerC + val insertRegister = getInstruction(insertIndex).registerC - it.addInstructions( + addInstructions( insertIndex, """ - invoke-static {v$insertRegister}, $SEEKBAR->enableTimeStampSpeed(Ljava/lang/String;)Ljava/lang/String; - move-result-object v$insertRegister - """ + invoke-static {v$insertRegister}, $SEEKBAR->enableTimeStampSpeed(Ljava/lang/String;)Ljava/lang/String; + move-result-object v$insertRegister + """ ) break } } - if (insertIndex == -1) return PatchResultError("target Instruction not found!") } 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 new file mode 100644 index 000000000..5f1b62b23 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/seekbar/tapping/fingerprints/SeekbarTappingFingerprint.kt @@ -0,0 +1,30 @@ +package app.revanced.patches.youtube.seekbar.tapping.fingerprints + +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 SeekbarTappingFingerprint : MethodFingerprint( + returnType = "Z", + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + parameters = listOf("L"), + opcodes = listOf( + Opcode.IPUT_OBJECT, + Opcode.INVOKE_VIRTUAL, + Opcode.RETURN, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT, + Opcode.IF_EQZ, + Opcode.INVOKE_VIRTUAL, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT, + Opcode.IF_EQZ, + Opcode.INT_TO_FLOAT, + Opcode.INT_TO_FLOAT, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT, + Opcode.IF_EQZ + ), + customFingerprint = { it, _ -> it.name == "onTouchEvent"} +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/seekbar/tapping/fingerprints/SeekbarTappingReferenceFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/seekbar/tapping/fingerprints/SeekbarTappingReferenceFingerprint.kt new file mode 100644 index 000000000..4cdcd96b1 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/seekbar/tapping/fingerprints/SeekbarTappingReferenceFingerprint.kt @@ -0,0 +1,31 @@ +package app.revanced.patches.youtube.seekbar.tapping.fingerprints + +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 SeekbarTappingReferenceFingerprint : MethodFingerprint( + returnType = "Z", + accessFlags = AccessFlags.PUBLIC or AccessFlags.PUBLIC, + parameters = listOf("L"), + opcodes = listOf( + Opcode.INVOKE_VIRTUAL, // oMethodReference + Opcode.RETURN, + Opcode.IGET_OBJECT, + Opcode.IGET_BOOLEAN, + Opcode.IF_EQZ, + Opcode.INVOKE_VIRTUAL, + Opcode.RETURN, + Opcode.INT_TO_FLOAT, + Opcode.INT_TO_FLOAT, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT, + Opcode.IF_NEZ, + Opcode.RETURN, + Opcode.INVOKE_VIRTUAL, + Opcode.INVOKE_VIRTUAL, // pMethodReference + Opcode.RETURN + ), + 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 new file mode 100644 index 000000000..b29b21713 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/seekbar/tapping/patch/SeekbarTappingPatch.kt @@ -0,0 +1,77 @@ +package app.revanced.patches.youtube.seekbar.tapping.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +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.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.seekbar.tapping.fingerprints.SeekbarTappingFingerprint +import app.revanced.patches.youtube.seekbar.tapping.fingerprints.SeekbarTappingReferenceFingerprint +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch +import app.revanced.util.integrations.Constants.SEEKBAR +import org.jf.dexlib2.iface.instruction.ReferenceInstruction + +@Patch +@Name("enable-seekbar-tapping") +@Description("Enables tap-to-seek on the seekbar of the video player.") +@DependsOn([SettingsPatch::class]) +@YouTubeCompatibility +@Version("0.0.1") +class SeekbarTappingPatch : BytecodePatch( + listOf( + SeekbarTappingReferenceFingerprint, + SeekbarTappingFingerprint + ) +) { + override fun execute(context: BytecodeContext): PatchResult { + SeekbarTappingReferenceFingerprint.result?.let { + it.mutableMethod.apply { + TappingLabel = """ + invoke-static {}, $SEEKBAR->enableSeekbarTapping()Z + move-result v0 + if-eqz v0, :disabled + invoke-virtual { p0, v2 }, ${getInstruction(it.scanResult.patternScanResult!!.startIndex).reference} + invoke-virtual { p0, v2 }, ${getInstruction(it.scanResult.patternScanResult!!.endIndex - 1).reference} + """ + } + } ?: return SeekbarTappingReferenceFingerprint.toErrorResult() + + SeekbarTappingFingerprint.result?.let { + it.mutableMethod.apply { + val insertIndex = it.scanResult.patternScanResult!!.startIndex + 2 + + addInstructionsWithLabels( + insertIndex, + TappingLabel, + ExternalLabel("disabled", getInstruction(insertIndex)) + ) + } + } ?: return SeekbarTappingFingerprint.toErrorResult() + + /** + * Add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: SEEKBAR_SETTINGS", + "SETTINGS: ENABLE_SEEKBAR_TAPPING" + ) + ) + + SettingsPatch.updatePatchStatus("enable-seekbar-tapping") + + return PatchResultSuccess() + } + private companion object { + lateinit var TappingLabel: String + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/timestamps/fingerprints/TimeCounterFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/seekbar/timestamps/fingerprints/TimeCounterFingerprint.kt similarity index 73% rename from src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/timestamps/fingerprints/TimeCounterFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/seekbar/timestamps/fingerprints/TimeCounterFingerprint.kt index f6a7fd9e3..4019b985d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/timestamps/fingerprints/TimeCounterFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/seekbar/timestamps/fingerprints/TimeCounterFingerprint.kt @@ -1,16 +1,14 @@ -package app.revanced.patches.youtube.layout.seekbar.timestamps.fingerprints +package app.revanced.patches.youtube.seekbar.timestamps.fingerprints import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -@FuzzyPatternScanMethod(3) object TimeCounterFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, - parameters = listOf(), + parameters = emptyList(), opcodes = listOf( Opcode.IGET_OBJECT, Opcode.IGET_WIDE, @@ -23,5 +21,6 @@ object TimeCounterFingerprint : MethodFingerprint( Opcode.MOVE_RESULT, Opcode.IF_EQZ, Opcode.GOTO - ) + ), + customFingerprint = { _, classDef -> classDef.methods.count() == 14 } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/timestamps/patch/HideTimeStampPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/seekbar/timestamps/patch/HideTimeStampPatch.kt similarity index 68% rename from src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/timestamps/patch/HideTimeStampPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/seekbar/timestamps/patch/HideTimeStampPatch.kt index 31df788e4..9d550f49c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/timestamps/patch/HideTimeStampPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/seekbar/timestamps/patch/HideTimeStampPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.seekbar.timestamps.patch +package app.revanced.patches.youtube.seekbar.timestamps.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -14,8 +14,8 @@ 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.layout.seekbar.timestamps.fingerprints.TimeCounterFingerprint -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 @Patch @@ -29,15 +29,17 @@ class HideTimeStampPatch : BytecodePatch( ) { override fun execute(context: BytecodeContext): PatchResult { - TimeCounterFingerprint.result?.mutableMethod?.let { - it.addInstructionsWithLabels( - 0, """ - invoke-static {}, $SEEKBAR->hideTimeStamp()Z - move-result v0 - if-eqz v0, :show_time_stamp - return-void - """, ExternalLabel("show_time_stamp", it.getInstruction(0)) - ) + TimeCounterFingerprint.result?.let { + it.mutableMethod.apply { + addInstructionsWithLabels( + 0, """ + invoke-static {}, $SEEKBAR->hideTimeStamp()Z + move-result v0 + if-eqz v0, :show_time_stamp + return-void + """, ExternalLabel("show_time_stamp", getInstruction(0)) + ) + } } ?: return TimeCounterFingerprint.toErrorResult() /** diff --git a/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/fingerprints/ShortsCommentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/fingerprints/ShortsCommentFingerprint.kt new file mode 100644 index 000000000..b641093ef --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/fingerprints/ShortsCommentFingerprint.kt @@ -0,0 +1,9 @@ +package app.revanced.patches.youtube.shorts.shortscomponent.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.RightComment +import app.revanced.util.bytecode.isWideLiteralExists + +object ShortsCommentFingerprint : MethodFingerprint( + customFingerprint = { it, _ -> it.isWideLiteralExists(RightComment) } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/fingerprints/ShortsInfoPanelFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/fingerprints/ShortsInfoPanelFingerprint.kt new file mode 100644 index 000000000..29798f803 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/fingerprints/ShortsInfoPanelFingerprint.kt @@ -0,0 +1,10 @@ +package app.revanced.patches.youtube.shorts.shortscomponent.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.ReelPlayerInfoPanel +import app.revanced.util.bytecode.isWideLiteralExists + +object ShortsInfoPanelFingerprint : MethodFingerprint( + returnType = "V", + customFingerprint = { it, _ -> it.isWideLiteralExists(ReelPlayerInfoPanel) } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/fingerprints/ShortsPaidContentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/fingerprints/ShortsPaidContentFingerprint.kt new file mode 100644 index 000000000..03b237e30 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/fingerprints/ShortsPaidContentFingerprint.kt @@ -0,0 +1,9 @@ +package app.revanced.patches.youtube.shorts.shortscomponent.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.ReelPlayerBadge +import app.revanced.util.bytecode.isWideLiteralExists + +object ShortsPaidContentFingerprint : MethodFingerprint( + customFingerprint = { it, _ -> it.isWideLiteralExists(ReelPlayerBadge) } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/fingerprints/ShortsRemixFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/fingerprints/ShortsRemixFingerprint.kt new file mode 100644 index 000000000..b955b753d --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/fingerprints/ShortsRemixFingerprint.kt @@ -0,0 +1,9 @@ +package app.revanced.patches.youtube.shorts.shortscomponent.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.ReelDynRemix +import app.revanced.util.bytecode.isWideLiteralExists + +object ShortsRemixFingerprint : MethodFingerprint( + customFingerprint = { it, _ -> it.isWideLiteralExists(ReelDynRemix) } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/fingerprints/ShortsSubscriptionsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/fingerprints/ShortsSubscriptionsFingerprint.kt new file mode 100644 index 000000000..425221d75 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/fingerprints/ShortsSubscriptionsFingerprint.kt @@ -0,0 +1,9 @@ +package app.revanced.patches.youtube.shorts.shortscomponent.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.ReelPlayerPausedStateButton +import app.revanced.util.bytecode.isWideLiteralExists + +object ShortsSubscriptionsFingerprint : MethodFingerprint( + customFingerprint = { it, _ -> it.isWideLiteralExists(ReelPlayerPausedStateButton) } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/fingerprints/ShortsSubscriptionsTabletFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/fingerprints/ShortsSubscriptionsTabletFingerprint.kt similarity index 80% rename from src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/fingerprints/ShortsSubscriptionsTabletFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/fingerprints/ShortsSubscriptionsTabletFingerprint.kt index a8d7bec32..b13f92bbc 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/fingerprints/ShortsSubscriptionsTabletFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/fingerprints/ShortsSubscriptionsTabletFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.shorts.shortscomponent.fingerprints +package app.revanced.patches.youtube.shorts.shortscomponent.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/fingerprints/ShortsSubscriptionsTabletParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/fingerprints/ShortsSubscriptionsTabletParentFingerprint.kt new file mode 100644 index 000000000..6db9eb7d1 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/fingerprints/ShortsSubscriptionsTabletParentFingerprint.kt @@ -0,0 +1,9 @@ +package app.revanced.patches.youtube.shorts.shortscomponent.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.ReelPlayerFooter +import app.revanced.util.bytecode.isWideLiteralExists + +object ShortsSubscriptionsTabletParentFingerprint : MethodFingerprint( + customFingerprint = { it, _ -> it.isWideLiteralExists(ReelPlayerFooter) } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/patch/ShortsCommentButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsCommentButtonPatch.kt similarity index 58% rename from src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/patch/ShortsCommentButtonPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsCommentButtonPatch.kt index 5bce8b2b7..82e1458dd 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/patch/ShortsCommentButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsCommentButtonPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.shorts.shortscomponent.patch +package app.revanced.patches.youtube.shorts.shortscomponent.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Name @@ -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.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.layout.shorts.shortscomponent.fingerprints.ShortsCommentFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.rightCommentId +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 import app.revanced.util.integrations.Constants.SHORTS import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @@ -23,14 +23,16 @@ class ShortsCommentButtonPatch : BytecodePatch( listOf(ShortsCommentFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { - ShortsCommentFingerprint.result?.mutableMethod?.let { - val insertIndex = it.getWideLiteralIndex(rightCommentId) + 3 - val insertRegister = it.getInstruction(insertIndex).registerA + ShortsCommentFingerprint.result?.let { + it.mutableMethod.apply { + val insertIndex = getWideLiteralIndex(RightComment) + 3 + val insertRegister = getInstruction(insertIndex).registerA - it.addInstruction( - insertIndex + 1, - "invoke-static {v$insertRegister}, $SHORTS->hideShortsPlayerCommentsButton(Landroid/view/View;)V" - ) + addInstruction( + insertIndex + 1, + "invoke-static {v$insertRegister}, $SHORTS->hideShortsPlayerCommentsButton(Landroid/view/View;)V" + ) + } } ?: return ShortsCommentFingerprint.toErrorResult() return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/patch/ShortsComponentPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsComponentPatch.kt similarity index 75% rename from src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/patch/ShortsComponentPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsComponentPatch.kt index 8a332bef9..f2c8c3f6a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/patch/ShortsComponentPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsComponentPatch.kt @@ -12,8 +12,13 @@ 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.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 +import app.revanced.patches.youtube.shorts.shortscomponent.patch.ShortsRemixButtonPatch +import app.revanced.patches.youtube.shorts.shortscomponent.patch.ShortsSubscriptionsButtonPatch +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus @Patch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/patch/ShortsInfoPanelPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsInfoPanelPatch.kt similarity index 54% rename from src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/patch/ShortsInfoPanelPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsInfoPanelPatch.kt index a8a85ea54..b2d549397 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/patch/ShortsInfoPanelPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsInfoPanelPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.shorts.shortscomponent.patch +package app.revanced.patches.youtube.shorts.shortscomponent.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Name @@ -10,8 +10,9 @@ 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.layout.shorts.shortscomponent.fingerprints.ShortsInfoPanelFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.reelPlayerInfoPanelId +import app.revanced.patches.youtube.shorts.shortscomponent.fingerprints.ShortsInfoPanelFingerprint +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.ReelPlayerInfoPanel + import app.revanced.util.bytecode.getWideLiteralIndex import app.revanced.util.integrations.Constants.SHORTS import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @@ -23,16 +24,18 @@ class ShortsInfoPanelPatch : BytecodePatch( listOf(ShortsInfoPanelFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { - ShortsInfoPanelFingerprint.result?.mutableMethod?.let { - val insertIndex = it.getWideLiteralIndex(reelPlayerInfoPanelId) + 3 - val insertRegister = it.getInstruction(insertIndex).registerA + ShortsInfoPanelFingerprint.result?.let { + it.mutableMethod.apply { + val insertIndex = getWideLiteralIndex(ReelPlayerInfoPanel) + 3 + val insertRegister = getInstruction(insertIndex).registerA - it.addInstructions( - insertIndex + 1, """ - invoke-static {v$insertRegister}, $SHORTS->hideShortsPlayerInfoPanel(Landroid/view/ViewGroup;)Landroid/view/ViewGroup; - move-result-object v$insertRegister - """ - ) + addInstructions( + insertIndex + 1, """ + invoke-static {v$insertRegister}, $SHORTS->hideShortsPlayerInfoPanel(Landroid/view/ViewGroup;)Landroid/view/ViewGroup; + move-result-object v$insertRegister + """ + ) + } } ?: return ShortsInfoPanelFingerprint.toErrorResult() return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/patch/ShortsPaidContentBannerPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsPaidContentBannerPatch.kt similarity index 64% rename from src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/patch/ShortsPaidContentBannerPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsPaidContentBannerPatch.kt index 5e4301df2..054074185 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/patch/ShortsPaidContentBannerPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsPaidContentBannerPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.shorts.shortscomponent.patch +package app.revanced.patches.youtube.shorts.shortscomponent.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Name @@ -11,9 +11,9 @@ 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.layout.shorts.shortscomponent.fingerprints.ShortsPaidContentFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.reelPlayerBadge2Id -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.reelPlayerBadgeId +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 import app.revanced.util.bytecode.getWideLiteralIndex import app.revanced.util.integrations.Constants.SHORTS import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @@ -25,16 +25,18 @@ class ShortsPaidContentBannerPatch : BytecodePatch( listOf(ShortsPaidContentFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { - ShortsPaidContentFingerprint.result?.mutableMethod?.let { - val primaryIndex = it.getWideLiteralIndex(reelPlayerBadgeId) + 3 - val secondaryIndex = it.getWideLiteralIndex(reelPlayerBadge2Id) + 3 + ShortsPaidContentFingerprint.result?.let { + it.mutableMethod.apply { + val primaryIndex = getWideLiteralIndex(ReelPlayerBadge) + 3 + val secondaryIndex = getWideLiteralIndex(ReelPlayerBadge2) + 3 - if (primaryIndex > secondaryIndex) { - it.insertHook(primaryIndex) - it.insertHook(secondaryIndex) - } else { - it.insertHook(secondaryIndex) - it.insertHook(primaryIndex) + if (primaryIndex > secondaryIndex) { + insertHook(primaryIndex) + insertHook(secondaryIndex) + } else { + insertHook(secondaryIndex) + insertHook(primaryIndex) + } } } ?: return ShortsPaidContentFingerprint.toErrorResult() diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/patch/ShortsRemixButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsRemixButtonPatch.kt similarity index 58% rename from src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/patch/ShortsRemixButtonPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsRemixButtonPatch.kt index 1d0934785..33bdf97f9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/patch/ShortsRemixButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsRemixButtonPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.shorts.shortscomponent.patch +package app.revanced.patches.youtube.shorts.shortscomponent.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Name @@ -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.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.layout.shorts.shortscomponent.fingerprints.ShortsRemixFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.reelRemixId +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 import app.revanced.util.integrations.Constants.SHORTS import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @@ -23,14 +23,17 @@ class ShortsRemixButtonPatch : BytecodePatch( listOf(ShortsRemixFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { - ShortsRemixFingerprint.result?.mutableMethod?.let { - val insertIndex = it.getWideLiteralIndex(reelRemixId) - 2 - val insertRegister = it.getInstruction(insertIndex).registerA + ShortsRemixFingerprint.result?.let { + it.mutableMethod.apply { + val insertIndex = getWideLiteralIndex(ReelDynRemix) - 2 + val insertRegister = getInstruction(insertIndex).registerA - it.addInstruction( - insertIndex, - "invoke-static {v$insertRegister}, $SHORTS->hideShortsPlayerRemixButton(Landroid/view/View;)V" - ) + addInstruction( + insertIndex, + "invoke-static {v$insertRegister}, $SHORTS->hideShortsPlayerRemixButton(Landroid/view/View;)V" + ) + + } } ?: return ShortsRemixFingerprint.toErrorResult() return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/patch/ShortsSubscriptionsButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsSubscriptionsButtonPatch.kt similarity index 72% rename from src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/patch/ShortsSubscriptionsButtonPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsSubscriptionsButtonPatch.kt index 634870e6a..eb24ac5d6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/shortscomponent/patch/ShortsSubscriptionsButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsSubscriptionsButtonPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.shorts.shortscomponent.patch +package app.revanced.patches.youtube.shorts.shortscomponent.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Name @@ -12,9 +12,11 @@ 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.layout.shorts.shortscomponent.fingerprints.* -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.reelPlayerFooterId -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.reelPlayerPausedId +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 +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.ReelPlayerFooter +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.ReelPlayerPausedStateButton import app.revanced.util.bytecode.getWideLiteralIndex import app.revanced.util.integrations.Constants.SHORTS import org.jf.dexlib2.Opcode @@ -33,19 +35,21 @@ class ShortsSubscriptionsButtonPatch : BytecodePatch( ) ) { override fun execute(context: BytecodeContext): PatchResult { - ShortsSubscriptionsFingerprint.result?.mutableMethod?.let { - val insertIndex = it.getWideLiteralIndex(reelPlayerPausedId) + 2 - val insertRegister = it.getInstruction(insertIndex).registerA + ShortsSubscriptionsFingerprint.result?.let { + it.mutableMethod.apply { + val insertIndex = getWideLiteralIndex(ReelPlayerPausedStateButton) + 2 + val insertRegister = getInstruction(insertIndex).registerA - it.addInstruction( - insertIndex + 1, - "invoke-static {v$insertRegister}, $SHORTS->hideShortsPlayerSubscriptionsButton(Landroid/view/View;)V" - ) + addInstruction( + insertIndex + 1, + "invoke-static {v$insertRegister}, $SHORTS->hideShortsPlayerSubscriptionsButton(Landroid/view/View;)V" + ) + } } ?: return ShortsSubscriptionsFingerprint.toErrorResult() ShortsSubscriptionsTabletParentFingerprint.result?.let { parentResult -> parentResult.mutableMethod.apply { - val targetIndex = getWideLiteralIndex(reelPlayerFooterId) - 1 + val targetIndex = getWideLiteralIndex(ReelPlayerFooter) - 1 if (getInstruction(targetIndex).opcode != Opcode.IPUT) return ShortsSubscriptionsTabletFingerprint.toErrorResult() subscriptionFieldReference = (getInstruction(targetIndex)).reference as FieldReference } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/startupshortsreset/fingerprints/UserWasInShortsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/startupshortsreset/fingerprints/UserWasInShortsFingerprint.kt similarity index 88% rename from src/main/kotlin/app/revanced/patches/youtube/layout/shorts/startupshortsreset/fingerprints/UserWasInShortsFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/shorts/startupshortsreset/fingerprints/UserWasInShortsFingerprint.kt index 9dea80969..fbe3b7eff 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/startupshortsreset/fingerprints/UserWasInShortsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/startupshortsreset/fingerprints/UserWasInShortsFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.shorts.startupshortsreset.fingerprints +package app.revanced.patches.youtube.shorts.startupshortsreset.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/startupshortsreset/patch/DisableShortsOnStartupPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/startupshortsreset/patch/DisableShortsOnStartupPatch.kt similarity index 80% rename from src/main/kotlin/app/revanced/patches/youtube/layout/shorts/startupshortsreset/patch/DisableShortsOnStartupPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/shorts/startupshortsreset/patch/DisableShortsOnStartupPatch.kt index f312eb6ce..e2cb62187 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/startupshortsreset/patch/DisableShortsOnStartupPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/startupshortsreset/patch/DisableShortsOnStartupPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.shorts.startupshortsreset.patch +package app.revanced.patches.youtube.shorts.startupshortsreset.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -14,8 +14,8 @@ 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.layout.shorts.startupshortsreset.fingerprints.UserWasInShortsFingerprint -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @@ -32,15 +32,15 @@ class DisableShortsOnStartupPatch : BytecodePatch( UserWasInShortsFingerprint.result?.let { it.mutableMethod.apply { - val insertIndex = it.scanResult.patternScanResult!!.endIndex + 1 - val register = getInstruction(insertIndex - 1).registerA + 2 + val targetIndex = it.scanResult.patternScanResult!!.endIndex + val register = getInstruction(targetIndex).registerA + 2 addInstructionsWithLabels( - insertIndex, """ + 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(insertIndex)) + """, ExternalLabel("show_startup_shorts_player", getInstruction(targetIndex + 1)) ) } } ?: return UserWasInShortsFingerprint.toErrorResult() diff --git a/src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrolshdr/fingerprints/HDRVideoFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/swipe/hdrbrightness/fingerprints/HDRBrightnessFingerprint.kt similarity index 55% rename from src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrolshdr/fingerprints/HDRVideoFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/swipe/hdrbrightness/fingerprints/HDRBrightnessFingerprint.kt index e33467592..83d6ee5d5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrolshdr/fingerprints/HDRVideoFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/swipe/hdrbrightness/fingerprints/HDRBrightnessFingerprint.kt @@ -1,8 +1,8 @@ -package app.revanced.patches.youtube.swipe.swipecontrolshdr.fingerprints +package app.revanced.patches.youtube.swipe.hdrbrightness.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -object HDRVideoFingerprint : MethodFingerprint( +object HDRBrightnessFingerprint : MethodFingerprint( returnType = "V", strings = listOf("mediaViewambientBrightnessSensor") ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrolshdr/patch/SwipeControlsHDRPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/swipe/hdrbrightness/patch/HDRBrightnessPatch.kt similarity index 50% rename from src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrolshdr/patch/SwipeControlsHDRPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/swipe/hdrbrightness/patch/HDRBrightnessPatch.kt index 15a1d7bc0..b32c660a5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrolshdr/patch/SwipeControlsHDRPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/swipe/hdrbrightness/patch/HDRBrightnessPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.swipe.swipecontrolshdr.patch +package app.revanced.patches.youtube.swipe.hdrbrightness.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Name @@ -11,29 +11,29 @@ 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.swipe.swipecontrolshdr.fingerprints.HDRVideoFingerprint +import app.revanced.patches.youtube.swipe.hdrbrightness.fingerprints.HDRBrightnessFingerprint import app.revanced.util.integrations.Constants.SWIPE_PATH -@Name("swipe-controls-hdr") +@Name("disable-hdr-auto-brightness") @YouTubeCompatibility @Version("0.0.1") -class SwipeControlsHDRPatch : BytecodePatch( - listOf( - HDRVideoFingerprint - ) +class HDRBrightnessPatch : BytecodePatch( + listOf(HDRBrightnessFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { - HDRVideoFingerprint.result?.mutableMethod?.let { - it.addInstructionsWithLabels( - 0, """ - invoke-static {}, $SWIPE_PATH/EnableSwipeGestureBrightnessInHDRPatch;->enableSwipeGestureBrightnessInHDR()Z - move-result v0 - if-eqz v0, :default - return-void - """, ExternalLabel("default", it.getInstruction(0)) - ) - } ?: return HDRVideoFingerprint.toErrorResult() + HDRBrightnessFingerprint.result?.let { + it.mutableMethod.apply { + addInstructionsWithLabels( + 0, """ + invoke-static {}, $SWIPE_PATH/DisableHDRAutoBrightnessPatch;->disableHDRAutoBrightness()Z + move-result v0 + if-eqz v0, :default + return-void + """, ExternalLabel("default", getInstruction(0)) + ) + } + } ?: return HDRBrightnessFingerprint.toErrorResult() return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrols/bytecode/fingerprints/SwipeControlsHostActivityFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrols/bytecode/fingerprints/SwipeControlsHostActivityFingerprint.kt index d03071028..e77ccb7d1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrols/bytecode/fingerprints/SwipeControlsHostActivityFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrols/bytecode/fingerprints/SwipeControlsHostActivityFingerprint.kt @@ -1,9 +1,11 @@ package app.revanced.patches.youtube.swipe.swipecontrols.bytecode.fingerprints +import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags object SwipeControlsHostActivityFingerprint : MethodFingerprint( - customFingerprint = { it, _ -> it.definingClass == "Lapp/revanced/integrations/swipecontrols/SwipeControlsHostActivity;" - && it.name == "" - } + accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, + parameters = emptyList(), + customFingerprint = { it, _ -> it.definingClass == "Lapp/revanced/integrations/swipecontrols/SwipeControlsHostActivity;" } ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrols/bytecode/fingerprints/WatchWhileActivityFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrols/bytecode/fingerprints/WatchWhileActivityFingerprint.kt index 6bd59f247..c777e8455 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrols/bytecode/fingerprints/WatchWhileActivityFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrols/bytecode/fingerprints/WatchWhileActivityFingerprint.kt @@ -1,10 +1,11 @@ package app.revanced.patches.youtube.swipe.swipecontrols.bytecode.fingerprints +import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags object WatchWhileActivityFingerprint : MethodFingerprint( - customFingerprint = { it, _ -> - it.definingClass.endsWith("WatchWhileActivity;") - && it.name == "" - } + accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, + parameters = emptyList(), + customFingerprint = { it, _ -> it.definingClass.endsWith("WatchWhileActivity;") && it.name == "" } ) 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 1eb7af9a0..297d4cf3c 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 @@ -12,7 +12,7 @@ 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.misc.playertype.patch.PlayerTypeHookPatch +import app.revanced.patches.youtube.utils.playertype.patch.PlayerTypeHookPatch import app.revanced.patches.youtube.swipe.swipecontrols.bytecode.fingerprints.SwipeControlsHostActivityFingerprint import app.revanced.patches.youtube.swipe.swipecontrols.bytecode.fingerprints.WatchWhileActivityFingerprint import org.jf.dexlib2.AccessFlags @@ -21,11 +21,7 @@ import org.jf.dexlib2.immutable.ImmutableMethod @Name("swipe-controls-bytecode-patch") @YouTubeCompatibility @Version("0.0.3") -@DependsOn( - [ - PlayerTypeHookPatch::class - ] -) +@DependsOn([PlayerTypeHookPatch::class]) class SwipeControlsBytecodePatch : BytecodePatch( listOf( SwipeControlsHostActivityFingerprint, 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 fda5b3c4d..1a95ae92b 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 @@ -10,9 +10,9 @@ 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.misc.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.swipe.hdrbrightness.patch.HDRBrightnessPatch import app.revanced.patches.youtube.swipe.swipecontrols.bytecode.patch.SwipeControlsBytecodePatch -import app.revanced.patches.youtube.swipe.swipecontrolshdr.patch.SwipeControlsHDRPatch +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.resources.ResourceUtils import app.revanced.util.resources.ResourceUtils.copyResources @@ -21,9 +21,9 @@ import app.revanced.util.resources.ResourceUtils.copyResources @Description("Adds volume and brightness swipe controls.") @DependsOn( [ + HDRBrightnessPatch::class, SettingsPatch::class, - SwipeControlsBytecodePatch::class, - SwipeControlsHDRPatch::class + SwipeControlsBytecodePatch::class ] ) @YouTubeCompatibility @@ -31,7 +31,7 @@ import app.revanced.util.resources.ResourceUtils.copyResources class SwipeControlsPatch : ResourcePatch { override fun execute(context: ResourceContext): PatchResult { - /* + /** * Add settings */ SettingsPatch.addPreference( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/clientspoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt similarity index 82% rename from src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/fix/clientspoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt index 24dc8022b..9f86e63e8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/clientspoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.clientspoof.fingerprints +package app.revanced.patches.youtube.utils.fix.clientspoof.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/patch/ClientSpoofPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/clientspoof/patch/ClientSpoofPatch.kt similarity index 76% rename from src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/patch/ClientSpoofPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/fix/clientspoof/patch/ClientSpoofPatch.kt index d537cd005..7ba516fae 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/patch/ClientSpoofPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/clientspoof/patch/ClientSpoofPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.clientspoof.patch +package app.revanced.patches.youtube.utils.fix.clientspoof.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -10,10 +10,9 @@ 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.patcher.patch.annotations.Patch import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.misc.clientspoof.fingerprints.UserAgentHeaderBuilderFingerprint -import app.revanced.patches.youtube.misc.microg.shared.Constants.PACKAGE_NAME +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 @Name("client-spoof") @@ -29,7 +28,11 @@ class ClientSpoofPatch : BytecodePatch( it.mutableMethod.apply { val insertIndex = it.scanResult.patternScanResult!!.endIndex val packageNameRegister = getInstruction(insertIndex).registerD - addInstruction(insertIndex, "const-string v$packageNameRegister, \"$PACKAGE_NAME\"") + + addInstruction( + insertIndex, + "const-string v$packageNameRegister, \"$PACKAGE_NAME\"" + ) } } ?: return UserAgentHeaderBuilderFingerprint.toErrorResult() diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/doublebacktoclose/fingerprint/ScrollPositionFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/doublebacktoclose/fingerprint/ScrollPositionFingerprint.kt new file mode 100644 index 000000000..9689e3d80 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/doublebacktoclose/fingerprint/ScrollPositionFingerprint.kt @@ -0,0 +1,19 @@ +package app.revanced.patches.youtube.utils.fix.doublebacktoclose.fingerprint + +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 ScrollPositionFingerprint : MethodFingerprint( + returnType = "V", + accessFlags = AccessFlags.PROTECTED or AccessFlags.FINAL, + parameters = listOf("L"), + opcodes = listOf( + Opcode.IF_NEZ, + Opcode.INVOKE_DIRECT, + Opcode.RETURN_VOID + ), + strings = listOf("scroll_position") +) + diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/oldlayout/fingerprints/SlimMetadataButtonTextFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/doublebacktoclose/fingerprint/ScrollTopFingerprint.kt similarity index 61% rename from src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/oldlayout/fingerprints/SlimMetadataButtonTextFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/fix/doublebacktoclose/fingerprint/ScrollTopFingerprint.kt index 6eab7d40d..0895905eb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/oldlayout/fingerprints/SlimMetadataButtonTextFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/doublebacktoclose/fingerprint/ScrollTopFingerprint.kt @@ -1,17 +1,21 @@ -package app.revanced.patches.youtube.misc.returnyoutubedislike.oldlayout.fingerprints +package app.revanced.patches.youtube.utils.fix.doublebacktoclose.fingerprint 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 SlimMetadataButtonTextFingerprint : MethodFingerprint( +object ScrollTopFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, parameters = listOf(), opcodes = listOf( + Opcode.CHECK_CAST, + Opcode.CONST_4, Opcode.INVOKE_VIRTUAL, + Opcode.GOTO, Opcode.IGET_OBJECT, - Opcode.IGET + Opcode.INVOKE_INTERFACE ) -) \ No newline at end of file +) + 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 new file mode 100644 index 000000000..51bd4d664 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/doublebacktoclose/fingerprint/ScrollTopParentFingerprint.kt @@ -0,0 +1,25 @@ +package app.revanced.patches.youtube.utils.fix.doublebacktoclose.fingerprint + +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 ScrollTopParentFingerprint : MethodFingerprint( + returnType = "V", + accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, + opcodes = listOf( + Opcode.IPUT_OBJECT, + Opcode.IPUT_OBJECT, + Opcode.IPUT_OBJECT, + Opcode.IPUT_OBJECT, + Opcode.CONST_16, + Opcode.INVOKE_VIRTUAL, + Opcode.NEW_INSTANCE, + Opcode.INVOKE_DIRECT, + Opcode.IPUT_OBJECT, + Opcode.RETURN_VOID + ), + 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 new file mode 100644 index 000000000..cc9f6be3a --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/doublebacktoclose/patch/DoubleBackToClosePatch.kt @@ -0,0 +1,90 @@ +package app.revanced.patches.youtube.utils.fix.doublebacktoclose.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.data.toMethodWalker +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +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.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.util.integrations.Constants.UTILS_PATH + +@Name("double-back-to-close") +@YouTubeCompatibility +@Version("0.0.1") +class DoubleBackToClosePatch : BytecodePatch( + listOf( + OnBackPressedFingerprint, + ScrollPositionFingerprint, + ScrollTopParentFingerprint + ) +) { + override fun execute(context: BytecodeContext): PatchResult { + + /** + * Hook onBackPressed method inside WatchWhileActivity + */ + OnBackPressedFingerprint.result?.let { + it.mutableMethod.apply { + val insertIndex = it.scanResult.patternScanResult!!.endIndex + + addInstruction( + insertIndex, + "invoke-static {p0}, $INTEGRATIONS_CLASS_DESCRIPTOR" + + "->" + + "closeActivityOnBackPressed(Landroid/app/Activity;)V" + ) + } + } ?: return OnBackPressedFingerprint.toErrorResult() + + + /** + * Inject the methods which start of ScrollView + */ + ScrollPositionFingerprint.result?.let { + val insertMethod = context.toMethodWalker(it.method) + .nextMethod(it.scanResult.patternScanResult!!.startIndex + 1, true) + .getMethod() as MutableMethod + + val insertIndex = insertMethod.implementation!!.instructions.size - 1 - 1 + + insertMethod.injectScrollView(insertIndex, "onStartScrollView") + } ?: return ScrollPositionFingerprint.toErrorResult() + + + /** + * Inject the methods which stop of ScrollView + */ + ScrollTopParentFingerprint.result?.let { parentResult -> + ScrollTopFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let { + val insertIndex = it.scanResult.patternScanResult!!.endIndex + + it.mutableMethod.injectScrollView(insertIndex, "onStopScrollView") + } ?: return ScrollTopFingerprint.toErrorResult() + } ?: return ScrollTopParentFingerprint.toErrorResult() + + return PatchResultSuccess() + } + + private companion object { + const val INTEGRATIONS_CLASS_DESCRIPTOR = + "$UTILS_PATH/DoubleBackToClosePatch;" + + fun MutableMethod.injectScrollView( + index: Int, + descriptor: String + ) { + addInstruction( + index, + "invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->$descriptor()V" + ) + } + } +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/protobufpoof/fingerprints/BadResponseFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/protobufpoof/fingerprints/BadResponseFingerprint.kt similarity index 76% rename from src/main/kotlin/app/revanced/patches/youtube/misc/protobufpoof/fingerprints/BadResponseFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/fix/protobufpoof/fingerprints/BadResponseFingerprint.kt index 8f9d70000..280163f96 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/protobufpoof/fingerprints/BadResponseFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/protobufpoof/fingerprints/BadResponseFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.protobufpoof.fingerprints +package app.revanced.patches.youtube.utils.fix.protobufpoof.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/protobufpoof/fingerprints/ProtobufParameterBuilderFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/protobufpoof/fingerprints/ProtobufParameterBuilderFingerprint.kt similarity index 84% rename from src/main/kotlin/app/revanced/patches/youtube/misc/protobufpoof/fingerprints/ProtobufParameterBuilderFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/fix/protobufpoof/fingerprints/ProtobufParameterBuilderFingerprint.kt index f2e453ad5..4ec4d067e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/protobufpoof/fingerprints/ProtobufParameterBuilderFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/protobufpoof/fingerprints/ProtobufParameterBuilderFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.protobufpoof.fingerprints +package app.revanced.patches.youtube.utils.fix.protobufpoof.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/protobufpoof/fingerprints/SubtitleWindowFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/protobufpoof/fingerprints/SubtitleWindowFingerprint.kt similarity index 79% rename from src/main/kotlin/app/revanced/patches/youtube/misc/protobufpoof/fingerprints/SubtitleWindowFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/fix/protobufpoof/fingerprints/SubtitleWindowFingerprint.kt index 47f5a7867..c6ce60467 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/protobufpoof/fingerprints/SubtitleWindowFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/protobufpoof/fingerprints/SubtitleWindowFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.protobufpoof.fingerprints +package app.revanced.patches.youtube.utils.fix.protobufpoof.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/protobufpoof/patch/ProtobufSpoofPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/protobufpoof/patch/ProtobufSpoofPatch.kt similarity index 90% rename from src/main/kotlin/app/revanced/patches/youtube/misc/protobufpoof/patch/ProtobufSpoofPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/fix/protobufpoof/patch/ProtobufSpoofPatch.kt index 5ed8ff067..ce0338c8e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/protobufpoof/patch/ProtobufSpoofPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/protobufpoof/patch/ProtobufSpoofPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.protobufpoof.patch +package app.revanced.patches.youtube.utils.fix.protobufpoof.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -15,10 +15,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.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch -import app.revanced.patches.youtube.misc.protobufpoof.fingerprints.* -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.patches.youtube.misc.videoid.mainstream.patch.MainstreamVideoIdPatch +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 diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/swiperefresh/fingerprint/SwipeRefreshLayoutFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/swiperefresh/fingerprint/SwipeRefreshLayoutFingerprint.kt new file mode 100644 index 000000000..6378a0c2f --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/swiperefresh/fingerprint/SwipeRefreshLayoutFingerprint.kt @@ -0,0 +1,19 @@ +package app.revanced.patches.youtube.utils.fix.swiperefresh.fingerprint + +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 SwipeRefreshLayoutFingerprint : MethodFingerprint( + returnType = "Z", + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + parameters = emptyList(), + opcodes = listOf( + Opcode.RETURN, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT, + Opcode.RETURN + ), + customFingerprint = { it, _ -> it.definingClass.endsWith("SwipeRefreshLayout;") } +) 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 new file mode 100644 index 000000000..1522d0730 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/swiperefresh/patch/SwipeRefreshPatch.kt @@ -0,0 +1,40 @@ +package app.revanced.patches.youtube.utils.fix.swiperefresh.patch + +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +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.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") +@Description("Enable swipe refresh.") +@YouTubeCompatibility +@Version("0.0.1") +class SwipeRefreshPatch : BytecodePatch( + listOf(SwipeRefreshLayoutFingerprint) +) { + override fun execute(context: BytecodeContext): PatchResult { + + SwipeRefreshLayoutFingerprint.result?.let { + it.mutableMethod.apply { + val insertIndex = it.scanResult.patternScanResult!!.endIndex + val register = getInstruction(insertIndex).registerA + + addInstruction( + insertIndex, + "const/4 v$register, 0x0" + ) + } + } ?: return SwipeRefreshLayoutFingerprint.toErrorResult() + + return PatchResultSuccess() + } +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/APIPlayerServiceFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/APIPlayerServiceFingerprint.kt new file mode 100644 index 000000000..8d674e3de --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/APIPlayerServiceFingerprint.kt @@ -0,0 +1,17 @@ +package app.revanced.patches.youtube.utils.integrations.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint +import org.jf.dexlib2.AccessFlags + +/** + * For embedded playback. + * It appears this hook may no longer be needed as one of the constructor parameters is the already hooked + * [EmbeddedPlayerControlsOverlayFingerprint] + */ +object APIPlayerServiceFingerprint : IntegrationsFingerprint( + accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, + customFingerprint = { methodDef, _ -> methodDef.definingClass == "Lcom/google/android/apps/youtube/embeddedplayer/service/service/jar/ApiPlayerService;" }, + // Integrations context is the first method parameter. + contextRegisterResolver = { it.implementation!!.registerCount - it.parameters.size } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/ApplicationInitFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/ApplicationInitFingerprint.kt new file mode 100644 index 000000000..946c50897 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/ApplicationInitFingerprint.kt @@ -0,0 +1,11 @@ +package app.revanced.patches.youtube.utils.integrations.fingerprints + +import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint + +/** + * Hooks the context when the app is launched as a regular application (and is not an embedded video playback). + */ +object ApplicationInitFingerprint : IntegrationsFingerprint( + strings = listOf("Application creation", "Application.onCreate"), + // Integrations context is the Activity itself. +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/EmbeddedPlayerControlsOverlayFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/EmbeddedPlayerControlsOverlayFingerprint.kt new file mode 100644 index 000000000..cf7105d9a --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/EmbeddedPlayerControlsOverlayFingerprint.kt @@ -0,0 +1,22 @@ +package app.revanced.patches.youtube.utils.integrations.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint +import org.jf.dexlib2.AccessFlags + +/** + * For embedded playback inside Google Play store (and probably other situations as well). + * + * Note: this fingerprint may no longer be needed, as it appears + * [RemoteEmbedFragmentFingerprint] may be set before this hook is called. + */ +object EmbeddedPlayerControlsOverlayFingerprint : IntegrationsFingerprint( + accessFlags = AccessFlags.PRIVATE or AccessFlags.CONSTRUCTOR, + returnType = "V", + parameters = listOf("Landroid/content/Context;", "L", "L"), + customFingerprint = { methodDef, _ -> + methodDef.definingClass.startsWith("Lcom/google/android/apps/youtube/embeddedplayer/service/ui/overlays/controlsoverlay/remoteloaded/") + }, + // Integrations context is the first method parameter. + contextRegisterResolver = { it.implementation!!.registerCount - it.parameters.size } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/EmbeddedPlayerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/EmbeddedPlayerFingerprint.kt new file mode 100644 index 000000000..22c9fa75c --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/EmbeddedPlayerFingerprint.kt @@ -0,0 +1,20 @@ +package app.revanced.patches.youtube.utils.integrations.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint +import org.jf.dexlib2.AccessFlags + +/** + * For embedded playback inside the Google app (such as the in app 'discover' tab). + * + * Note: this fingerprint may or may not be needed, as + * [RemoteEmbedFragmentFingerprint] might be set before this is called. + */ +object EmbeddedPlayerFingerprint : IntegrationsFingerprint( + accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC, + returnType = "L", + parameters = listOf("L", "L", "Landroid/content/Context;"), + strings = listOf("android.hardware.type.television"), // String is also found in other classes + // Integrations context is the third method parameter. + contextRegisterResolver = { it.implementation!!.registerCount - it.parameters.size + 2 } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/RemoteEmbedFragmentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/RemoteEmbedFragmentFingerprint.kt new file mode 100644 index 000000000..2d2a68d42 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/RemoteEmbedFragmentFingerprint.kt @@ -0,0 +1,19 @@ +package app.revanced.patches.youtube.utils.integrations.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint +import org.jf.dexlib2.AccessFlags + +/** + * For embedded playback. Likely covers Google Play store and other Google products. + */ +object RemoteEmbedFragmentFingerprint : IntegrationsFingerprint( + accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, + returnType = "V", + parameters = listOf("Landroid/content/Context;", "L", "L"), + customFingerprint = { methodDef, _ -> + methodDef.definingClass == "Lcom/google/android/apps/youtube/embeddedplayer/service/jar/client/RemoteEmbedFragment;" + }, + // Integrations context is the first method parameter. + contextRegisterResolver = { it.implementation!!.registerCount - it.parameters.size } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/RemoteEmbeddedPlayerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/RemoteEmbeddedPlayerFingerprint.kt new file mode 100644 index 000000000..75f1d83f5 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/RemoteEmbeddedPlayerFingerprint.kt @@ -0,0 +1,19 @@ +package app.revanced.patches.youtube.utils.integrations.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint +import org.jf.dexlib2.AccessFlags + +/** + * For embedded playback inside 3rd party android app (such as 3rd party Reddit apps). + */ +object RemoteEmbeddedPlayerFingerprint : IntegrationsFingerprint( + accessFlags = AccessFlags.PRIVATE or AccessFlags.CONSTRUCTOR, + returnType = "V", + parameters = listOf("Landroid/content/Context;", "L", "L", "Z"), + customFingerprint = { methodDef, _ -> + methodDef.definingClass == "Lcom/google/android/youtube/api/jar/client/RemoteEmbeddedPlayer;" + }, + // Integrations context is the first method parameter. + contextRegisterResolver = { it.implementation!!.registerCount - it.parameters.size } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/StandalonePlayerActivityFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/StandalonePlayerActivityFingerprint.kt new file mode 100644 index 000000000..5705c50f2 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/StandalonePlayerActivityFingerprint.kt @@ -0,0 +1,18 @@ +package app.revanced.patches.youtube.utils.integrations.fingerprints + +import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint + +/** + * Old API activity to embed YouTube into 3rd party Android apps. + * + * In 2023 supported was ended and is no longer available, + * but this may still be used by older apps: + * https://developers.google.com/youtube/android/player + */ +object StandalonePlayerActivityFingerprint : IntegrationsFingerprint( + customFingerprint = { methodDef, _ -> + methodDef.definingClass == "Lcom/google/android/youtube/api/StandalonePlayerActivity;" + && methodDef.name == "onCreate" + }, + // Integrations context is the Activity itself. +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/patch/IntegrationsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/patch/IntegrationsPatch.kt similarity index 53% rename from src/main/kotlin/app/revanced/patches/youtube/misc/integrations/patch/IntegrationsPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/integrations/patch/IntegrationsPatch.kt index 08180e269..dcbff298c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/patch/IntegrationsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/patch/IntegrationsPatch.kt @@ -1,10 +1,10 @@ -package app.revanced.patches.youtube.misc.integrations.patch +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.misc.integrations.fingerprints.* +import app.revanced.patches.youtube.utils.integrations.fingerprints.* import app.revanced.util.integrations.Constants.INTEGRATIONS_PATH @Name("integrations") @@ -12,5 +12,13 @@ import app.revanced.util.integrations.Constants.INTEGRATIONS_PATH @RequiresIntegrations class IntegrationsPatch : AbstractIntegrationsPatch( "$INTEGRATIONS_PATH/utils/ReVancedUtils;", - listOf(InitFingerprint, StandalonePlayerFingerprint, ServiceFingerprint), + listOf( + ApplicationInitFingerprint, + StandalonePlayerActivityFingerprint, + RemoteEmbeddedPlayerFingerprint, + RemoteEmbedFragmentFingerprint, + EmbeddedPlayerControlsOverlayFingerprint, + EmbeddedPlayerFingerprint, + APIPlayerServiceFingerprint, + ), ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/bytecode/fingerprints/CastContextFetchFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/microg/bytecode/fingerprints/CastContextFetchFingerprint.kt similarity index 71% rename from src/main/kotlin/app/revanced/patches/youtube/misc/microg/bytecode/fingerprints/CastContextFetchFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/microg/bytecode/fingerprints/CastContextFetchFingerprint.kt index 374f60776..f8d1e108a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/bytecode/fingerprints/CastContextFetchFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/microg/bytecode/fingerprints/CastContextFetchFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.microg.bytecode.fingerprints +package app.revanced.patches.youtube.utils.microg.bytecode.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/bytecode/fingerprints/CastDynamiteModuleFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/microg/bytecode/fingerprints/CastDynamiteModuleFingerprint.kt similarity index 75% rename from src/main/kotlin/app/revanced/patches/youtube/misc/microg/bytecode/fingerprints/CastDynamiteModuleFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/microg/bytecode/fingerprints/CastDynamiteModuleFingerprint.kt index cc20f77ed..23a640b71 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/bytecode/fingerprints/CastDynamiteModuleFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/microg/bytecode/fingerprints/CastDynamiteModuleFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.microg.bytecode.fingerprints +package app.revanced.patches.youtube.utils.microg.bytecode.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/bytecode/fingerprints/CastDynamiteModuleV2Fingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/microg/bytecode/fingerprints/CastDynamiteModuleV2Fingerprint.kt similarity index 72% rename from src/main/kotlin/app/revanced/patches/youtube/misc/microg/bytecode/fingerprints/CastDynamiteModuleV2Fingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/microg/bytecode/fingerprints/CastDynamiteModuleV2Fingerprint.kt index 9a45803b0..eefcc2227 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/bytecode/fingerprints/CastDynamiteModuleV2Fingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/microg/bytecode/fingerprints/CastDynamiteModuleV2Fingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.microg.bytecode.fingerprints +package app.revanced.patches.youtube.utils.microg.bytecode.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/bytecode/fingerprints/GooglePlayUtilityFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/microg/bytecode/fingerprints/GooglePlayUtilityFingerprint.kt similarity index 73% rename from src/main/kotlin/app/revanced/patches/youtube/misc/microg/bytecode/fingerprints/GooglePlayUtilityFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/microg/bytecode/fingerprints/GooglePlayUtilityFingerprint.kt index 02248c167..af05cc522 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/bytecode/fingerprints/GooglePlayUtilityFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/microg/bytecode/fingerprints/GooglePlayUtilityFingerprint.kt @@ -1,10 +1,12 @@ -package app.revanced.patches.youtube.misc.microg.bytecode.fingerprints +package app.revanced.patches.youtube.utils.microg.bytecode.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.AccessFlags object GooglePlayUtilityFingerprint : MethodFingerprint( + returnType = "I", accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC, + parameters = listOf("L", "I"), strings = listOf("This should never happen.", "MetadataValueReader", "com.google.android.gms") ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/bytecode/fingerprints/PrimeFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/microg/bytecode/fingerprints/PrimeFingerprint.kt similarity index 73% rename from src/main/kotlin/app/revanced/patches/youtube/misc/microg/bytecode/fingerprints/PrimeFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/microg/bytecode/fingerprints/PrimeFingerprint.kt index 488fb6aa5..560db5b48 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/bytecode/fingerprints/PrimeFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/microg/bytecode/fingerprints/PrimeFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.microg.bytecode.fingerprints +package app.revanced.patches.youtube.utils.microg.bytecode.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/bytecode/fingerprints/ServiceCheckFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/microg/bytecode/fingerprints/ServiceCheckFingerprint.kt similarity index 51% rename from src/main/kotlin/app/revanced/patches/youtube/misc/microg/bytecode/fingerprints/ServiceCheckFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/microg/bytecode/fingerprints/ServiceCheckFingerprint.kt index 23eccecd6..22ba53eec 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/bytecode/fingerprints/ServiceCheckFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/microg/bytecode/fingerprints/ServiceCheckFingerprint.kt @@ -1,8 +1,12 @@ -package app.revanced.patches.youtube.misc.microg.bytecode.fingerprints +package app.revanced.patches.youtube.utils.microg.bytecode.fingerprints +import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags 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 ") ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/bytecode/patch/MicroGBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/microg/bytecode/patch/MicroGBytecodePatch.kt similarity index 81% rename from src/main/kotlin/app/revanced/patches/youtube/misc/microg/bytecode/patch/MicroGBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/microg/bytecode/patch/MicroGBytecodePatch.kt index 46b85db11..d7d9d0fe0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/bytecode/patch/MicroGBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/microg/bytecode/patch/MicroGBytecodePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.microg.bytecode.patch +package app.revanced.patches.youtube.utils.microg.bytecode.patch import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version @@ -9,9 +9,10 @@ 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.misc.clientspoof.patch.ClientSpoofPatch -import app.revanced.patches.youtube.misc.microg.bytecode.fingerprints.* -import app.revanced.patches.youtube.misc.microg.shared.Constants.PACKAGE_NAME +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.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 @@ -19,7 +20,8 @@ import app.revanced.util.microg.MicroGBytecodeHelper @DependsOn( [ ClientSpoofPatch::class, - PackageNamePatch::class + PackageNamePatch::class, + ProtobufSpoofPatch::class ] ) @YouTubeCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/resource/patch/MicroGPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/microg/resource/patch/MicroGPatch.kt similarity index 80% rename from src/main/kotlin/app/revanced/patches/youtube/misc/microg/resource/patch/MicroGPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/microg/resource/patch/MicroGPatch.kt index 78e37fbcc..7fc535ca9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/resource/patch/MicroGPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/microg/resource/patch/MicroGPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.microg.resource.patch +package app.revanced.patches.youtube.utils.microg.resource.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -11,11 +11,11 @@ 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.misc.microg.bytecode.patch.MicroGBytecodePatch -import app.revanced.patches.youtube.misc.microg.shared.Constants.PACKAGE_NAME -import app.revanced.patches.youtube.misc.microg.shared.Constants.SPOOFED_PACKAGE_NAME -import app.revanced.patches.youtube.misc.microg.shared.Constants.SPOOFED_PACKAGE_SIGNATURE -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +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 +import app.revanced.patches.youtube.utils.microg.shared.Constants.SPOOFED_PACKAGE_SIGNATURE +import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.microg.MicroGManifestHelper.addSpoofingMetadata import app.revanced.util.microg.MicroGResourceHelper.patchManifest import app.revanced.util.microg.MicroGResourceHelper.patchSetting diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/shared/Constants.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/microg/shared/Constants.kt similarity index 80% rename from src/main/kotlin/app/revanced/patches/youtube/misc/microg/shared/Constants.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/microg/shared/Constants.kt index 5545799f2..9fb8bcdd5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/shared/Constants.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/microg/shared/Constants.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.microg.shared +package app.revanced.patches.youtube.utils.microg.shared object Constants { internal const val PACKAGE_NAME = "com.google.android.youtube" diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/overridespeed/bytecode/fingerprints/SpeedClassFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/fingerprints/SpeedClassFingerprint.kt similarity index 85% rename from src/main/kotlin/app/revanced/patches/youtube/misc/overridespeed/bytecode/fingerprints/SpeedClassFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/fingerprints/SpeedClassFingerprint.kt index 5f81ecc37..3cc43953b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/overridespeed/bytecode/fingerprints/SpeedClassFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/fingerprints/SpeedClassFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.overridespeed.bytecode.fingerprints +package app.revanced.patches.youtube.utils.overridespeed.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/overridespeed/bytecode/fingerprints/VideoSpeedChangedFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/fingerprints/VideoSpeedChangedFingerprint.kt similarity index 83% rename from src/main/kotlin/app/revanced/patches/youtube/misc/overridespeed/bytecode/fingerprints/VideoSpeedChangedFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/fingerprints/VideoSpeedChangedFingerprint.kt index a0cf7d44b..d762fcfca 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/overridespeed/bytecode/fingerprints/VideoSpeedChangedFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/fingerprints/VideoSpeedChangedFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.overridespeed.bytecode.fingerprints +package app.revanced.patches.youtube.utils.overridespeed.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/overridespeed/bytecode/fingerprints/VideoSpeedParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/fingerprints/VideoSpeedParentFingerprint.kt similarity index 86% rename from src/main/kotlin/app/revanced/patches/youtube/misc/overridespeed/bytecode/fingerprints/VideoSpeedParentFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/fingerprints/VideoSpeedParentFingerprint.kt index 35b114d9a..877537e8b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/overridespeed/bytecode/fingerprints/VideoSpeedParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/fingerprints/VideoSpeedParentFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.overridespeed.bytecode.fingerprints +package app.revanced.patches.youtube.utils.overridespeed.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/overridespeed/bytecode/fingerprints/VideoSpeedPatchFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/fingerprints/VideoSpeedPatchFingerprint.kt similarity index 84% rename from src/main/kotlin/app/revanced/patches/youtube/misc/overridespeed/bytecode/fingerprints/VideoSpeedPatchFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/fingerprints/VideoSpeedPatchFingerprint.kt index 936a56cbc..98c77b807 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/overridespeed/bytecode/fingerprints/VideoSpeedPatchFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/fingerprints/VideoSpeedPatchFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.overridespeed.bytecode.fingerprints +package app.revanced.patches.youtube.utils.overridespeed.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/overridespeed/bytecode/patch/OverrideSpeedHookPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/patch/OverrideSpeedHookPatch.kt similarity index 94% rename from src/main/kotlin/app/revanced/patches/youtube/misc/overridespeed/bytecode/patch/OverrideSpeedHookPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/patch/OverrideSpeedHookPatch.kt index e806a7bbd..47de87d00 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/overridespeed/bytecode/patch/OverrideSpeedHookPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/patch/OverrideSpeedHookPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.overridespeed.bytecode.patch +package app.revanced.patches.youtube.utils.overridespeed.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Name @@ -15,14 +15,12 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult 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.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable 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.misc.overridespeed.bytecode.fingerprints.* -import app.revanced.patches.youtube.misc.overridespeed.resource.patch.OverrideSpeedHookResourcePatch +import app.revanced.patches.youtube.utils.overridespeed.fingerprints.* import app.revanced.util.integrations.Constants.INTEGRATIONS_PATH import app.revanced.util.integrations.Constants.VIDEO_PATH import org.jf.dexlib2.AccessFlags @@ -32,7 +30,6 @@ import org.jf.dexlib2.iface.reference.FieldReference import org.jf.dexlib2.immutable.* @Name("override-speed-hook") -@DependsOn([OverrideSpeedHookResourcePatch::class]) @YouTubeCompatibility @Version("0.0.1") class OverrideSpeedHookPatch : BytecodePatch( @@ -136,7 +133,7 @@ class OverrideSpeedHookPatch : BytecodePatch( 0, """ sget-object v0, $INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR->speedClass:$SPEED_CLASS invoke-virtual {v0, p0}, $SPEED_CLASS->overrideSpeed(F)V - """ + """ ) } diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/playerbutton/fingerprints/LiveChatFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/playerbutton/fingerprints/LiveChatFingerprint.kt new file mode 100644 index 000000000..4cf5be80b --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/playerbutton/fingerprints/LiveChatFingerprint.kt @@ -0,0 +1,11 @@ +package app.revanced.patches.youtube.utils.playerbutton.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.LiveChatButton +import app.revanced.util.bytecode.isWideLiteralExists +import org.jf.dexlib2.Opcode + +object LiveChatFingerprint : MethodFingerprint( + opcodes = listOf(Opcode.NEW_INSTANCE), + customFingerprint = { it, _ -> it.isWideLiteralExists(LiveChatButton) } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playerbutton/patch/PlayerButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/playerbutton/patch/PlayerButtonPatch.kt similarity index 88% rename from src/main/kotlin/app/revanced/patches/youtube/misc/playerbutton/patch/PlayerButtonPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/playerbutton/patch/PlayerButtonPatch.kt index ad892a9bb..1f231079c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playerbutton/patch/PlayerButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/playerbutton/patch/PlayerButtonPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.playerbutton.patch +package app.revanced.patches.youtube.utils.playerbutton.patch import app.revanced.extensions.findMutableMethodOf import app.revanced.extensions.toErrorResult @@ -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.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.misc.playerbutton.fingerprints.LiveChatFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch +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 import org.jf.dexlib2.Opcode import org.jf.dexlib2.builder.instruction.BuilderInstruction21c @@ -38,11 +38,11 @@ class PlayerButtonPatch : BytecodePatch( .mutableClass for (method in imageButtonClass.methods) { - with (imageButtonClass.findMutableMethodOf(method)) { + imageButtonClass.findMutableMethodOf(method).apply { var jumpInstruction = true implementation!!.instructions.forEachIndexed { index, instructions -> - if (instructions.opcode.ordinal == Opcode.INVOKE_VIRTUAL.ordinal) { + if (instructions.opcode == Opcode.INVOKE_VIRTUAL) { val definedInstruction = (instructions as? BuilderInstruction35c) if (definedInstruction?.reference.toString() == diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/BottomControlsInflateFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/fingerprints/BottomControlsInflateFingerprint.kt similarity index 54% rename from src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/BottomControlsInflateFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/fingerprints/BottomControlsInflateFingerprint.kt index 4750d25a0..f40a9da3d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/BottomControlsInflateFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/fingerprints/BottomControlsInflateFingerprint.kt @@ -1,7 +1,7 @@ -package app.revanced.patches.youtube.misc.playercontrols.fingerprints +package app.revanced.patches.youtube.utils.playercontrols.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.bottomUiContainerResourceId +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.BottomUiContainerStub import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.Opcode @@ -11,5 +11,5 @@ object BottomControlsInflateFingerprint : MethodFingerprint( Opcode.INVOKE_VIRTUAL, Opcode.MOVE_RESULT_OBJECT ), - customFingerprint = { it, _ -> it.isWideLiteralExists(bottomUiContainerResourceId) } + customFingerprint = { it, _ -> it.isWideLiteralExists(BottomUiContainerStub) } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/ControlsLayoutInflateFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/fingerprints/ControlsLayoutInflateFingerprint.kt similarity index 59% rename from src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/ControlsLayoutInflateFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/fingerprints/ControlsLayoutInflateFingerprint.kt index c377a132b..97c5398b3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/ControlsLayoutInflateFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/fingerprints/ControlsLayoutInflateFingerprint.kt @@ -1,7 +1,7 @@ -package app.revanced.patches.youtube.misc.playercontrols.fingerprints +package app.revanced.patches.youtube.utils.playercontrols.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.controlsLayoutStubResourceId +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.ControlsLayoutStub import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.Opcode @@ -13,5 +13,5 @@ object ControlsLayoutInflateFingerprint : MethodFingerprint( Opcode.INVOKE_VIRTUAL, Opcode.MOVE_RESULT_OBJECT ), - customFingerprint = { it, _ -> it.isWideLiteralExists(controlsLayoutStubResourceId) } + customFingerprint = { it, _ -> it.isWideLiteralExists(ControlsLayoutStub) } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/PlayerControlsVisibilityFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/fingerprints/PlayerControlsVisibilityFingerprint.kt similarity index 80% rename from src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/PlayerControlsVisibilityFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/fingerprints/PlayerControlsVisibilityFingerprint.kt index db8cf149e..09ca86f9f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/PlayerControlsVisibilityFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/fingerprints/PlayerControlsVisibilityFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.playercontrols.fingerprints +package app.revanced.patches.youtube.utils.playercontrols.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/PlayerControlsVisibilityModelFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/fingerprints/PlayerControlsVisibilityModelFingerprint.kt similarity index 80% rename from src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/PlayerControlsVisibilityModelFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/fingerprints/PlayerControlsVisibilityModelFingerprint.kt index 8e23440c9..52bbda617 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/PlayerControlsVisibilityModelFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/fingerprints/PlayerControlsVisibilityModelFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.playercontrols.fingerprints +package app.revanced.patches.youtube.utils.playercontrols.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/SeekEDUVisibleFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/fingerprints/SeekEDUVisibleFingerprint.kt similarity index 87% rename from src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/SeekEDUVisibleFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/fingerprints/SeekEDUVisibleFingerprint.kt index 0600e4d9d..38a7cd2b9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/SeekEDUVisibleFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/fingerprints/SeekEDUVisibleFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.playercontrols.fingerprints +package app.revanced.patches.youtube.utils.playercontrols.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/fingerprints/SpeedEduVisibleFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/fingerprints/SpeedEduVisibleFingerprint.kt new file mode 100644 index 000000000..e2bab2a9d --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/fingerprints/SpeedEduVisibleFingerprint.kt @@ -0,0 +1,10 @@ +package app.revanced.patches.youtube.utils.playercontrols.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.Opcode + +object SpeedEduVisibleFingerprint : MethodFingerprint( + returnType = "V", + opcodes = listOf(Opcode.IPUT_BOOLEAN), + customFingerprint = { it, _ -> it.name == "" } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/fingerprints/SpeedEduVisibleParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/fingerprints/SpeedEduVisibleParentFingerprint.kt new file mode 100644 index 000000000..65700c921 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/fingerprints/SpeedEduVisibleParentFingerprint.kt @@ -0,0 +1,8 @@ +package app.revanced.patches.youtube.utils.playercontrols.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +object SpeedEduVisibleParentFingerprint : MethodFingerprint( + returnType = "L", + strings = listOf(", isSpeedmasterEDUVisible=") +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/UserScrubbingFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/fingerprints/UserScrubbingFingerprint.kt similarity index 87% rename from src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/UserScrubbingFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/fingerprints/UserScrubbingFingerprint.kt index 09e8a94d0..346205d94 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/fingerprints/UserScrubbingFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/fingerprints/UserScrubbingFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.playercontrols.fingerprints +package app.revanced.patches.youtube.utils.playercontrols.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode 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 new file mode 100644 index 000000000..77704659a --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/patch/PlayerControlsPatch.kt @@ -0,0 +1,162 @@ +package app.revanced.patches.youtube.utils.playercontrols.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult +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.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.playercontrols.fingerprints.BottomControlsInflateFingerprint +import app.revanced.patches.youtube.utils.playercontrols.fingerprints.ControlsLayoutInflateFingerprint +import app.revanced.patches.youtube.utils.playercontrols.fingerprints.PlayerControlsVisibilityFingerprint +import app.revanced.patches.youtube.utils.playercontrols.fingerprints.PlayerControlsVisibilityModelFingerprint +import app.revanced.patches.youtube.utils.playercontrols.fingerprints.SeekEDUVisibleFingerprint +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.util.bytecode.getStringIndex +import org.jf.dexlib2.Opcode +import org.jf.dexlib2.iface.instruction.OneRegisterInstruction +import org.jf.dexlib2.iface.instruction.ReferenceInstruction +import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction +import org.jf.dexlib2.iface.instruction.formats.Instruction35c +import org.jf.dexlib2.iface.reference.Reference + +@Name("player-controls-bytecode-patch") +@DependsOn([SharedResourceIdPatch::class]) +@Description("Manages the code for the player controls of the YouTube player.") +@YouTubeCompatibility +@Version("0.0.1") +class PlayerControlsPatch : BytecodePatch( + listOf( + BottomControlsInflateFingerprint, + ControlsLayoutInflateFingerprint, + PlayerControlsVisibilityFingerprint, + PlayerControlsVisibilityModelFingerprint, + SpeedEduVisibleParentFingerprint + ) +) { + override fun execute(context: BytecodeContext): PatchResult { + + val playerControlsVisibilityModelClassDef = PlayerControlsVisibilityModelFingerprint.result?.classDef?: return PlayerControlsVisibilityModelFingerprint.toErrorResult() + + SeekEDUVisibleFingerprint.resolve(context, playerControlsVisibilityModelClassDef) + seekEDUVisibleResult = SeekEDUVisibleFingerprint.result?: return SeekEDUVisibleFingerprint.toErrorResult() + + UserScrubbingFingerprint.resolve(context, playerControlsVisibilityModelClassDef) + userScrubbingResult = UserScrubbingFingerprint.result?: return UserScrubbingFingerprint.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 + parentResult.mutableMethod.apply { + val targetIndex = getStringIndex(", isSpeedmasterEDUVisible=") + 2 + val targetRegister = getInstruction(targetIndex).registerD + + val instructions = implementation!!.instructions + for ((index, instruction) in instructions.withIndex()) { + if (instruction.opcode != Opcode.IGET_BOOLEAN) continue + + if (getInstruction(index).registerA == targetRegister) { + speedEDUVisibleReference = getInstruction(index).reference + speedIndex = index + break + } + } + if (speedIndex == 0) return PatchResultError("SpeedEduVisibleParent Instruction not found!") + } + + 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 + + if (it.getInstruction(index).reference == speedEDUVisibleReference) { + speedEDUVisibleMutableMethod = it + speedEDUVisibleIndex = index + speedEDUVisibleRegister = it.getInstruction(index).registerA + break + } + } + } + if (speedEDUVisibleIndex == 0) return PatchResultError("SpeedEduVisibleFingerprint Instruction not found!") + } ?: return SpeedEduVisibleFingerprint.toErrorResult() + } ?: return SpeedEduVisibleParentFingerprint.toErrorResult() + + return PatchResultSuccess() + } + + internal companion object { + lateinit var controlsLayoutInflateResult: MethodFingerprintResult + lateinit var inflateResult: MethodFingerprintResult + lateinit var playerControlsVisibilityResult: MethodFingerprintResult + lateinit var seekEDUVisibleResult: MethodFingerprintResult + lateinit var userScrubbingResult: MethodFingerprintResult + + lateinit var speedEDUVisibleMutableMethod: MutableMethod + lateinit var speedEDUVisibleReference: Reference + + private var speedEDUVisibleRegister: Int = 1 + private var speedEDUVisibleIndex: Int = 0 + + private fun injectSpeedEduVisibilityCall(descriptor: String) { + speedEDUVisibleMutableMethod.addInstruction( + speedEDUVisibleIndex, + "invoke-static {v$speedEDUVisibleRegister}, $descriptor->changeVisibilityNegatedImmediate(Z)V" + ) + } + + private fun MethodFingerprintResult.injectVisibilityCall( + descriptor: String, + fieldName: String + ) { + mutableMethod.addInstruction( + 0, + "invoke-static {p1}, $descriptor->$fieldName(Z)V" + ) + } + + private fun MethodFingerprintResult.injectCalls( + descriptor: String + ) { + mutableMethod.apply { + val endIndex = scanResult.patternScanResult!!.endIndex + val viewRegister = getInstruction(endIndex).registerA + + addInstruction( + endIndex + 1, + "invoke-static {v$viewRegister}, $descriptor->initialize(Ljava/lang/Object;)V" + ) + } + } + + fun injectVisibility(descriptor: String) { + playerControlsVisibilityResult.injectVisibilityCall(descriptor, "changeVisibility") + seekEDUVisibleResult.injectVisibilityCall(descriptor, "changeVisibilityNegatedImmediate") + userScrubbingResult.injectVisibilityCall(descriptor, "changeVisibilityNegatedImmediate") + injectSpeedEduVisibilityCall(descriptor) + } + + fun initializeSB(descriptor: String) { + controlsLayoutInflateResult.injectCalls(descriptor) + } + + fun initializeControl(descriptor: String) { + inflateResult.injectCalls(descriptor) + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/playeroverlay/fingerprint/PlayerOverlaysOnFinishInflateFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/playeroverlay/fingerprint/PlayerOverlaysOnFinishInflateFingerprint.kt new file mode 100644 index 000000000..49abd94d9 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/playeroverlay/fingerprint/PlayerOverlaysOnFinishInflateFingerprint.kt @@ -0,0 +1,7 @@ +package app.revanced.patches.youtube.utils.playeroverlay.fingerprint + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +object PlayerOverlaysOnFinishInflateFingerprint : MethodFingerprint( + customFingerprint = { it, _ -> it.definingClass.endsWith("YouTubePlayerOverlaysLayout;") && it.name == "onFinishInflate" } +) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/patch/PlayerOverlaysHookPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/playeroverlay/patch/PlayerOverlaysHookPatch.kt similarity index 89% rename from src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/patch/PlayerOverlaysHookPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/playeroverlay/patch/PlayerOverlaysHookPatch.kt index 771280517..ab6a3a041 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/patch/PlayerOverlaysHookPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/playeroverlay/patch/PlayerOverlaysHookPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.playeroverlay.patch +package app.revanced.patches.youtube.utils.playeroverlay.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -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.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.misc.playeroverlay.fingerprint.PlayerOverlaysOnFinishInflateFingerprint +import app.revanced.patches.youtube.utils.playeroverlay.fingerprint.PlayerOverlaysOnFinishInflateFingerprint import app.revanced.util.integrations.Constants.UTILS_PATH @Name("player-overlays-hook") diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/fingerprint/UpdatePlayerTypeFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/playertype/fingerprint/PlayerTypeFingerprint.kt similarity index 61% rename from src/main/kotlin/app/revanced/patches/youtube/misc/playertype/fingerprint/UpdatePlayerTypeFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/playertype/fingerprint/PlayerTypeFingerprint.kt index ec6c7b9ee..676d84b63 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/fingerprint/UpdatePlayerTypeFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/playertype/fingerprint/PlayerTypeFingerprint.kt @@ -1,11 +1,11 @@ -package app.revanced.patches.youtube.misc.playertype.fingerprint +package app.revanced.patches.youtube.utils.playertype.fingerprint 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 UpdatePlayerTypeFingerprint : MethodFingerprint( +object PlayerTypeFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, parameters = listOf("L"), @@ -13,7 +13,5 @@ object UpdatePlayerTypeFingerprint : MethodFingerprint( Opcode.IF_NE, Opcode.RETURN_VOID ), - customFingerprint = { it, _ -> - it.definingClass.endsWith("YouTubePlayerOverlaysLayout;") - } + customFingerprint = { it, _ -> it.definingClass.endsWith("YouTubePlayerOverlaysLayout;") } ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/playertype/fingerprint/VideoStateFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/playertype/fingerprint/VideoStateFingerprint.kt new file mode 100644 index 000000000..630a4a204 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/playertype/fingerprint/VideoStateFingerprint.kt @@ -0,0 +1,22 @@ +package app.revanced.patches.youtube.utils.playertype.fingerprint + +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 VideoStateFingerprint : MethodFingerprint( + returnType = "V", + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + parameters = listOf("L"), + opcodes = listOf( + Opcode.IGET_OBJECT, + Opcode.INVOKE_VIRTUAL, + Opcode.IGET_OBJECT, + Opcode.CONST_4, + Opcode.IF_EQZ, + Opcode.IF_EQZ, + Opcode.IGET_OBJECT, // obfuscated parameter field name + ), + customFingerprint = { it, _ -> it.definingClass.endsWith("YouTubeControlsOverlay;") } +) \ No newline at end of file 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 new file mode 100644 index 000000000..153f003ba --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/playertype/patch/PlayerTypeHookPatch.kt @@ -0,0 +1,61 @@ +package app.revanced.patches.youtube.utils.playertype.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +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.playertype.fingerprint.PlayerTypeFingerprint +import app.revanced.patches.youtube.utils.playertype.fingerprint.VideoStateFingerprint +import app.revanced.util.integrations.Constants.UTILS_PATH +import org.jf.dexlib2.iface.instruction.ReferenceInstruction + +@Name("player-type-hook") +@Description("Hook to get the current player type and video playback state.") +@YouTubeCompatibility +@Version("0.0.1") +class PlayerTypeHookPatch : BytecodePatch( + listOf( + PlayerTypeFingerprint, + VideoStateFingerprint + ) +) { + override fun execute(context: BytecodeContext): PatchResult { + + PlayerTypeFingerprint.result?.let { + it.mutableMethod.apply { + addInstruction( + 0, + "invoke-static {p1}, $INTEGRATIONS_CLASS_DESCRIPTOR->setPlayerType(Ljava/lang/Enum;)V" + ) + } + } ?: return PlayerTypeFingerprint.toErrorResult() + + VideoStateFingerprint.result?.let { + it.mutableMethod.apply { + val endIndex = it.scanResult.patternScanResult!!.endIndex + val videoStateFieldName = getInstruction(endIndex).reference + addInstructions( + 0, """ + iget-object v0, p1, $videoStateFieldName # copy VideoState parameter field + invoke-static {v0}, $INTEGRATIONS_CLASS_DESCRIPTOR->setVideoState(Ljava/lang/Enum;)V + """ + ) + } + } ?: return VideoStateFingerprint.toErrorResult() + + return PatchResultSuccess() + } + + companion object { + private const val INTEGRATIONS_CLASS_DESCRIPTOR = + "$UTILS_PATH/PlayerTypeHookPatch;" + } +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/quickactionscontainer/fingerprints/QuickActionsElementFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/quickactionscontainer/fingerprints/QuickActionsElementFingerprint.kt new file mode 100644 index 000000000..ead309168 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/quickactionscontainer/fingerprints/QuickActionsElementFingerprint.kt @@ -0,0 +1,23 @@ +package app.revanced.patches.youtube.utils.quickactionscontainer.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.QuickActionsElementContainer +import app.revanced.util.bytecode.isWideLiteralExists +import org.jf.dexlib2.Opcode + +object QuickActionsElementFingerprint : MethodFingerprint( + returnType = "V", + opcodes = listOf( + Opcode.RETURN_VOID, + Opcode.IGET_OBJECT, + Opcode.CONST, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT_OBJECT, + Opcode.CHECK_CAST, + Opcode.CONST, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT_OBJECT, + Opcode.CHECK_CAST + ), + customFingerprint = { it, _ -> it.isWideLiteralExists(QuickActionsElementContainer) } +) \ No newline at end of file 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 new file mode 100644 index 000000000..9aa76f36d --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/quickactionscontainer/patch/HideQuickActionsContainerPatch.kt @@ -0,0 +1,42 @@ +package app.revanced.patches.youtube.utils.quickactionscontainer.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +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.patcher.patch.annotations.DependsOn +import app.revanced.patches.shared.annotation.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 +import org.jf.dexlib2.iface.instruction.OneRegisterInstruction + +@Name("hide-quick-actions-hook") +@DependsOn([SharedResourceIdPatch::class]) +@YouTubeCompatibility +@Version("0.0.1") +class HideQuickActionsContainerPatch : BytecodePatch( + listOf(QuickActionsElementFingerprint) +) { + override fun execute(context: BytecodeContext): PatchResult { + + QuickActionsElementFingerprint.result?.let { + it.mutableMethod.apply { + val insertIndex = it.scanResult.patternScanResult!!.endIndex + val targetRegister = getInstruction(insertIndex).registerA + + addInstruction( + insertIndex, + "invoke-static {v$targetRegister}, $FULLSCREEN->hideQuickActions(Landroid/view/View;)V" + ) + } + } ?: return QuickActionsElementFingerprint.toErrorResult() + + return PatchResultSuccess() + } +} 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 new file mode 100644 index 000000000..ddc8c80a6 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/patch/SharedResourceIdPatch.kt @@ -0,0 +1,134 @@ +package app.revanced.patches.youtube.utils.resourceid.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.patcher.patch.annotations.DependsOn +import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch +import app.revanced.util.enum.ResourceType +import app.revanced.util.enum.ResourceType.* + +@Name("shared-resource-id") +@DependsOn([ResourceMappingPatch::class]) +@YouTubeCompatibility +@Version("0.0.1") +class SharedResourceIdPatch : ResourcePatch { + internal companion object { + var AccountSwitcherAccessibility: Long = -1 + var ActionBarRingo: Long = -1 + var AdAttribution: Long = -1 + var Appearance: Long = -1 + var AppRelatedEndScreenResults: Long = -1 + var AutoNavPreviewStub: Long = -1 + var BackgroundCategory: Long = -1 + var BarContainerHeight: Long = -1 + var BottomPanelOverlayText: Long = -1 + var BottomUiContainerStub: Long = -1 + var ChannelListSubMenu: Long = -1 + var CompactLink: Long = -1 + var ControlsLayoutStub: Long = -1 + var DislikeButton: Long = -1 + var DonationCompanion: Long = -1 + var EasySeekEduContainer: Long = -1 + var EndScreenElementLayoutCircle: Long = -1 + var EndScreenElementLayoutIcon: Long = -1 + var EndScreenElementLayoutVideo: Long = -1 + var ExpandButtonDown: Long = -1 + var Fab: Long = -1 + var FilterBarHeight: Long = -1 + var FloatyBarTopMargin: Long = -1 + var FullScreenEngagementPanel: Long = -1 + var HorizontalCardList: Long = -1 + var ImageOnlyTab: Long = -1 + var InlineTimeBarColorizedBarPlayedColorDark: Long = -1 + var InlineTimeBarPlayedNotHighlightedColor: Long = -1 + var InsetOverlayViewLayout: Long = -1 + var LiveChatButton: Long = -1 + var QuickActionsElementContainer: Long = -1 + var ReelDynRemix: Long = -1 + var ReelPlayerBadge: Long = -1 + var ReelPlayerBadge2: Long = -1 + var ReelPlayerFooter: Long = -1 + var ReelPlayerInfoPanel: Long = -1 + var ReelPlayerPausedStateButton: Long = -1 + var RelatedChipCloudMargin: Long = -1 + var RightComment: Long = -1 + var ScrimOverlay: Long = -1 + var Scrubbing: Long = -1 + var SearchSuggestionEntry: Long = -1 + var SuggestedAction: Long = -1 + var ToolBarPaddingHome: Long = -1 + var ToolTipContentView: Long = -1 + var TotalTime: Long = -1 + var VideoQualityBottomSheet: Long = -1 + var WatchWhileTimeBarOverlayStub: Long = -1 + var WordMarkHeader: Long = -1 + var YoutubeControlsOverlay: Long = -1 + } + + override fun execute(context: ResourceContext): PatchResult { + + fun find(resourceType: ResourceType, resourceName: String) = ResourceMappingPatch + .resourceMappings + .find { it.type == resourceType.value && it.name == resourceName }?.id + ?: throw PatchResultError("Failed to find resource id : $resourceName") + + AccountSwitcherAccessibility = find(STRING, "account_switcher_accessibility_label") + ActionBarRingo = find(LAYOUT, "action_bar_ringo") + AdAttribution = find(ID, "ad_attribution") + Appearance = find(STRING, "app_theme_appearance_dark") + AppRelatedEndScreenResults = find(LAYOUT, "app_related_endscreen_results") + AutoNavPreviewStub = find(ID, "autonav_preview_stub") + BackgroundCategory = find(STRING, "pref_background_and_offline_category") + BarContainerHeight = find(DIMEN, "bar_container_height") + BottomPanelOverlayText = find(ID, "bottom_panel_overlay_text") + BottomUiContainerStub = find(ID, "bottom_ui_container_stub") + ChannelListSubMenu = find(LAYOUT, "channel_list_sub_menu") + CompactLink = find(LAYOUT, "compact_link") + ControlsLayoutStub = find(ID, "controls_layout_stub") + DislikeButton = find(ID, "dislike_button") + DonationCompanion = find(LAYOUT, "donation_companion") + EasySeekEduContainer = find(ID, "easy_seek_edu_container") + EndScreenElementLayoutCircle = find(LAYOUT, "endscreen_element_layout_circle") + EndScreenElementLayoutIcon = find(LAYOUT, "endscreen_element_layout_icon") + EndScreenElementLayoutVideo = find(LAYOUT, "endscreen_element_layout_video") + ExpandButtonDown = find(LAYOUT, "expand_button_down") + Fab = find(ID, "fab") + FilterBarHeight = find(DIMEN, "filter_bar_height") + FloatyBarTopMargin = find(DIMEN, "floaty_bar_button_top_margin") + 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") + InsetOverlayViewLayout = find(ID, "inset_overlay_view_layout") + LiveChatButton = find(ID, "live_chat_overlay_button") + QuickActionsElementContainer = find(ID, "quick_actions_element_container") + ReelDynRemix = find(ID, "reel_dyn_remix") + ReelPlayerBadge = find(ID, "reel_player_badge") + ReelPlayerBadge2 = find(ID, "reel_player_badge2") + ReelPlayerFooter = find(LAYOUT, "reel_player_dyn_footer_vert_stories3") + ReelPlayerInfoPanel = find(ID, "reel_player_info_panel") + ReelPlayerPausedStateButton = find(ID, "reel_player_paused_state_buttons") + RelatedChipCloudMargin = find(LAYOUT, "related_chip_cloud_reduced_margins") + RightComment = find(DRAWABLE, "ic_right_comment_32c") + ScrimOverlay = find(ID, "scrim_overlay") + Scrubbing = find(DIMEN, "vertical_touch_offset_to_enter_fine_scrubbing") + SearchSuggestionEntry = find(LAYOUT, "search_suggestion_entry") + SuggestedAction = find(LAYOUT, "suggested_action") + ToolBarPaddingHome = find(DIMEN, "toolbar_padding_home_action_up") + ToolTipContentView = find(LAYOUT, "tooltip_content_view") + TotalTime = find(STRING, "total_time") + VideoQualityBottomSheet = find(LAYOUT, "video_quality_bottom_sheet_list_fragment_title") + WatchWhileTimeBarOverlayStub = find(ID, "watch_while_timebar_overlay_stub") + WordMarkHeader = find(ATTR, "ytWordmarkHeader") + YoutubeControlsOverlay = find(ID, "youtube_controls_overlay") + + return PatchResultSuccess() + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/general/fingerprints/DislikeFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/DislikeFingerprint.kt similarity index 67% rename from src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/general/fingerprints/DislikeFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/DislikeFingerprint.kt index 282ff24a0..6a8010e7f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/general/fingerprints/DislikeFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/DislikeFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.returnyoutubedislike.general.fingerprints +package app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/general/fingerprints/LikeFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/LikeFingerprint.kt similarity index 67% rename from src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/general/fingerprints/LikeFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/LikeFingerprint.kt index 877dd4654..447fe71f6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/general/fingerprints/LikeFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/LikeFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.returnyoutubedislike.general.fingerprints +package app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/general/fingerprints/RemoveLikeFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/RemoveLikeFingerprint.kt similarity index 68% rename from src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/general/fingerprints/RemoveLikeFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/RemoveLikeFingerprint.kt index 869ae1bfc..c64866fa4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/general/fingerprints/RemoveLikeFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/RemoveLikeFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.returnyoutubedislike.general.fingerprints +package app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/general/fingerprints/TextComponentAtomicReferenceFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/TextComponentAtomicReferenceFingerprint.kt similarity index 85% rename from src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/general/fingerprints/TextComponentAtomicReferenceFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/TextComponentAtomicReferenceFingerprint.kt index dcc8291b7..d068959d8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/general/fingerprints/TextComponentAtomicReferenceFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/TextComponentAtomicReferenceFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.returnyoutubedislike.general.fingerprints +package app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/general/fingerprints/TextComponentConstructorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/TextComponentConstructorFingerprint.kt similarity index 79% rename from src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/general/fingerprints/TextComponentConstructorFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/TextComponentConstructorFingerprint.kt index a17e8ca16..075cf34a4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/general/fingerprints/TextComponentConstructorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/TextComponentConstructorFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.returnyoutubedislike.general.fingerprints +package app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/general/fingerprints/TextComponentContextFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/TextComponentContextFingerprint.kt similarity index 85% rename from src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/general/fingerprints/TextComponentContextFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/TextComponentContextFingerprint.kt index 9bb84d3ed..2f84d5821 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/general/fingerprints/TextComponentContextFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/TextComponentContextFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.returnyoutubedislike.general.fingerprints +package app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/general/fingerprints/TextComponentTmpFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/TextComponentTmpFingerprint.kt similarity index 84% rename from src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/general/fingerprints/TextComponentTmpFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/TextComponentTmpFingerprint.kt index f9e9a8f0d..85572c4cd 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/general/fingerprints/TextComponentTmpFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/TextComponentTmpFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.returnyoutubedislike.general.fingerprints +package app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/general/patch/ReturnYouTubeDislikePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/patch/ReturnYouTubeDislikePatch.kt similarity index 78% rename from src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/general/patch/ReturnYouTubeDislikePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/patch/ReturnYouTubeDislikePatch.kt index 6cd290c4f..62a8928ac 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/general/patch/ReturnYouTubeDislikePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/patch/ReturnYouTubeDislikePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.returnyoutubedislike.general.patch +package app.revanced.patches.youtube.utils.returnyoutubedislike.general.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -7,7 +7,7 @@ import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.getInstruction -import app.revanced.patcher.extensions.InstructionExtensions.replaceInstructions +import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch @@ -16,11 +16,17 @@ 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.returnyoutubedislike.general.fingerprints.* -import app.revanced.patches.youtube.misc.returnyoutubedislike.oldlayout.patch.ReturnYouTubeDislikeOldLayoutPatch -import app.revanced.patches.youtube.misc.returnyoutubedislike.shorts.patch.ReturnYouTubeDislikeShortsPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.patches.youtube.misc.videoid.mainstream.patch.MainstreamVideoIdPatch +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.returnyoutubedislike.general.fingerprints.DislikeFingerprint +import app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints.LikeFingerprint +import app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints.RemoveLikeFingerprint +import app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints.TextComponentAtomicReferenceFingerprint +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.videoid.mainstream.patch.MainstreamVideoIdPatch import app.revanced.util.integrations.Constants.UTILS_PATH import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction import org.jf.dexlib2.iface.instruction.ReferenceInstruction @@ -69,7 +75,7 @@ class ReturnYouTubeDislikePatch : BytecodePatch( TextComponentConstructorFingerprint.result?.let { parentResult -> TextComponentContextFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let { - with (it.mutableMethod) { + it.mutableMethod.apply { val conversionContextIndex = it.scanResult.patternScanResult!!.startIndex conversionContextFieldReference = getInstruction(conversionContextIndex).reference @@ -86,7 +92,7 @@ class ReturnYouTubeDislikePatch : BytecodePatch( TextComponentAtomicReferenceFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let { - with (it.mutableMethod) { + it.mutableMethod.apply { val atomicReferenceStartIndex = it.scanResult.patternScanResult!!.startIndex val insertIndex = it.scanResult.patternScanResult!!.endIndex val moveCharSequenceInstruction = getInstruction(insertIndex) @@ -97,15 +103,16 @@ class ReturnYouTubeDislikePatch : BytecodePatch( val charSequenceRegister = moveCharSequenceInstruction.registerB - replaceInstructions(insertIndex, "move-object/from16 v$tmpRegister, p0") addInstructions( insertIndex + 1, """ + move-object/from16 v$tmpRegister, p0 iget-object v$tmpRegister, v$tmpRegister, $conversionContextFieldReference invoke-static {v$tmpRegister, v$atomicReferenceRegister, v$charSequenceRegister}, $INTEGRATIONS_RYD_CLASS_DESCRIPTOR->onLithoTextLoaded(Ljava/lang/Object;Ljava/util/concurrent/atomic/AtomicReference;Ljava/lang/CharSequence;)Ljava/lang/CharSequence; move-result-object v$charSequenceRegister move-object v${moveCharSequenceInstruction.registerA}, v${charSequenceRegister} - """ + """ ) + removeInstruction(insertIndex) } } ?: return TextComponentAtomicReferenceFingerprint.toErrorResult() } ?: return TextComponentConstructorFingerprint.toErrorResult() diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/oldlayout/fingerprints/ButtonTagFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/oldlayout/fingerprints/ButtonTagFingerprint.kt similarity index 57% rename from src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/oldlayout/fingerprints/ButtonTagFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/oldlayout/fingerprints/ButtonTagFingerprint.kt index ba983562b..954f0fe67 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/oldlayout/fingerprints/ButtonTagFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/oldlayout/fingerprints/ButtonTagFingerprint.kt @@ -1,8 +1,8 @@ -package app.revanced.patches.youtube.misc.returnyoutubedislike.oldlayout.fingerprints +package app.revanced.patches.youtube.utils.returnyoutubedislike.oldlayout.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.dislikeButtonId +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.DislikeButton import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.AccessFlags @@ -10,5 +10,5 @@ object ButtonTagFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, parameters = listOf("L"), - customFingerprint = { it, _ -> it.isWideLiteralExists(dislikeButtonId) } + customFingerprint = { it, _ -> it.isWideLiteralExists(DislikeButton) } ) \ No newline at end of file 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 new file mode 100644 index 000000000..58680ceb7 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/oldlayout/patch/ReturnYouTubeDislikeOldLayoutPatch.kt @@ -0,0 +1,50 @@ +package app.revanced.patches.youtube.utils.returnyoutubedislike.oldlayout.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +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.patcher.patch.annotations.DependsOn +import app.revanced.patches.shared.annotation.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 +import app.revanced.util.bytecode.getWideLiteralIndex +import app.revanced.util.integrations.Constants.UTILS_PATH +import org.jf.dexlib2.iface.instruction.OneRegisterInstruction + +@Name("return-youtube-dislike-old-layout") +@DependsOn([SharedResourceIdPatch::class]) +@YouTubeCompatibility +@Version("0.0.1") +class ReturnYouTubeDislikeOldLayoutPatch : BytecodePatch( + listOf(ButtonTagFingerprint) +) { + override fun execute(context: BytecodeContext): PatchResult { + + ButtonTagFingerprint.result?.let { + it.mutableMethod.apply { + val dislikeButtonIndex = getWideLiteralIndex(DislikeButton) + + val resourceIdentifierRegister = getInstruction(dislikeButtonIndex).registerA + val textViewRegister = getInstruction(dislikeButtonIndex + 4).registerA + + addInstruction( + dislikeButtonIndex + 4, + "invoke-static {v$resourceIdentifierRegister, v$textViewRegister}, $INTEGRATIONS_RYD_CLASS_DESCRIPTOR->setOldUILayoutDislikes(ILandroid/widget/TextView;)V" + ) + } + } ?: return ButtonTagFingerprint.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/returnyoutubedislike/shorts/fingerprints/ShortsTextViewFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/shorts/fingerprints/ShortsTextViewFingerprint.kt new file mode 100644 index 000000000..a60fa5ab1 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/shorts/fingerprints/ShortsTextViewFingerprint.kt @@ -0,0 +1,30 @@ +package app.revanced.patches.youtube.utils.returnyoutubedislike.shorts.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.Opcode + +object ShortsTextViewFingerprint : MethodFingerprint( + returnType = "V", + parameters = listOf("L", "L"), + opcodes = listOf( + Opcode.INVOKE_SUPER, // first instruction of method + Opcode.IF_NEZ, + Opcode.RETURN_VOID, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT_OBJECT, + Opcode.CHECK_CAST, + Opcode.SGET_OBJECT, // insertion point, must be after constructor call to parent class + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT, + Opcode.CONST_4, + Opcode.IF_EQZ, + Opcode.CONST_4, + Opcode.IF_EQ, + Opcode.CONST_4, + Opcode.IF_EQ, + Opcode.RETURN_VOID, + Opcode.IGET_OBJECT, // TextView field + Opcode.CHECK_CAST, + Opcode.IGET_BOOLEAN, // boolean field + ) +) \ No newline at end of file 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 new file mode 100644 index 000000000..3e4c1e7c3 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/shorts/patch/ReturnYouTubeDislikeShortsPatch.kt @@ -0,0 +1,61 @@ +package app.revanced.patches.youtube.utils.returnyoutubedislike.shorts.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +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.patcher.util.smali.ExternalLabel +import app.revanced.patches.shared.annotation.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 + +@Name("return-youtube-dislike-shorts") +@YouTubeCompatibility +@Version("0.0.1") +class ReturnYouTubeDislikeShortsPatch : BytecodePatch( + listOf(ShortsTextViewFingerprint) +) { + override fun execute(context: BytecodeContext): PatchResult { + ShortsTextViewFingerprint.result?.let { + it.mutableMethod.apply { + val patternResult = it.scanResult.patternScanResult!! + + // If the field is true, the TextView is for a dislike button. + val isDisLikesBooleanReference = getInstruction(patternResult.endIndex).reference + + val textViewFieldReference = // Like/Dislike button TextView field + getInstruction(patternResult.endIndex - 2).reference + + // Check if the hooked TextView object is that of the dislike button. + // If RYD is disabled, or the TextView object is not that of the dislike button, the execution flow is not interrupted. + // Otherwise, the TextView object is modified, and the execution flow is interrupted to prevent it from being changed afterward. + val insertIndex = patternResult.startIndex + 6 + addInstructionsWithLabels( + insertIndex, """ + # Check, if the TextView is for a dislike button + iget-boolean v0, p0, $isDisLikesBooleanReference + if-eqz v0, :ryd_disabled + + # Hook the TextView, if it is for the dislike button + iget-object v0, p0, $textViewFieldReference + invoke-static {v0}, $INTEGRATIONS_RYD_CLASS_DESCRIPTOR->setShortsDislikes(Landroid/view/View;)Z + move-result v0 + if-eqz v0, :ryd_disabled + return-void + """, ExternalLabel("ryd_disabled", getInstruction(insertIndex)) + ) + } + } ?: 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/fingerprints/SpannableStringBuilderFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubeusername/fingerprints/SpannableStringBuilderFingerprint.kt new file mode 100644 index 000000000..ff15ead1d --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubeusername/fingerprints/SpannableStringBuilderFingerprint.kt @@ -0,0 +1,14 @@ +package app.revanced.patches.youtube.utils.returnyoutubeusername.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.Opcode + +object SpannableStringBuilderFingerprint : MethodFingerprint( + returnType = "L", + opcodes = listOf( + Opcode.INVOKE_STATIC, + Opcode.MOVE_RESULT_OBJECT, + Opcode.CONST_4 + ), + strings = listOf("TextComponentSpec: No converter for extension: %s") +) \ No newline at end of file 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 new file mode 100644 index 000000000..d30dbceaf --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubeusername/patch/ReturnYouTubeUserNamePatch.kt @@ -0,0 +1,52 @@ +package app.revanced.patches.youtube.utils.returnyoutubeusername.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction +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.patcher.patch.annotations.Patch +import app.revanced.patches.shared.annotation.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 +import org.jf.dexlib2.iface.instruction.formats.Instruction35c + +@Patch +@Name("return-youtube-user-name") +@Description("Replace user handles in YouTube comments with user nicknames.") +@DependsOn([SettingsPatch::class]) +@YouTubeCompatibility +@Version("0.0.1") +class ReturnYouTubeUserNamePatch : BytecodePatch( + listOf(SpannableStringBuilderFingerprint) +) { + override fun execute(context: BytecodeContext): PatchResult { + + SpannableStringBuilderFingerprint.result?.let { + it.mutableMethod.apply { + val targetIndex = it.scanResult.patternScanResult!!.startIndex + val targetReference = getInstruction(targetIndex).reference + val targetRegister = getInstruction(targetIndex).registerC + + addInstructions( + targetIndex + 1, """ + invoke-static {v$targetRegister}, Lapp/revanced/integrations/patches/utils/ReturnYouTubeCommentUsernamePatch;->onCharSequenceLoaded(Ljava/lang/CharSequence;)Ljava/lang/CharSequence; + move-result-object v$targetRegister + invoke-static {v$targetRegister}, $targetReference + """ + ) + removeInstruction(targetIndex) + } + } ?: return SpannableStringBuilderFingerprint.toErrorResult() + + return PatchResultSuccess() + } +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/fingerprints/ThemeSetterSystemFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/settings/bytecode/fingerprints/ThemeSetterSystemFingerprint.kt similarity index 51% rename from src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/fingerprints/ThemeSetterSystemFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/settings/bytecode/fingerprints/ThemeSetterSystemFingerprint.kt index 707aa2355..7c7487e2f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/fingerprints/ThemeSetterSystemFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/settings/bytecode/fingerprints/ThemeSetterSystemFingerprint.kt @@ -1,12 +1,12 @@ -package app.revanced.patches.youtube.misc.settings.bytecode.fingerprints +package app.revanced.patches.youtube.utils.settings.bytecode.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.appearanceStringId +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.Appearance import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.Opcode object ThemeSetterSystemFingerprint : MethodFingerprint( returnType = "L", opcodes = listOf(Opcode.RETURN_OBJECT), - customFingerprint = { it, _ -> it.isWideLiteralExists(appearanceStringId) } + customFingerprint = { it, _ -> it.isWideLiteralExists(Appearance) } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/patch/SettingsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/settings/bytecode/patch/SettingsBytecodePatch.kt similarity index 86% rename from src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/patch/SettingsBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/settings/bytecode/patch/SettingsBytecodePatch.kt index b59be2295..76ebcdab1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/patch/SettingsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/settings/bytecode/patch/SettingsBytecodePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.settings.bytecode.patch +package app.revanced.patches.youtube.utils.settings.bytecode.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Name @@ -12,9 +12,9 @@ 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.misc.integrations.patch.IntegrationsPatch -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.youtube.misc.settings.bytecode.fingerprints.ThemeSetterSystemFingerprint +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 import app.revanced.util.bytecode.BytecodeHelper.injectInit import app.revanced.util.integrations.Constants.INTEGRATIONS_PATH diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/resource/patch/SettingsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/settings/resource/patch/SettingsPatch.kt similarity index 85% rename from src/main/kotlin/app/revanced/patches/youtube/misc/settings/resource/patch/SettingsPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/settings/resource/patch/SettingsPatch.kt index 2fac4c3d8..b205fd79b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/resource/patch/SettingsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/settings/resource/patch/SettingsPatch.kt @@ -1,5 +1,6 @@ -package app.revanced.patches.youtube.misc.settings.resource.patch +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 @@ -10,9 +11,9 @@ 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.misc.integrations.patch.IntegrationsPatch -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsBytecodePatch +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 import app.revanced.util.resources.IconHelper.YOUTUBE_LAUNCHER_ICON_ARRAY import app.revanced.util.resources.IconHelper.copyFiles import app.revanced.util.resources.IconHelper.makeDirectoryAndCopyFiles @@ -24,6 +25,7 @@ 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") @@ -95,6 +97,16 @@ class SettingsPatch : AbstractSettingsResourcePatch( } } + /** + * If ad services config exists, disable it + */ + context.xmlEditor["AndroidManifest.xml"].use { editor -> + val tags = editor.file.getElementsByTagName("property") + List(tags.length) { tags.item(it) as Element } + .filter { it.getAttribute("android:name").contains("AD_SERVICES_CONFIG") } + .forEach { it.parentNode.removeChild(it) } + } + /** * If a custom branding icon path exists, merge it */ diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/sponsorblock/bytecode/fingerprints/EndScreenEngagementPanelsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/bytecode/fingerprints/EndScreenEngagementPanelsFingerprint.kt similarity index 77% rename from src/main/kotlin/app/revanced/patches/youtube/misc/sponsorblock/bytecode/fingerprints/EndScreenEngagementPanelsFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/bytecode/fingerprints/EndScreenEngagementPanelsFingerprint.kt index 95a01fb3c..672534fe9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/sponsorblock/bytecode/fingerprints/EndScreenEngagementPanelsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/bytecode/fingerprints/EndScreenEngagementPanelsFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.sponsorblock.bytecode.fingerprints +package app.revanced.patches.youtube.utils.sponsorblock.bytecode.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/sponsorblock/bytecode/fingerprints/OverlayViewLayoutFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/bytecode/fingerprints/OverlayViewLayoutFingerprint.kt similarity index 60% rename from src/main/kotlin/app/revanced/patches/youtube/misc/sponsorblock/bytecode/fingerprints/OverlayViewLayoutFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/bytecode/fingerprints/OverlayViewLayoutFingerprint.kt index f855d940d..6607f24e8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/sponsorblock/bytecode/fingerprints/OverlayViewLayoutFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/bytecode/fingerprints/OverlayViewLayoutFingerprint.kt @@ -1,7 +1,7 @@ -package app.revanced.patches.youtube.misc.sponsorblock.bytecode.fingerprints +package app.revanced.patches.youtube.utils.sponsorblock.bytecode.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.insetOverlayViewLayoutId +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.InsetOverlayViewLayout import app.revanced.util.bytecode.isWideLiteralExists import org.jf.dexlib2.Opcode @@ -12,5 +12,5 @@ object OverlayViewLayoutFingerprint : MethodFingerprint( Opcode.MOVE_RESULT_OBJECT, Opcode.CHECK_CAST ), - customFingerprint = { it, _ -> it.definingClass.endsWith("YouTubeControlsOverlay;") && it.isWideLiteralExists(insetOverlayViewLayoutId) } + 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/misc/sponsorblock/bytecode/fingerprints/PlayerControllerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/bytecode/fingerprints/PlayerControllerFingerprint.kt similarity index 76% rename from src/main/kotlin/app/revanced/patches/youtube/misc/sponsorblock/bytecode/fingerprints/PlayerControllerFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/bytecode/fingerprints/PlayerControllerFingerprint.kt index 4d9475a64..d61ed6d64 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/sponsorblock/bytecode/fingerprints/PlayerControllerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/bytecode/fingerprints/PlayerControllerFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.sponsorblock.bytecode.fingerprints +package app.revanced.patches.youtube.utils.sponsorblock.bytecode.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint 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 new file mode 100644 index 000000000..8e0bf8d6b --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/bytecode/fingerprints/RectangleFieldInvalidatorFingerprint.kt @@ -0,0 +1,21 @@ +package app.revanced.patches.youtube.utils.sponsorblock.bytecode.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.iface.instruction.ReferenceInstruction +import org.jf.dexlib2.iface.reference.MethodReference + +object RectangleFieldInvalidatorFingerprint : MethodFingerprint( + returnType = "V", + customFingerprint = custom@{ methodDef, _ -> + val instructions = methodDef.implementation?.instructions!! + val instructionCount = instructions.count() + + // 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) + + reference?.parameterTypes?.size == 1 && reference.name == "invalidate" // the reference is the invalidate(..) method + } +) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt similarity index 69% rename from src/main/kotlin/app/revanced/patches/youtube/misc/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt index 01ff85642..c7630446d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.sponsorblock.bytecode.patch +package app.revanced.patches.youtube.utils.sponsorblock.bytecode.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Name @@ -8,22 +8,24 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction +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.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.misc.overridespeed.bytecode.patch.OverrideSpeedHookPatch -import app.revanced.patches.youtube.misc.playercontrols.patch.PlayerControlsPatch -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.insetOverlayViewLayoutId -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.totalTimeId -import app.revanced.patches.youtube.misc.sponsorblock.bytecode.fingerprints.* -import app.revanced.patches.youtube.misc.timebar.patch.HookTimeBarPatch -import app.revanced.patches.youtube.misc.videoid.legacy.patch.LegacyVideoIdPatch -import app.revanced.patches.youtube.misc.videoid.mainstream.patch.MainstreamVideoIdPatch +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.videoid.legacy.patch.LegacyVideoIdPatch +import app.revanced.patches.youtube.utils.videoid.mainstream.patch.MainstreamVideoIdPatch import app.revanced.util.bytecode.BytecodeHelper.injectInit import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus import app.revanced.util.bytecode.getWideLiteralIndex @@ -34,12 +36,12 @@ import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction import org.jf.dexlib2.iface.instruction.OneRegisterInstruction import org.jf.dexlib2.iface.instruction.ReferenceInstruction import org.jf.dexlib2.iface.instruction.formats.Instruction35c +import org.jf.dexlib2.iface.reference.FieldReference import org.jf.dexlib2.iface.reference.MethodReference @Name("sponsorblock-bytecode-patch") @DependsOn( [ - HookTimeBarPatch::class, LegacyVideoIdPatch::class, MainstreamVideoIdPatch::class, OverrideSpeedHookPatch::class, @@ -77,22 +79,25 @@ class SponsorBlockBytecodePatch : BytecodePatch( /** * Seekbar drawing */ - insertMethod = HookTimeBarPatch.setTimeBarMethod + insertMethod = SeekbarFingerprint.result!!.let { + SeekbarOnDrawFingerprint.apply { resolve(context, it.mutableClass) } + }.result?.mutableMethod?: return SeekbarFingerprint.toErrorResult() insertInstructions = insertMethod.implementation!!.instructions /** - * Get the instance of the seekbar rectangle + * Get left and right of seekbar rectangle */ - for ((index, instruction) in insertInstructions.withIndex()) { - if (instruction.opcode != Opcode.INVOKE_DIRECT_RANGE) continue - insertMethod.addInstruction( - index, - "invoke-static/range {p0 .. p0}, $INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->setSponsorBarRect(Ljava/lang/Object;)V" - ) - break + val moveRectangleToRegisterIndex = insertInstructions.indexOfFirst { + it.opcode == Opcode.MOVE_OBJECT_FROM16 } + insertMethod.addInstruction( + moveRectangleToRegisterIndex + 1, + "invoke-static/range {p0 .. p0}, " + + "$INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->setSponsorBarRect(Ljava/lang/Object;)V" + ) + for ((index, instruction) in insertInstructions.withIndex()) { if (instruction.opcode != Opcode.INVOKE_STATIC) continue @@ -103,34 +108,12 @@ class SponsorBlockBytecodePatch : BytecodePatch( insertMethod.addInstruction( insertIndex, - "invoke-static {v${invokeInstruction.registerC}}, $INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->setSponsorBarThickness(I)V" + "invoke-static {v${invokeInstruction.registerC}}, " + + "$INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->setSponsorBarThickness(I)V" ) break } - /** - * Set rectangle absolute left and right positions - */ - val drawRectangleInstructions = insertInstructions.filter { - it is ReferenceInstruction && (it.reference as? MethodReference)?.name == "drawRect" && it is FiveRegisterInstruction - }.map { // TODO: improve code - insertInstructions.indexOf(it) to (it as FiveRegisterInstruction).registerD - } - - /** - * Deprecated in YouTube v18.17.43+. - * TODO: remove code from integrations - */ - if (drawRectangleInstructions.size > 3) { - mapOf( - "setSponsorBarAbsoluteLeft" to 3, - "setSponsorBarAbsoluteRight" to 0 - ).forEach { (string, int) -> - val (index, register) = drawRectangleInstructions[int] - injectCallRectangle(index, register, string) - } - } - /** * Draw segment */ @@ -172,7 +155,7 @@ class SponsorBlockBytecodePatch : BytecodePatch( */ TotalTimeFingerprint.result?.mutableMethod?.let { it.apply { - val targetIndex = getWideLiteralIndex(totalTimeId) + 2 + val targetIndex = getWideLiteralIndex(TotalTime) + 2 val targetRegister = getInstruction(targetIndex).registerA addInstructions( @@ -189,7 +172,7 @@ class SponsorBlockBytecodePatch : BytecodePatch( */ OverlayViewLayoutFingerprint.result?.mutableMethod?.let{ it.apply{ - val targetIndex = getWideLiteralIndex(insetOverlayViewLayoutId) + 3 + val targetIndex = getWideLiteralIndex(InsetOverlayViewLayout) + 3 val targetRegister = getInstruction(targetIndex).registerA addInstruction( @@ -202,6 +185,13 @@ class SponsorBlockBytecodePatch : BytecodePatch( /** * Replace strings */ + RectangleFieldInvalidatorFingerprint.resolve(context, SeekbarOnDrawFingerprint.result!!.classDef) + val rectangleFieldInvalidatorInstructions = + RectangleFieldInvalidatorFingerprint.result!!.method.implementation!!.instructions + val rectangleFieldName = + ((rectangleFieldInvalidatorInstructions.elementAt(rectangleFieldInvalidatorInstructions.count() - 3) as ReferenceInstruction).reference as FieldReference).name + + PlayerControllerFingerprint.result?.mutableMethod?.let { val instructions = it.implementation!!.instructions @@ -210,7 +200,7 @@ class SponsorBlockBytecodePatch : BytecodePatch( val register = it.getInstruction(index).registerA it.replaceInstruction( index, - "const-string v$register, \"${MainstreamVideoIdPatch.reactReference}\"" + "const-string v$register, \"$rectangleFieldName\"" ) break } @@ -236,20 +226,5 @@ class SponsorBlockBytecodePatch : BytecodePatch( lateinit var insertMethod: MutableMethod lateinit var insertInstructions: List - - /** - * Adds an invoke-static instruction, called with the new id when the video changes - * @param methodDescriptor which method to call. Params have to be `Ljava/lang/String;` - */ - fun injectCallRectangle( - insertIndex: Int, - targetRegister: Int, - methodDescriptor: String - ) { - insertMethod.addInstruction( - insertIndex, - "invoke-static {v$targetRegister}, $INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->$methodDescriptor(Landroid/graphics/Rect;)V" - ) - } } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/sponsorblock/resource/patch/SponsorBlockResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/resource/patch/SponsorBlockResourcePatch.kt similarity index 94% rename from src/main/kotlin/app/revanced/patches/youtube/misc/sponsorblock/resource/patch/SponsorBlockResourcePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/resource/patch/SponsorBlockResourcePatch.kt index 642bad3f9..622029d5b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/sponsorblock/resource/patch/SponsorBlockResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/resource/patch/SponsorBlockResourcePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.sponsorblock.resource.patch +package app.revanced.patches.youtube.utils.sponsorblock.resource.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -10,8 +10,8 @@ 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.misc.settings.resource.patch.SettingsPatch -import app.revanced.patches.youtube.misc.sponsorblock.bytecode.patch.SponsorBlockBytecodePatch +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 import app.revanced.util.resources.ResourceUtils.copyResources import app.revanced.util.resources.ResourceUtils.copyXmlNode diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/legacy/fingerprint/LegacyVideoIdFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/legacy/fingerprint/LegacyVideoIdFingerprint.kt similarity index 71% rename from src/main/kotlin/app/revanced/patches/youtube/misc/videoid/legacy/fingerprint/LegacyVideoIdFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/videoid/legacy/fingerprint/LegacyVideoIdFingerprint.kt index d91d6eb92..2210f7937 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/legacy/fingerprint/LegacyVideoIdFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/legacy/fingerprint/LegacyVideoIdFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.videoid.legacy.fingerprint +package app.revanced.patches.youtube.utils.videoid.legacy.fingerprint import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint @@ -10,7 +10,5 @@ object LegacyVideoIdFingerprint : MethodFingerprint( accessFlags = AccessFlags.DECLARED_SYNCHRONIZED or AccessFlags.FINAL or AccessFlags.PUBLIC, parameters = listOf("L"), opcodes = listOf(Opcode.INVOKE_INTERFACE), - customFingerprint = { it, _ -> - it.definingClass.endsWith("PlaybackLifecycleMonitor;") - } + customFingerprint = { it, _ -> it.definingClass.endsWith("PlaybackLifecycleMonitor;") } ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/legacy/patch/LegacyVideoIdPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/legacy/patch/LegacyVideoIdPatch.kt similarity index 93% rename from src/main/kotlin/app/revanced/patches/youtube/misc/videoid/legacy/patch/LegacyVideoIdPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/videoid/legacy/patch/LegacyVideoIdPatch.kt index 9a6feb413..859665212 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/legacy/patch/LegacyVideoIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/legacy/patch/LegacyVideoIdPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.videoid.legacy.patch +package app.revanced.patches.youtube.utils.videoid.legacy.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -11,7 +11,7 @@ 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.misc.videoid.legacy.fingerprint.LegacyVideoIdFingerprint +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 diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/mainstream/fingerprint/MainstreamVideoIdFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/fingerprint/MainstreamVideoIdFingerprint.kt similarity index 89% rename from src/main/kotlin/app/revanced/patches/youtube/misc/videoid/mainstream/fingerprint/MainstreamVideoIdFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/fingerprint/MainstreamVideoIdFingerprint.kt index c689094b8..534fb4c19 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/mainstream/fingerprint/MainstreamVideoIdFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/fingerprint/MainstreamVideoIdFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.videoid.mainstream.fingerprint +package app.revanced.patches.youtube.utils.videoid.mainstream.fingerprint import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/mainstream/fingerprint/PlayerControllerSetTimeReferenceFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/fingerprint/PlayerControllerSetTimeReferenceFingerprint.kt similarity index 82% rename from src/main/kotlin/app/revanced/patches/youtube/misc/videoid/mainstream/fingerprint/PlayerControllerSetTimeReferenceFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/fingerprint/PlayerControllerSetTimeReferenceFingerprint.kt index 3af0e0aab..5fbb13b0e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/mainstream/fingerprint/PlayerControllerSetTimeReferenceFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/fingerprint/PlayerControllerSetTimeReferenceFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.videoid.mainstream.fingerprint +package app.revanced.patches.youtube.utils.videoid.mainstream.fingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/fingerprint/PlayerInitFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/fingerprint/PlayerInitFingerprint.kt new file mode 100644 index 000000000..b59316891 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/fingerprint/PlayerInitFingerprint.kt @@ -0,0 +1,7 @@ +package app.revanced.patches.youtube.utils.videoid.mainstream.fingerprint + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +object PlayerInitFingerprint : MethodFingerprint( + strings = listOf("playVideo called on player response with no videoStreamingData.") +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/mainstream/fingerprint/SeekFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/fingerprint/SeekFingerprint.kt similarity index 70% rename from src/main/kotlin/app/revanced/patches/youtube/misc/videoid/mainstream/fingerprint/SeekFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/fingerprint/SeekFingerprint.kt index 256007ec5..020c6f149 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/mainstream/fingerprint/SeekFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/fingerprint/SeekFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.videoid.mainstream.fingerprint +package app.revanced.patches.youtube.utils.videoid.mainstream.fingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/mainstream/fingerprint/TimebarFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/fingerprint/TimebarFingerprint.kt similarity index 60% rename from src/main/kotlin/app/revanced/patches/youtube/misc/videoid/mainstream/fingerprint/TimebarFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/fingerprint/TimebarFingerprint.kt index 233b7f90c..6aae65a06 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/mainstream/fingerprint/TimebarFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/fingerprint/TimebarFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.videoid.mainstream.fingerprint +package app.revanced.patches.youtube.utils.videoid.mainstream.fingerprint import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint @@ -8,8 +8,5 @@ object TimebarFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, parameters = listOf("L"), - customFingerprint = { it, _ -> - it.definingClass.endsWith("/TimeBar;") - && it.name.contains("draw") - } + customFingerprint = { it, _ -> it.definingClass.endsWith("/TimeBar;") && it.name.contains("draw") } ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/fingerprint/VideoLengthFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/fingerprint/VideoLengthFingerprint.kt new file mode 100644 index 000000000..c49d0ef68 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/fingerprint/VideoLengthFingerprint.kt @@ -0,0 +1,19 @@ +package app.revanced.patches.youtube.utils.videoid.mainstream.fingerprint + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.util.bytecode.isWide32LiteralExists +import org.jf.dexlib2.AccessFlags +import org.jf.dexlib2.Opcode + +object VideoLengthFingerprint : MethodFingerprint( + returnType = "V", + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + parameters = emptyList(), + opcodes = listOf( + Opcode.MOVE_RESULT_WIDE, + Opcode.CONST_4, + Opcode.INVOKE_VIRTUAL + ), + customFingerprint = { it, _ -> it.isWide32LiteralExists(45388753) } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/mainstream/fingerprint/VideoTimeHighPrecisionFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/fingerprint/VideoTimeHighPrecisionFingerprint.kt similarity index 88% rename from src/main/kotlin/app/revanced/patches/youtube/misc/videoid/mainstream/fingerprint/VideoTimeHighPrecisionFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/fingerprint/VideoTimeHighPrecisionFingerprint.kt index a6a9f6d50..7cd6b3e83 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/mainstream/fingerprint/VideoTimeHighPrecisionFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/fingerprint/VideoTimeHighPrecisionFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.videoid.mainstream.fingerprint +package app.revanced.patches.youtube.utils.videoid.mainstream.fingerprint import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/mainstream/fingerprint/VideoTimeHighPrecisionParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/fingerprint/VideoTimeHighPrecisionParentFingerprint.kt similarity index 74% rename from src/main/kotlin/app/revanced/patches/youtube/misc/videoid/mainstream/fingerprint/VideoTimeHighPrecisionParentFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/fingerprint/VideoTimeHighPrecisionParentFingerprint.kt index b5eb3e2e4..195f65451 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/mainstream/fingerprint/VideoTimeHighPrecisionParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/fingerprint/VideoTimeHighPrecisionParentFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.videoid.mainstream.fingerprint +package app.revanced.patches.youtube.utils.videoid.mainstream.fingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/mainstream/patch/MainstreamVideoIdPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/patch/MainstreamVideoIdPatch.kt similarity index 75% rename from src/main/kotlin/app/revanced/patches/youtube/misc/videoid/mainstream/patch/MainstreamVideoIdPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/patch/MainstreamVideoIdPatch.kt index 1d6e360c7..3d7856a8d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/mainstream/patch/MainstreamVideoIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/videoid/mainstream/patch/MainstreamVideoIdPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.videoid.mainstream.patch +package app.revanced.patches.youtube.utils.videoid.mainstream.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description @@ -8,6 +8,7 @@ import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.toMethodWalker import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch @@ -17,17 +18,12 @@ 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.misc.playertype.patch.PlayerTypeHookPatch -import app.revanced.patches.youtube.misc.timebar.patch.HookTimeBarPatch -import app.revanced.patches.youtube.misc.videoid.mainstream.fingerprint.* +import app.revanced.patches.youtube.utils.playertype.patch.PlayerTypeHookPatch +import app.revanced.patches.youtube.utils.videoid.mainstream.fingerprint.* import app.revanced.util.integrations.Constants.VIDEO_PATH import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.builder.MutableMethodImplementation -import org.jf.dexlib2.dexbacked.reference.DexBackedMethodReference 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.iface.reference.MethodReference import org.jf.dexlib2.immutable.ImmutableMethod import org.jf.dexlib2.immutable.ImmutableMethodParameter import org.jf.dexlib2.util.MethodUtil @@ -36,12 +32,7 @@ import org.jf.dexlib2.util.MethodUtil @Description("Hook to detect when the video id changes (mainstream)") @YouTubeCompatibility @Version("0.0.1") -@DependsOn( - [ - HookTimeBarPatch::class, - PlayerTypeHookPatch::class - ] -) +@DependsOn([PlayerTypeHookPatch::class]) class MainstreamVideoIdPatch : BytecodePatch( listOf( MainstreamVideoIdFingerprint, @@ -49,6 +40,7 @@ class MainstreamVideoIdPatch : BytecodePatch( PlayerInitFingerprint, SeekFingerprint, TimebarFingerprint, + VideoLengthFingerprint, VideoTimeHighPrecisionFingerprint, VideoTimeHighPrecisionParentFingerprint ) @@ -62,11 +54,9 @@ class MainstreamVideoIdPatch : BytecodePatch( onCreateHook(INTEGRATIONS_CLASS_DESCRIPTOR, "initialize") SeekFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let { - val resultMethod = it.method - - with (it.mutableMethod) { + it.mutableMethod.apply { val seekHelperMethod = ImmutableMethod( - resultMethod.definingClass, + definingClass, "seekTo", listOf(ImmutableMethodParameter("J", null, "time")), "Z", @@ -75,13 +65,12 @@ class MainstreamVideoIdPatch : BytecodePatch( MutableMethodImplementation(4) ).toMutable() - val seekSourceEnumType = resultMethod.parameterTypes[1].toString() + val seekSourceEnumType = parameterTypes[1].toString() seekHelperMethod.addInstructions( - 0, - """ + 0, """ sget-object v0, $seekSourceEnumType->a:$seekSourceEnumType - invoke-virtual {p0, p1, p2, v0}, ${resultMethod.definingClass}->${resultMethod.name}(J$seekSourceEnumType)Z + invoke-virtual {p0, p1, p2, v0}, ${definingClass}->${name}(J$seekSourceEnumType)Z move-result p1 return p1 """ @@ -115,38 +104,27 @@ class MainstreamVideoIdPatch : BytecodePatch( .getMethod() as MutableMethod } ?: return PlayerControllerSetTimeReferenceFingerprint.toErrorResult() + /** + * Set current video length + */ + VideoLengthFingerprint.result?.let { + it.mutableMethod.apply { + val startIndex = it.scanResult.patternScanResult!!.startIndex + val primaryRegister = getInstruction(startIndex).registerA + val secondaryRegister = primaryRegister + 1 - with (HookTimeBarPatch.emptyColorMethod) { - val timeBarResult = TimebarFingerprint.result ?: return TimebarFingerprint.toErrorResult() - val timeBarInstructions = timeBarResult.method.implementation!!.instructions - val timeBarReference = - (timeBarInstructions.elementAt(2) as ReferenceInstruction).reference as MethodReference - - val instructions = implementation!!.instructions - - reactReference = - ((instructions.elementAt(instructions.count() - 3) as ReferenceInstruction).reference as FieldReference).name - - for ((index, instruction) in instructions.withIndex()) { - val fieldReference = (instruction as? ReferenceInstruction)?.reference as? DexBackedMethodReference - if (fieldReference?.let { it.name == timeBarReference.name } == true) { - val primaryRegister = (instructions.elementAt(index + 1) as OneRegisterInstruction).registerA - val secondaryRegister = primaryRegister + 1 - addInstruction( - index + 3, - "invoke-static {v$primaryRegister, v$secondaryRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->setVideoLength(J)V" - ) - break - } + addInstruction( + startIndex + 2, + "invoke-static {v$primaryRegister, v$secondaryRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->setVideoLength(J)V" + ) } - } + } ?: return VideoLengthFingerprint.toErrorResult() MainstreamVideoIdFingerprint.result?.let { - insertIndex = it.scanResult.patternScanResult!!.endIndex - - with (it.mutableMethod) { + it.mutableMethod.apply { insertMethod = this - videoIdRegister = (implementation!!.instructions[insertIndex] as OneRegisterInstruction).registerA + insertIndex = it.scanResult.patternScanResult!!.endIndex + videoIdRegister = getInstruction(insertIndex).registerA } offset++ // offset so setVideoId is called before any injected call } ?: return MainstreamVideoIdFingerprint.toErrorResult() @@ -156,7 +134,6 @@ class MainstreamVideoIdPatch : BytecodePatch( companion object { const val INTEGRATIONS_CLASS_DESCRIPTOR = "$VIDEO_PATH/VideoInformation;" - internal var reactReference: String? = null private var offset = 0 private var playerInitInsertIndex = 4 diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/fingerprints/SpeedArrayGeneratorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/fingerprints/SpeedArrayGeneratorFingerprint.kt index 8453286c3..6c918de3f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/fingerprints/SpeedArrayGeneratorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/fingerprints/SpeedArrayGeneratorFingerprint.kt @@ -3,9 +3,14 @@ package app.revanced.patches.youtube.video.customspeed.fingerprints 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 SpeedArrayGeneratorFingerprint : MethodFingerprint( returnType = "[L", accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC, + opcodes = listOf( + Opcode.CONST_4, + Opcode.NEW_ARRAY + ), strings = listOf("0.0#") ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/fingerprints/VideoSpeedEntriesFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/fingerprints/VideoSpeedEntriesFingerprint.kt deleted file mode 100644 index 2033d6384..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/fingerprints/VideoSpeedEntriesFingerprint.kt +++ /dev/null @@ -1,11 +0,0 @@ -package app.revanced.patches.youtube.video.customspeed.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import org.jf.dexlib2.Opcode - -object VideoSpeedEntriesFingerprint : MethodFingerprint( - opcodes = listOf(Opcode.FILL_ARRAY_DATA), - customFingerprint = { it, _ -> - it.definingClass.endsWith("VideoSpeedEntries;") && it.name == "" - } -) diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/patch/CustomVideoSpeedBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/patch/CustomVideoSpeedBytecodePatch.kt deleted file mode 100644 index 525261780..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/patch/CustomVideoSpeedBytecodePatch.kt +++ /dev/null @@ -1,202 +0,0 @@ -package app.revanced.patches.youtube.video.customspeed.patch - -import app.revanced.extensions.toErrorResult -import app.revanced.patcher.annotation.Description -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels -import app.revanced.patcher.extensions.InstructionExtensions.getInstruction -import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction -import app.revanced.patcher.patch.BytecodePatch -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.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.misc.settings.resource.patch.SettingsPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch.Companion.contexts -import app.revanced.patches.youtube.video.customspeed.fingerprints.SpeedArrayGeneratorFingerprint -import app.revanced.patches.youtube.video.customspeed.fingerprints.SpeedLimiterFingerprint -import app.revanced.patches.youtube.video.customspeed.fingerprints.VideoSpeedEntriesFingerprint -import app.revanced.util.integrations.Constants.VIDEO_PATH -import app.revanced.util.resources.ResourceHelper.addEntries -import app.revanced.util.resources.ResourceHelper.addEntryValues -import app.revanced.util.resources.ResourceUtils.copyXmlNode -import org.jf.dexlib2.builder.instruction.BuilderArrayPayload -import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction -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.iface.reference.MethodReference - -@Patch -@Name("custom-video-speed") -@Description("Adds more video speed options.") -@DependsOn([SettingsPatch::class]) -@YouTubeCompatibility -@Version("0.0.1") -class CustomVideoSpeedPatch : BytecodePatch( - listOf( - SpeedArrayGeneratorFingerprint, - SpeedLimiterFingerprint, - VideoSpeedEntriesFingerprint - ) -) { - override fun execute(context: BytecodeContext): PatchResult { - val arrayPath = "res/values/arrays.xml" - val entriesName = "revanced_custom_video_speed_entry" - val entryValueName = "revanced_custom_video_speed_entry_value" - - val speed = CustomSpeedArrays - ?: return PatchResultError("Invalid video speed array.") - val splits = speed.replace(" ","").split(",") - if (splits.isEmpty()) throw IllegalArgumentException("Invalid speed elements") - - val videoSpeedsArray = splits.map { it.toFloat().toRawBits() } - - SpeedArrayGeneratorFingerprint.result?.let { result -> - with (result.mutableMethod) { - val sizeCallIndex = implementation!!.instructions - .indexOfFirst { ((it as? ReferenceInstruction)?.reference as? MethodReference)?.name == "size" } - - if (sizeCallIndex == -1) return PatchResultError("Couldn't find call to size()") - - val sizeCallResultRegister = - (implementation!!.instructions.elementAt(sizeCallIndex + 1) as OneRegisterInstruction).registerA - - addInstructionsWithLabels( - sizeCallIndex + 2, - """ - invoke-static {}, $VIDEO_PATH/VideoSpeedPatch;->isCustomVideoSpeedEnabled()Z - move-result v9 - if-eqz v9, :defaultspeed - const/4 v$sizeCallResultRegister, 0x0 - """, ExternalLabel("defaultspeed", getInstruction(sizeCallIndex + 2)) - ) - - val (arrayLengthConstIndex, arrayLengthConst) = implementation!!.instructions.withIndex() - .first { (it.value as? NarrowLiteralInstruction)?.narrowLiteral == 7 } - - val arrayLengthConstDestination = (arrayLengthConst as OneRegisterInstruction).registerA - - val videoSpeedsArrayType = "$VIDEO_PATH/VideoSpeedEntries;->videoSpeed:[F" - - addInstructionsWithLabels( - arrayLengthConstIndex + 1, - """ - if-eqz v9, :defaultspeed - sget-object v$arrayLengthConstDestination, $videoSpeedsArrayType - array-length v$arrayLengthConstDestination, v$arrayLengthConstDestination - """, ExternalLabel("defaultspeed", getInstruction(arrayLengthConstIndex + 1)) - ) - - val (originalArrayFetchIndex, originalArrayFetch) = implementation!!.instructions.withIndex() - .first { - val reference = ((it.value as? ReferenceInstruction)?.reference as? FieldReference) - reference?.definingClass?.contains("PlayerConfigModel") ?: false && - reference?.type == "[F" - } - - val originalArrayFetchDestination = (originalArrayFetch as OneRegisterInstruction).registerA - - addInstructionsWithLabels( - originalArrayFetchIndex + 1, - """ - if-eqz v9, :defaultspeed - sget-object v$originalArrayFetchDestination, $videoSpeedsArrayType - """, ExternalLabel("defaultspeed", getInstruction(originalArrayFetchIndex + 1)) - ) - } - } ?: return SpeedArrayGeneratorFingerprint.toErrorResult() - - SpeedLimiterFingerprint.result?.let { result -> - with (result.mutableMethod) { - val (limiterMinConstIndex, limiterMinConst) = implementation!!.instructions.withIndex() - .first { (it.value as? NarrowLiteralInstruction)?.narrowLiteral == 0.25f.toRawBits() } - val (limiterMaxConstIndex, limiterMaxConst) = implementation!!.instructions.withIndex() - .first { (it.value as? NarrowLiteralInstruction)?.narrowLiteral == 2.0f.toRawBits() } - - val limiterMinConstDestination = (limiterMinConst as OneRegisterInstruction).registerA - val limiterMaxConstDestination = (limiterMaxConst as OneRegisterInstruction).registerA - - fun hexFloat(float: Float): String = "0x%08x".format(float.toRawBits()) - - replaceInstruction( - limiterMinConstIndex, - "const/high16 v$limiterMinConstDestination, ${hexFloat(0.0f)}" - ) - replaceInstruction( - limiterMaxConstIndex, - "const/high16 v$limiterMaxConstDestination, ${hexFloat(100.0f)}" - ) - } - } ?: return SpeedLimiterFingerprint.toErrorResult() - - VideoSpeedEntriesFingerprint.result?.let { - with (it.mutableMethod) { - val arrayPayloadIndex = implementation!!.instructions.size - 1 - - replaceInstruction( - 0, - "const/16 v0, ${videoSpeedsArray.size}" - ) - - implementation!!.replaceInstruction( - arrayPayloadIndex, - BuilderArrayPayload( - 4, - videoSpeedsArray - ) - ) - } - } ?: return VideoSpeedEntriesFingerprint.toErrorResult() - - - /** - * Copy arrays - */ - contexts.copyXmlNode("youtube/customspeed/host", "values/arrays.xml", "resources") - - val speedElements = splits.map { it } - for (index in 0 until splits.count()) { - contexts.addEntries( - arrayPath, speedElements[index] + "x", - entriesName - ) - contexts.addEntryValues( - arrayPath, speedElements[index], - entryValueName - ) - } - - /** - * Add settings - */ - SettingsPatch.addPreference( - arrayOf( - "PREFERENCE: VIDEO_SETTINGS", - "SETTINGS: CUSTOM_VIDEO_SPEED" - ) - ) - - SettingsPatch.updatePatchStatus("custom-video-speed") - - return PatchResultSuccess() - } - - companion object : OptionsContainer() { - var CustomSpeedArrays: String? by option( - PatchOption.StringOption( - key = "CustomSpeedArrays", - default = "0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 3.0, 5.0", - title = "Custom Speed Values", - description = "A list of custom video speeds. Be sure to separate them with commas (,)." - ) - ) - } -} 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 new file mode 100644 index 000000000..025cbe6ed --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/patch/CustomVideoSpeedPatch.kt @@ -0,0 +1,126 @@ +package app.revanced.patches.youtube.video.customspeed.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction +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.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.video.customspeed.fingerprints.SpeedArrayGeneratorFingerprint +import app.revanced.patches.youtube.video.customspeed.fingerprints.SpeedLimiterFingerprint +import app.revanced.util.integrations.Constants.VIDEO_PATH +import org.jf.dexlib2.Opcode +import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction +import org.jf.dexlib2.iface.instruction.OneRegisterInstruction +import org.jf.dexlib2.iface.instruction.ReferenceInstruction +import org.jf.dexlib2.iface.instruction.formats.Instruction35c +import org.jf.dexlib2.iface.reference.MethodReference + +@Patch +@Name("custom-video-speed") +@Description("Adds more video speed options.") +@DependsOn([SettingsPatch::class]) +@YouTubeCompatibility +@Version("0.0.1") +class CustomVideoSpeedPatch : BytecodePatch( + listOf( + SpeedArrayGeneratorFingerprint, + SpeedLimiterFingerprint + ) +) { + override fun execute(context: BytecodeContext): PatchResult { + SpeedArrayGeneratorFingerprint.result?.let { result -> + result.mutableMethod.apply { + val targetIndex= result.scanResult.patternScanResult!!.startIndex + val targetRegister = getInstruction(targetIndex).registerA + + addInstructions( + targetIndex + 1, """ + invoke-static {v$targetRegister}, $VIDEO_PATH/CustomVideoSpeedPatch;->getLength(I)I + move-result v$targetRegister + """ + ) + + val targetInstruction = implementation!!.instructions + + for ((index, instruction) in targetInstruction.withIndex()) { + if (instruction.opcode != Opcode.INVOKE_INTERFACE) continue + + val sizeInstruction = getInstruction(index) + if ((sizeInstruction.reference as MethodReference).name != "size") continue + + val register = getInstruction(index + 1).registerA + + addInstructions( + index + 2, """ + invoke-static {v$register}, $VIDEO_PATH/CustomVideoSpeedPatch;->getSize(I)I + move-result v$register + """ + ) + break + } + + + for ((index, instruction) in targetInstruction.withIndex()) { + if (instruction.opcode != Opcode.SGET_OBJECT) continue + + val targetReference = getInstruction(index).reference.toString() + + if (targetReference.contains("PlayerConfigModel;") && targetReference.endsWith("[F")) { + val register = getInstruction(index).registerA + + addInstructions( + index + 1, """ + invoke-static {v$register}, $VIDEO_PATH/CustomVideoSpeedPatch;->getArray([F)[F + move-result-object v$register + """ + ) + break + } + } + } + } ?: return SpeedArrayGeneratorFingerprint.toErrorResult() + + 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 limiterMinConstDestination = getInstruction(limiterMinConstIndex).registerA + val limiterMaxConstDestination = getInstruction(limiterMaxConstIndex).registerA + + replaceInstruction( + limiterMinConstIndex, + "const/high16 v$limiterMinConstDestination, 0x0" + ) + replaceInstruction( + limiterMaxConstIndex, + "const/high16 v$limiterMaxConstDestination, 0x42c80000 # 100.0f" + ) + } + } ?: return SpeedLimiterFingerprint.toErrorResult() + + /** + * Add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: VIDEO_SETTINGS", + "SETTINGS: CUSTOM_VIDEO_SPEED" + ) + ) + + SettingsPatch.updatePatchStatus("custom-video-speed") + + return PatchResultSuccess() + } +} 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 14154096e..2c74221d2 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 @@ -16,7 +16,7 @@ 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.misc.settings.resource.patch.SettingsPatch +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 @@ -27,9 +27,7 @@ import app.revanced.util.integrations.Constants.VIDEO_PATH @YouTubeCompatibility @Version("0.0.1") class DisableHdrVideoPatch : BytecodePatch( - listOf( - HdrCapabilitiesFingerprint - ) + listOf(HdrCapabilitiesFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { @@ -40,20 +38,19 @@ class DisableHdrVideoPatch : BytecodePatch( .getMethod() as MutableMethod ) { addInstructionsWithLabels( - 0, - """ + 0, """ invoke-static {}, $VIDEO_PATH/HDRVideoPatch;->disableHDRVideo()Z move-result v0 if-nez v0, :default return v0 - """, ExternalLabel("default", getInstruction(0)) + """, ExternalLabel("default", getInstruction(0)) ) } } ?: return HdrCapabilitiesFingerprint.toErrorResult() - /* - * Add settings - */ + /** + * Add settings + */ SettingsPatch.addPreference( arrayOf( "PREFERENCE: VIDEO_SETTINGS", diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/livestream/patch/LiveStreamPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/livestream/patch/LiveStreamPatch.kt deleted file mode 100644 index 3c08b2b90..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/video/livestream/patch/LiveStreamPatch.kt +++ /dev/null @@ -1,38 +0,0 @@ -package app.revanced.patches.youtube.video.livestream.patch - -import app.revanced.extensions.toErrorResult -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.BytecodeContext -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.video.livestream.fingerprints.OrganicPlaybackContextModelFingerprint -import app.revanced.util.integrations.Constants.VIDEO_PATH - -@Name("live-stream-speed") -@YouTubeCompatibility -@Version("0.0.1") -class LiveStreamPatch : BytecodePatch( - listOf( - OrganicPlaybackContextModelFingerprint - ) -) { - override fun execute(context: BytecodeContext): PatchResult { - - OrganicPlaybackContextModelFingerprint.result?.mutableMethod?.addInstruction( - 2, - "invoke-static { p2 }, $INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR->liveStreamObserver(Z)V" - ) ?: return OrganicPlaybackContextModelFingerprint.toErrorResult() - - return PatchResultSuccess() - } - - private companion object { - const val INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR = - "$VIDEO_PATH/VideoSpeedPatch;" - } - -} diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/quality/bytecode/fingerprints/VideoQualityReferenceFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/video/quality/fingerprints/VideoQualityReferenceFingerprint.kt similarity index 85% rename from src/main/kotlin/app/revanced/patches/youtube/video/quality/bytecode/fingerprints/VideoQualityReferenceFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/video/quality/fingerprints/VideoQualityReferenceFingerprint.kt index a2c39243f..061fe027a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/quality/bytecode/fingerprints/VideoQualityReferenceFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/quality/fingerprints/VideoQualityReferenceFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.video.quality.bytecode.fingerprints +package app.revanced.patches.youtube.video.quality.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/quality/bytecode/fingerprints/VideoQualitySetterFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/video/quality/fingerprints/VideoQualitySetterFingerprint.kt similarity index 84% rename from src/main/kotlin/app/revanced/patches/youtube/video/quality/bytecode/fingerprints/VideoQualitySetterFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/video/quality/fingerprints/VideoQualitySetterFingerprint.kt index 0ac2e7ca8..5f940cd64 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/quality/bytecode/fingerprints/VideoQualitySetterFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/quality/fingerprints/VideoQualitySetterFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.video.quality.bytecode.fingerprints +package app.revanced.patches.youtube.video.quality.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/quality/bytecode/fingerprints/VideoQualitySettingsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/video/quality/fingerprints/VideoQualitySettingsFingerprint.kt similarity index 86% rename from src/main/kotlin/app/revanced/patches/youtube/video/quality/bytecode/fingerprints/VideoQualitySettingsFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/video/quality/fingerprints/VideoQualitySettingsFingerprint.kt index 99563837f..5b3a77bf3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/quality/bytecode/fingerprints/VideoQualitySettingsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/quality/fingerprints/VideoQualitySettingsFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.video.quality.bytecode.fingerprints +package app.revanced.patches.youtube.video.quality.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/quality/bytecode/fingerprints/VideoQualitySettingsParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/video/quality/fingerprints/VideoQualitySettingsParentFingerprint.kt similarity index 87% rename from src/main/kotlin/app/revanced/patches/youtube/video/quality/bytecode/fingerprints/VideoQualitySettingsParentFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/video/quality/fingerprints/VideoQualitySettingsParentFingerprint.kt index 8ff2dce5b..3897b1ebe 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/quality/bytecode/fingerprints/VideoQualitySettingsParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/quality/fingerprints/VideoQualitySettingsParentFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.video.quality.bytecode.fingerprints +package app.revanced.patches.youtube.video.quality.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/quality/bytecode/fingerprints/VideoUserQualityChangeFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/video/quality/fingerprints/VideoUserQualityChangeFingerprint.kt similarity index 82% rename from src/main/kotlin/app/revanced/patches/youtube/video/quality/bytecode/fingerprints/VideoUserQualityChangeFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/video/quality/fingerprints/VideoUserQualityChangeFingerprint.kt index c481a4cff..19042178e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/quality/bytecode/fingerprints/VideoUserQualityChangeFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/quality/fingerprints/VideoUserQualityChangeFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.video.quality.bytecode.fingerprints +package app.revanced.patches.youtube.video.quality.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/quality/bytecode/patch/VideoQualityBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/quality/patch/VideoQualityPatch.kt similarity index 53% rename from src/main/kotlin/app/revanced/patches/youtube/video/quality/bytecode/patch/VideoQualityBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/video/quality/patch/VideoQualityPatch.kt index e98e62db6..9dd2cfc08 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/quality/bytecode/patch/VideoQualityBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/quality/patch/VideoQualityPatch.kt @@ -1,28 +1,41 @@ -package app.revanced.patches.youtube.video.quality.bytecode.patch +package app.revanced.patches.youtube.video.quality.patch import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +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.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.videoid.legacy.patch.LegacyVideoIdPatch -import app.revanced.patches.youtube.video.quality.bytecode.fingerprints.* +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.util.integrations.Constants.VIDEO_PATH +import app.revanced.util.resources.ResourceUtils.copyXmlNode import org.jf.dexlib2.iface.instruction.ReferenceInstruction import org.jf.dexlib2.iface.reference.FieldReference -@Name("default-video-quality-bytecode-patch") -@DependsOn([LegacyVideoIdPatch::class]) +@Patch +@Name("default-video-quality") +@Description("Adds ability to set default video quality settings.") +@DependsOn( + [ + LegacyVideoIdPatch::class, + SettingsPatch::class + ] +) @YouTubeCompatibility @Version("0.0.1") -class VideoQualityBytecodePatch : BytecodePatch( +class VideoQualityPatch : BytecodePatch( listOf( VideoQualitySetterFingerprint, VideoQualitySettingsParentFingerprint @@ -31,13 +44,14 @@ class VideoQualityBytecodePatch : BytecodePatch( override fun execute(context: BytecodeContext): PatchResult { VideoQualitySetterFingerprint.result?.let { parentResult -> VideoQualityReferenceFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let { result -> - val instructions = result.method.implementation!!.instructions + result.mutableMethod.apply { + qualityFieldReference = + getInstruction(0).reference as FieldReference - qualityFieldReference = - (instructions.elementAt(0) as ReferenceInstruction).reference as FieldReference - - qIndexMethodName = - context.classes.single { it.type == qualityFieldReference.type }.methods.single { it.parameterTypes.first() == "I" }.name + qIndexMethodName = context.classes + .single { it.type == qualityFieldReference.type }.methods + .single { it.parameterTypes.first() == "I" }.name + } } ?: return VideoQualityReferenceFingerprint.toErrorResult() VideoUserQualityChangeFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.addInstruction( @@ -48,22 +62,41 @@ class VideoQualityBytecodePatch : BytecodePatch( VideoQualitySettingsParentFingerprint.result?.let { parentResult -> VideoQualitySettingsFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.let { - relayFieldReference = (it.implementation!!.instructions.elementAt(0) as ReferenceInstruction).reference as FieldReference + relayFieldReference = it.getInstruction(0).reference as FieldReference } ?: return VideoQualitySettingsFingerprint.toErrorResult() parentResult.mutableMethod.addInstructions( 0, """ - iget-object v0, p0, ${parentResult.classDef.type}->${relayFieldReference.name}:${relayFieldReference.type} - iget-object v1, v0, ${relayFieldReference.type}->${qualityFieldReference.name}:${qualityFieldReference.type} - const-string v2, "$qIndexMethodName" - invoke-static {p1, p2, v1, v2}, $INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR->setVideoQuality([Ljava/lang/Object;ILjava/lang/Object;Ljava/lang/String;)I - move-result p2 - """ + iget-object v0, p0, ${parentResult.classDef.type}->${relayFieldReference.name}:${relayFieldReference.type} + iget-object v1, v0, ${relayFieldReference.type}->${qualityFieldReference.name}:${qualityFieldReference.type} + const-string v2, "$qIndexMethodName" + invoke-static {p1, p2, v1, v2}, $INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR->setVideoQuality([Ljava/lang/Object;ILjava/lang/Object;Ljava/lang/String;)I + move-result p2 + """ ) } ?: return VideoQualitySettingsParentFingerprint.toErrorResult() LegacyVideoIdPatch.injectCall("$INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR->newVideoStarted(Ljava/lang/String;)V") + + /** + * Copy arrays + */ + contexts.copyXmlNode("youtube/quality/host", "values/arrays.xml", "resources") + + + /** + * Add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: VIDEO_SETTINGS", + "SETTINGS: DEFAULT_VIDEO_QUALITY" + ) + ) + + SettingsPatch.updatePatchStatus("default-video-quality") + return PatchResultSuccess() } private companion object { @@ -74,6 +107,5 @@ class VideoQualityBytecodePatch : BytecodePatch( private lateinit var relayFieldReference: FieldReference private lateinit var qualityFieldReference: FieldReference - } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/quality/resource/patch/VideoQualityPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/quality/resource/patch/VideoQualityPatch.kt deleted file mode 100644 index 51195265c..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/video/quality/resource/patch/VideoQualityPatch.kt +++ /dev/null @@ -1,52 +0,0 @@ -package app.revanced.patches.youtube.video.quality.resource.patch - -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.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.misc.settings.resource.patch.SettingsPatch -import app.revanced.patches.youtube.video.quality.bytecode.patch.VideoQualityBytecodePatch -import app.revanced.util.resources.ResourceUtils.copyXmlNode - -@Patch -@Name("default-video-quality") -@Description("Adds ability to set default video quality settings.") -@DependsOn( - [ - VideoQualityBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class VideoQualityPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - * Copy arrays - */ - - context.copyXmlNode("youtube/quality/host", "values/arrays.xml", "resources") - - - /* - * Add settings - */ - SettingsPatch.addPreference( - arrayOf( - "PREFERENCE: VIDEO_SETTINGS", - "SETTINGS: DEFAULT_VIDEO_QUALITY" - ) - ) - - SettingsPatch.updatePatchStatus("default-video-quality") - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/bytecode/fingerprints/VideoSpeedSettingsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/bytecode/fingerprints/VideoSpeedSettingsFingerprint.kt deleted file mode 100644 index c647034fb..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/bytecode/fingerprints/VideoSpeedSettingsFingerprint.kt +++ /dev/null @@ -1,12 +0,0 @@ -package app.revanced.patches.youtube.video.speed.bytecode.fingerprints - -import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import org.jf.dexlib2.AccessFlags - -object VideoSpeedSettingsFingerprint : MethodFingerprint( - returnType = "V", - accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, - parameters = listOf("[L", "I"), - strings = listOf("menu_item_playback_speed") -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/bytecode/patch/VideoSpeedBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/bytecode/patch/VideoSpeedBytecodePatch.kt deleted file mode 100644 index 7d9bf4e34..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/bytecode/patch/VideoSpeedBytecodePatch.kt +++ /dev/null @@ -1,66 +0,0 @@ -package app.revanced.patches.youtube.video.speed.bytecode.patch - -import app.revanced.extensions.toErrorResult -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.BytecodeContext -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.patcher.patch.annotations.DependsOn -import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.misc.overridespeed.bytecode.fingerprints.VideoSpeedSettingsFingerprint -import app.revanced.patches.youtube.misc.overridespeed.bytecode.patch.OverrideSpeedHookPatch -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch -import app.revanced.patches.youtube.misc.videoid.mainstream.patch.MainstreamVideoIdPatch -import app.revanced.patches.youtube.video.livestream.patch.LiveStreamPatch -import app.revanced.util.integrations.Constants.VIDEO_PATH -import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction - -@Name("default-video-speed-bytecode-patch") -@DependsOn( - [ - LiveStreamPatch::class, - MainstreamVideoIdPatch::class, - OverrideSpeedHookPatch::class, - SharedResourceIdPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class VideoSpeedBytecodePatch : BytecodePatch( - listOf( - VideoSpeedSettingsFingerprint - ) -) { - override fun execute(context: BytecodeContext): PatchResult { - - with(OverrideSpeedHookPatch.videoSpeedChangedResult) { - val index = scanResult.patternScanResult!!.endIndex - val register = - (method.implementation!!.instructions.elementAt(index) as FiveRegisterInstruction).registerD - - mutableMethod.addInstruction( - index, - "invoke-static { v$register }, $INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR" + - "->" + - "userChangedSpeed(F)V" - ) - } - - VideoSpeedSettingsFingerprint.result?.mutableMethod?.addInstruction( - 0, - "invoke-static {}, $INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR->setDefaultSpeed()V" - ) ?: return VideoSpeedSettingsFingerprint.toErrorResult() - - MainstreamVideoIdPatch.onCreateHook(INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR, "newVideoStarted") - - return PatchResultSuccess() - } - - private companion object { - const val INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR = - "$VIDEO_PATH/VideoSpeedPatch;" - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/livestream/fingerprints/OrganicPlaybackContextModelFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/fingerprints/OrganicPlaybackContextModelFingerprint.kt similarity index 75% rename from src/main/kotlin/app/revanced/patches/youtube/video/livestream/fingerprints/OrganicPlaybackContextModelFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/video/speed/fingerprints/OrganicPlaybackContextModelFingerprint.kt index f0c659bcd..9509a6c11 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/livestream/fingerprints/OrganicPlaybackContextModelFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/fingerprints/OrganicPlaybackContextModelFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.video.livestream.fingerprints +package app.revanced.patches.youtube.video.speed.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint 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 new file mode 100644 index 000000000..fa26914c5 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/patch/VideoSpeedPatch.kt @@ -0,0 +1,75 @@ +package app.revanced.patches.youtube.video.speed.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +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.patcher.patch.annotations.DependsOn +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.shared.annotation.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 +import app.revanced.patches.youtube.video.speed.fingerprints.OrganicPlaybackContextModelFingerprint +import app.revanced.util.integrations.Constants.VIDEO_PATH +import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction + +@Patch +@Name("default-video-speed") +@Description("Adds ability to set default video speed settings.") +@DependsOn( + [ + OverrideSpeedHookPatch::class, + PlayerTypeHookPatch::class + ] +) +@YouTubeCompatibility +@Version("0.0.1") +class VideoSpeedPatch : BytecodePatch( + listOf(OrganicPlaybackContextModelFingerprint) +) { + override fun execute(context: BytecodeContext): PatchResult { + + OverrideSpeedHookPatch.videoSpeedChangedResult.let { + it.mutableMethod.apply { + val index = it.scanResult.patternScanResult!!.endIndex + val register = getInstruction(index).registerD + + addInstruction( + index, + "invoke-static {v$register}, $INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR->userChangedSpeed(F)V" + ) + } + } + + OrganicPlaybackContextModelFingerprint.result?.mutableMethod?.addInstruction( + 2, + "invoke-static {p1,p2}, $INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR->newVideoStarted(Ljava/lang/String;Z)V" + ) ?: return OrganicPlaybackContextModelFingerprint.toErrorResult() + + /** + * Add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: VIDEO_SETTINGS", + "SETTINGS: DEFAULT_VIDEO_SPEED" + ) + ) + + SettingsPatch.updatePatchStatus("default-video-speed") + + return PatchResultSuccess() + } + + private companion object { + const val INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR = + "$VIDEO_PATH/VideoSpeedPatch;" + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/resource/patch/VideoSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/resource/patch/VideoSpeedPatch.kt deleted file mode 100644 index e569d6751..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/resource/patch/VideoSpeedPatch.kt +++ /dev/null @@ -1,44 +0,0 @@ -package app.revanced.patches.youtube.video.speed.resource.patch - -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.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.misc.settings.resource.patch.SettingsPatch -import app.revanced.patches.youtube.video.speed.bytecode.patch.VideoSpeedBytecodePatch - -@Patch -@Name("default-video-speed") -@Description("Adds ability to set default video speed settings.") -@DependsOn( - [ - VideoSpeedBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class VideoSpeedPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - * Add settings - */ - SettingsPatch.addPreference( - arrayOf( - "PREFERENCE: VIDEO_SETTINGS", - "SETTINGS: DEFAULT_VIDEO_SPEED" - ) - ) - - SettingsPatch.updatePatchStatus("default-video-speed") - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/util/bytecode/BytecodeUtils.kt b/src/main/kotlin/app/revanced/util/bytecode/BytecodeUtils.kt index 219f43821..ae5248b74 100644 --- a/src/main/kotlin/app/revanced/util/bytecode/BytecodeUtils.kt +++ b/src/main/kotlin/app/revanced/util/bytecode/BytecodeUtils.kt @@ -14,6 +14,10 @@ fun Method.isWideLiteralExists(value: Long): Boolean { return getWideLiteralIndex(value) != -1 } +fun Method.isWide32LiteralExists(value: Long): Boolean { + return getWide32LiteralIndex(value) != -1 +} + fun Method.getNarrowLiteralIndex(value: Int): Int { return implementation?.let { it.instructions.indexOfFirst { instruction -> @@ -41,3 +45,12 @@ fun Method.getWideLiteralIndex(value: Long): Int { } ?: -1 } +fun Method.getWide32LiteralIndex(value: Long): Int { + return implementation?.let { + it.instructions.indexOfFirst { instruction -> + instruction.opcode == Opcode.CONST_WIDE_32 + && (instruction as WideLiteralInstruction).wideLiteral == value + } + } ?: -1 +} + diff --git a/src/main/kotlin/app/revanced/util/enum/ResourceType.kt b/src/main/kotlin/app/revanced/util/enum/ResourceType.kt index 9edf7a11a..12d294a2b 100644 --- a/src/main/kotlin/app/revanced/util/enum/ResourceType.kt +++ b/src/main/kotlin/app/revanced/util/enum/ResourceType.kt @@ -1,6 +1,7 @@ package app.revanced.util.enum internal enum class ResourceType(val value: String) { + ATTR("attr"), BOOL("bool"), COLOR("color"), DIMEN("dimen"), diff --git a/src/main/kotlin/app/revanced/util/microg/MicroGBytecodeHelper.kt b/src/main/kotlin/app/revanced/util/microg/MicroGBytecodeHelper.kt index 353e8787d..012a86a02 100644 --- a/src/main/kotlin/app/revanced/util/microg/MicroGBytecodeHelper.kt +++ b/src/main/kotlin/app/revanced/util/microg/MicroGBytecodeHelper.kt @@ -1,5 +1,6 @@ package app.revanced.util.microg +import app.revanced.extensions.toErrorResult import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction @@ -53,23 +54,26 @@ internal object MicroGBytecodeHelper { * Patch the prime method to accept the new package name. */ fun transformPrimeMethodPackageName() { - val primeMethod = primeMethodFingerprint.result!!.mutableMethod - val implementation = primeMethod.implementation!! + primeMethodFingerprint.result?.let { + var targetRegister = 2 - var register = 2 - val index = implementation.instructions.indexOfFirst { - if (it.opcode != Opcode.CONST_STRING) return@indexOfFirst false + it.mutableMethod.apply { + val targetIndex = implementation!!.instructions.indexOfFirst { instructions -> + if (instructions.opcode != Opcode.CONST_STRING) return@indexOfFirst false - val instructionString = ((it as Instruction21c).reference as StringReference).string - if (instructionString != fromPackageName) return@indexOfFirst false + val instructionString = ((instructions as Instruction21c).reference as StringReference).string + if (instructionString != fromPackageName) return@indexOfFirst false - register = it.registerA - return@indexOfFirst true - } + targetRegister = instructions.registerA + return@indexOfFirst true + } - primeMethod.replaceInstruction( - index, "const-string v$register, \"$toPackageName\"" - ) + replaceInstruction( + targetIndex, + "const-string v$targetRegister, \"$toPackageName\"" + ) + } + } ?: throw primeMethodFingerprint.toErrorResult() } } @@ -206,24 +210,27 @@ internal object MicroGBytecodeHelper { */ private fun List.returnEarly() { this.forEach { fingerprint -> - val result = fingerprint.result!! - val stringInstructions = when (result.method.returnType.first()) { - 'L' -> """ + fingerprint.result?.let { + it.mutableMethod.apply { + val stringInstructions = when (it.method.returnType.first()) { + 'L' -> """ const/4 v0, 0x0 return-object v0 """ - 'V' -> "return-void" - 'I' -> """ + 'V' -> "return-void" + 'I' -> """ const/4 v0, 0x0 return v0 """ - else -> throw Exception("This case should never happen.") - } - result.mutableMethod.addInstructions( - 0, stringInstructions - ) + else -> throw Exception("This case should never happen.") + } + addInstructions( + 0, stringInstructions + ) + } + } ?: throw fingerprint.toErrorResult() } } } diff --git a/src/main/kotlin/app/revanced/util/resources/IconHelper.kt b/src/main/kotlin/app/revanced/util/resources/IconHelper.kt index 620fc7443..3c9d5859b 100644 --- a/src/main/kotlin/app/revanced/util/resources/IconHelper.kt +++ b/src/main/kotlin/app/revanced/util/resources/IconHelper.kt @@ -1,6 +1,7 @@ package app.revanced.util.resources import app.revanced.patcher.data.ResourceContext +import org.w3c.dom.Element import java.io.File import java.nio.file.Files import java.nio.file.Paths @@ -98,9 +99,7 @@ internal object IconHelper { iconName ) - this["res/values-v31/styles.xml"].writeText( - this["res/values-v31/styles.xml"].readText().replace("@drawable/avd_anim", "") - ) + this.disableSplashAnimation() } internal fun ResourceContext.customIconMusic(iconName: String) { @@ -219,4 +218,15 @@ internal object IconHelper { ) } } + + private fun ResourceContext.disableSplashAnimation() { + val targetPath = "res/values-v31/styles.xml" + + 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") } + .forEach { it.parentNode.removeChild(it) } + } + } } \ No newline at end of file