diff --git a/src/main/kotlin/app/revanced/patches/Index.kt b/src/main/kotlin/app/revanced/patches/Index.kt deleted file mode 100644 index 8a9ce4710..000000000 --- a/src/main/kotlin/app/revanced/patches/Index.kt +++ /dev/null @@ -1,28 +0,0 @@ -package app.revanced.patches - -import app.revanced.patcher.patch.Patch -import app.revanced.patches.ad.VideoAds -import app.revanced.patches.interaction.EnableSeekbarTapping -import app.revanced.patches.layout.* -import app.revanced.patches.misc.Integrations - -/** - * Index contains all the patches and should be imported when using this library. - */ -@Suppress("Unused") -object Index { - /** - * Array of patches. - * New patches should be added to the array. - */ - val patches: Array<() -> Patch> = arrayOf( - ::Integrations, - ::VideoAds, - ::MinimizedPlayback, - ::CreateButtonRemover, - ::HideReels, - ::HideSuggestions, - ::OldQualityLayout, - ::EnableSeekbarTapping - ) -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/ad/VideoAds.kt b/src/main/kotlin/app/revanced/patches/ad/VideoAdsPatch.kt similarity index 97% rename from src/main/kotlin/app/revanced/patches/ad/VideoAds.kt rename to src/main/kotlin/app/revanced/patches/ad/VideoAdsPatch.kt index cefd0674c..494f34d61 100644 --- a/src/main/kotlin/app/revanced/patches/ad/VideoAds.kt +++ b/src/main/kotlin/app/revanced/patches/ad/VideoAdsPatch.kt @@ -9,7 +9,7 @@ import app.revanced.patcher.smali.asInstructions import app.revanced.patches.SHARED_METADATA import org.jf.dexlib2.AccessFlags -class VideoAds : Patch( +class VideoAdsPatch : Patch( PatchMetadata( "video-ads", "TODO", diff --git a/src/main/kotlin/app/revanced/patches/interaction/EnableSeekbarTapping.kt b/src/main/kotlin/app/revanced/patches/interaction/EnableSeekbarTappingPatch.kt similarity index 98% rename from src/main/kotlin/app/revanced/patches/interaction/EnableSeekbarTapping.kt rename to src/main/kotlin/app/revanced/patches/interaction/EnableSeekbarTappingPatch.kt index 1b21d3785..90d3a6925 100644 --- a/src/main/kotlin/app/revanced/patches/interaction/EnableSeekbarTapping.kt +++ b/src/main/kotlin/app/revanced/patches/interaction/EnableSeekbarTappingPatch.kt @@ -12,7 +12,7 @@ import org.jf.dexlib2.builder.instruction.BuilderInstruction21t import org.jf.dexlib2.iface.Method import org.jf.dexlib2.iface.instruction.formats.Instruction11n -class EnableSeekbarTapping : Patch( +class EnableSeekbarTappingPatch : Patch( PatchMetadata( "enable-seekbar-tapping", "TODO", diff --git a/src/main/kotlin/app/revanced/patches/layout/CreateButtonRemover.kt b/src/main/kotlin/app/revanced/patches/layout/CreateButtonRemoverPatch.kt similarity index 95% rename from src/main/kotlin/app/revanced/patches/layout/CreateButtonRemover.kt rename to src/main/kotlin/app/revanced/patches/layout/CreateButtonRemoverPatch.kt index e39cae248..20b233695 100644 --- a/src/main/kotlin/app/revanced/patches/layout/CreateButtonRemover.kt +++ b/src/main/kotlin/app/revanced/patches/layout/CreateButtonRemoverPatch.kt @@ -7,7 +7,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.smali.asInstruction -class CreateButtonRemover : Patch( +class CreateButtonRemoverPatch : Patch( PatchMetadata( "create-button-remover", "TODO", diff --git a/src/main/kotlin/app/revanced/patches/layout/HideReels.kt b/src/main/kotlin/app/revanced/patches/layout/HideReelsPatch.kt similarity index 96% rename from src/main/kotlin/app/revanced/patches/layout/HideReels.kt rename to src/main/kotlin/app/revanced/patches/layout/HideReelsPatch.kt index 9e28f5359..f92b22bd2 100644 --- a/src/main/kotlin/app/revanced/patches/layout/HideReels.kt +++ b/src/main/kotlin/app/revanced/patches/layout/HideReelsPatch.kt @@ -7,7 +7,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.smali.asInstruction -class HideReels : Patch( +class HideReelsPatch : Patch( PatchMetadata( "hide-reels", "TODO", diff --git a/src/main/kotlin/app/revanced/patches/layout/HideSuggestions.kt b/src/main/kotlin/app/revanced/patches/layout/HideSuggestionsPatch.kt similarity index 99% rename from src/main/kotlin/app/revanced/patches/layout/HideSuggestions.kt rename to src/main/kotlin/app/revanced/patches/layout/HideSuggestionsPatch.kt index 005a9c7a6..a6abd5db1 100644 --- a/src/main/kotlin/app/revanced/patches/layout/HideSuggestions.kt +++ b/src/main/kotlin/app/revanced/patches/layout/HideSuggestionsPatch.kt @@ -17,7 +17,7 @@ import org.jf.dexlib2.iface.instruction.formats.Instruction35c import org.jf.dexlib2.immutable.ImmutableMethod import org.jf.dexlib2.immutable.ImmutableMethodImplementation -class HideSuggestions : Patch( +class HideSuggestionsPatch : Patch( PatchMetadata( "hide-suggestions", "TODO", diff --git a/src/main/kotlin/app/revanced/patches/layout/MinimizedPlayback.kt b/src/main/kotlin/app/revanced/patches/layout/MinimizedPlaybackPatch.kt similarity index 96% rename from src/main/kotlin/app/revanced/patches/layout/MinimizedPlayback.kt rename to src/main/kotlin/app/revanced/patches/layout/MinimizedPlaybackPatch.kt index 5573bc13b..38bd78721 100644 --- a/src/main/kotlin/app/revanced/patches/layout/MinimizedPlayback.kt +++ b/src/main/kotlin/app/revanced/patches/layout/MinimizedPlaybackPatch.kt @@ -8,7 +8,7 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.smali.asInstructions -class MinimizedPlayback : Patch( +class MinimizedPlaybackPatch : Patch( PatchMetadata( "minimized-playback", "TODO", diff --git a/src/main/kotlin/app/revanced/patches/layout/OldQualityLayout.kt b/src/main/kotlin/app/revanced/patches/layout/OldQualityLayoutPatch.kt similarity index 98% rename from src/main/kotlin/app/revanced/patches/layout/OldQualityLayout.kt rename to src/main/kotlin/app/revanced/patches/layout/OldQualityLayoutPatch.kt index 59d684985..77b6185c7 100644 --- a/src/main/kotlin/app/revanced/patches/layout/OldQualityLayout.kt +++ b/src/main/kotlin/app/revanced/patches/layout/OldQualityLayoutPatch.kt @@ -11,7 +11,7 @@ import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode import org.jf.dexlib2.builder.instruction.BuilderInstruction21t -class OldQualityLayout : Patch( +class OldQualityLayoutPatch : Patch( PatchMetadata( "old-quality-layout", "TODO", diff --git a/src/main/kotlin/app/revanced/patches/misc/Integrations.kt b/src/main/kotlin/app/revanced/patches/misc/IntegrationsPatch.kt similarity index 98% rename from src/main/kotlin/app/revanced/patches/misc/Integrations.kt rename to src/main/kotlin/app/revanced/patches/misc/IntegrationsPatch.kt index 5b663426d..32b0d3bc3 100644 --- a/src/main/kotlin/app/revanced/patches/misc/Integrations.kt +++ b/src/main/kotlin/app/revanced/patches/misc/IntegrationsPatch.kt @@ -13,7 +13,7 @@ import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.immutable.ImmutableMethod import org.jf.dexlib2.immutable.ImmutableMethodImplementation -class Integrations : Patch( +class IntegrationsPatch : Patch( PatchMetadata( "integrations", "TODO", diff --git a/src/main/kotlin/app/revanced/shared/Index.kt b/src/main/kotlin/app/revanced/shared/Index.kt new file mode 100644 index 000000000..0a81af313 --- /dev/null +++ b/src/main/kotlin/app/revanced/shared/Index.kt @@ -0,0 +1,40 @@ +package app.revanced.shared + +import app.revanced.patcher.patch.Patch +import app.revanced.patches.ad.VideoAdsPatch +import app.revanced.patches.interaction.EnableSeekbarTappingPatch +import app.revanced.patches.layout.* +import app.revanced.patches.misc.IntegrationsPatch +import app.revanced.signatures.SignatureSupplier +import app.revanced.signatures.ad.VideoAdsSignature +import app.revanced.signatures.misc.IntegrationsSignature + +/** + * Index contains all the patches and signatures. + */ +@Suppress("Unused") +object Index { + /** + * Array of patches. + * New patches should be added to the array. + */ + val patches: Array<() -> Patch> = arrayOf( + ::IntegrationsPatch, + ::VideoAdsPatch, + ::MinimizedPlaybackPatch, + ::CreateButtonRemoverPatch, + ::HideReelsPatch, + ::HideSuggestionsPatch, + ::OldQualityLayoutPatch, + ::EnableSeekbarTappingPatch + ) + + /** + * Array of signatures. + * New signatures should be added to the array. + */ + val signatures: Array<() -> SignatureSupplier> = arrayOf( + ::IntegrationsSignature, + ::VideoAdsSignature, + ) +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/signatures/SignatureSupplier.kt b/src/main/kotlin/app/revanced/signatures/SignatureSupplier.kt new file mode 100644 index 000000000..e7994d7af --- /dev/null +++ b/src/main/kotlin/app/revanced/signatures/SignatureSupplier.kt @@ -0,0 +1,7 @@ +package app.revanced.signatures + +import app.revanced.patcher.signature.MethodSignature + +interface SignatureSupplier { + fun get(): MethodSignature +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/signatures/ad/VideoAdsSignature.kt b/src/main/kotlin/app/revanced/signatures/ad/VideoAdsSignature.kt new file mode 100644 index 000000000..f6edf7f8b --- /dev/null +++ b/src/main/kotlin/app/revanced/signatures/ad/VideoAdsSignature.kt @@ -0,0 +1,45 @@ +package app.revanced.signatures.ad + +import app.revanced.patcher.extensions.AccessFlagExtensions.Companion.or +import app.revanced.patcher.signature.* +import app.revanced.signatures.SignatureSupplier +import org.jf.dexlib2.AccessFlags +import org.jf.dexlib2.Opcode + +class VideoAdsSignature : SignatureSupplier { + override fun get() = MethodSignature( + "show-video-ads-constructor", + SignatureMetadata( + method = MethodMetadata( + definingClass = "zai", + methodName = "", + comment = "YouTube v17.03.38" + ), + patcher = PatcherMetadata( + // FIXME: Test this threshold and find the best value. + resolverMethod = ResolverMethod.Fuzzy(2) + ) + ), + "V", + AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, + listOf("L", "L", "L"), + listOf( + Opcode.INVOKE_DIRECT, + Opcode.NEW_INSTANCE, + Opcode.INVOKE_DIRECT, + Opcode.IPUT_OBJECT, + Opcode.NEW_INSTANCE, + Opcode.CONST_4, + Opcode.INVOKE_DIRECT, + Opcode.IPUT_OBJECT, + Opcode.NEW_INSTANCE, + Opcode.INVOKE_DIRECT, + Opcode.IPUT_OBJECT, + Opcode.IPUT_OBJECT, + Opcode.IPUT_OBJECT, + Opcode.CONST_4, + Opcode.IPUT_BOOLEAN, + Opcode.RETURN_VOID + ) + ) +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/signatures/misc/IntegrationsSignature.kt b/src/main/kotlin/app/revanced/signatures/misc/IntegrationsSignature.kt new file mode 100644 index 000000000..3612e86b2 --- /dev/null +++ b/src/main/kotlin/app/revanced/signatures/misc/IntegrationsSignature.kt @@ -0,0 +1,60 @@ +package app.revanced.signatures.misc + +import app.revanced.patcher.signature.* +import app.revanced.signatures.SignatureSupplier +import org.jf.dexlib2.AccessFlags +import org.jf.dexlib2.Opcode + +class IntegrationsSignature : SignatureSupplier { + override fun get() = MethodSignature( + "integrations-patch", + SignatureMetadata( + method = MethodMetadata( + definingClass = "???", // TODO: Fill this in. + methodName = "???", // TODO: Fill this in. + comment = "YouTube v17.03.38" + ), + patcher = PatcherMetadata( + // FIXME: Test this threshold and find the best value. + resolverMethod = ResolverMethod.Fuzzy(2) + ) + ), + "V", + AccessFlags.PUBLIC.value, + listOf(), + listOf( + Opcode.SGET_OBJECT, + Opcode.NEW_INSTANCE, + Opcode.INVOKE_DIRECT, + Opcode.IGET_OBJECT, + Opcode.CONST_STRING, + Opcode.IF_NEZ, + Opcode.IGET_OBJECT, + Opcode.IGET_OBJECT, + Opcode.IGET_OBJECT, + Opcode.IGET_OBJECT, + Opcode.MOVE_OBJECT, + Opcode.CHECK_CAST, + Opcode.MOVE_OBJECT, + Opcode.CHECK_CAST, + Opcode.CONST_4, + Opcode.CONST_STRING, + Opcode.INVOKE_INTERFACE_RANGE, + Opcode.MOVE_RESULT_OBJECT, + Opcode.INVOKE_STATIC, + Opcode.MOVE_RESULT_OBJECT, + Opcode.SPUT_OBJECT, + Opcode.SGET_OBJECT, + Opcode.INVOKE_STATIC, + Opcode.INVOKE_STATIC, + Opcode.MOVE_RESULT_OBJECT, + Opcode.IGET_OBJECT, + Opcode.INVOKE_INTERFACE, + Opcode.MOVE_RESULT_OBJECT, + Opcode.CHECK_CAST, + Opcode.INVOKE_VIRTUAL, + Opcode.INVOKE_SUPER, + Opcode.INVOKE_VIRTUAL + ) + ) +} \ No newline at end of file