From 04a7cfff20d2734b1c92713de4e7e08a3b93ee85 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Tue, 22 Mar 2022 00:55:42 +0100 Subject: [PATCH] feat: OldQualityLayout, HideSuggestions, HideReels, EnableSeekbarTapping --- src/main/kotlin/app/revanced/patches/Index.kt | 12 +++-- .../revanced/patches/{ads => ad}/VideoAds.kt | 2 +- .../interaction/EnableSeekbarTapping.kt | 49 +++++++++++++++++ .../CreateButtonRemover.kt | 2 +- .../app/revanced/patches/layout/HideReels.kt | 29 +++++++++++ .../patches/layout/HideSuggestions.kt | 52 +++++++++++++++++++ .../{layouts => layout}/MinimizedPlayback.kt | 2 +- .../patches/layout/OldQualityLayout.kt | 52 +++++++++++++++++++ 8 files changed, 193 insertions(+), 7 deletions(-) rename src/main/kotlin/app/revanced/patches/{ads => ad}/VideoAds.kt (97%) create mode 100644 src/main/kotlin/app/revanced/patches/interaction/EnableSeekbarTapping.kt rename src/main/kotlin/app/revanced/patches/{layouts => layout}/CreateButtonRemover.kt (96%) create mode 100644 src/main/kotlin/app/revanced/patches/layout/HideReels.kt create mode 100644 src/main/kotlin/app/revanced/patches/layout/HideSuggestions.kt rename src/main/kotlin/app/revanced/patches/{layouts => layout}/MinimizedPlayback.kt (91%) create mode 100644 src/main/kotlin/app/revanced/patches/layout/OldQualityLayout.kt diff --git a/src/main/kotlin/app/revanced/patches/Index.kt b/src/main/kotlin/app/revanced/patches/Index.kt index 53c603cec..df2c48dc4 100644 --- a/src/main/kotlin/app/revanced/patches/Index.kt +++ b/src/main/kotlin/app/revanced/patches/Index.kt @@ -1,9 +1,9 @@ package app.revanced.patches import app.revanced.patcher.patch.Patch -import app.revanced.patches.ads.VideoAds -import app.revanced.patches.layouts.CreateButtonRemover -import app.revanced.patches.layouts.MinimizedPlayback +import app.revanced.patches.ad.VideoAds +import app.revanced.patches.interaction.EnableSeekbarTapping +import app.revanced.patches.layout.* import kotlin.reflect.KClass /** @@ -18,6 +18,10 @@ object Index { val patches: Array> = arrayOf( VideoAds::class, MinimizedPlayback::class, - CreateButtonRemover::class + CreateButtonRemover::class, + HideReels::class, + HideSuggestions::class, + OldQualityLayout::class, + EnableSeekbarTapping::class ) } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/ads/VideoAds.kt b/src/main/kotlin/app/revanced/patches/ad/VideoAds.kt similarity index 97% rename from src/main/kotlin/app/revanced/patches/ads/VideoAds.kt rename to src/main/kotlin/app/revanced/patches/ad/VideoAds.kt index 2e4501767..8092b6a17 100644 --- a/src/main/kotlin/app/revanced/patches/ads/VideoAds.kt +++ b/src/main/kotlin/app/revanced/patches/ad/VideoAds.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.ads +package app.revanced.patches.ad import app.revanced.patcher.cache.Cache import app.revanced.patcher.patch.Patch diff --git a/src/main/kotlin/app/revanced/patches/interaction/EnableSeekbarTapping.kt b/src/main/kotlin/app/revanced/patches/interaction/EnableSeekbarTapping.kt new file mode 100644 index 000000000..7262dbb34 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/interaction/EnableSeekbarTapping.kt @@ -0,0 +1,49 @@ +package app.revanced.patches.interaction + +import app.revanced.patcher.cache.Cache +import app.revanced.patcher.patch.Patch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.writer.ASMWriter.insertAt +import org.objectweb.asm.Opcodes +import org.objectweb.asm.tree.* + +class EnableSeekbarTapping : Patch("enable-seekbar-tapping") { + override fun execute(cache: Cache): PatchResult { + val patchData = cache.methods["enable-seekbar-tapping"] + val methodOPatchData = cache.methods["enable-seekbar-tapping-method-o"] + val methodPPatchData = cache.methods["enable-seekbar-tapping-method-p"] + + val elseLabel = LabelNode() + patchData.method.instructions.insertAt( + patchData.scanData.endIndex, + InsnNode(Opcodes.ACONST_NULL), + MethodInsnNode( + Opcodes.INVOKESTATIC, + "fi/razerman/youtube/preferences/BooleanPreferences", + "isTapSeekingEnabled", + "()Z" + ), + JumpInsnNode(Opcodes.IFEQ, elseLabel), + VarInsnNode(Opcodes.ALOAD, 0), + VarInsnNode(Opcodes.ILOAD, 6), + MethodInsnNode( + Opcodes.INVOKEVIRTUAL, + methodOPatchData.declaringClass.name, + methodOPatchData.method.name, + "(I)V" + ), + VarInsnNode(Opcodes.ALOAD, 0), + VarInsnNode(Opcodes.ILOAD, 6), + MethodInsnNode( + Opcodes.INVOKEVIRTUAL, + methodPPatchData.declaringClass.name, + methodPPatchData.method.name, + "(I)V" + ), + elseLabel + ) + + return PatchResultSuccess() + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/layouts/CreateButtonRemover.kt b/src/main/kotlin/app/revanced/patches/layout/CreateButtonRemover.kt similarity index 96% rename from src/main/kotlin/app/revanced/patches/layouts/CreateButtonRemover.kt rename to src/main/kotlin/app/revanced/patches/layout/CreateButtonRemover.kt index 62183cd2b..92c500006 100644 --- a/src/main/kotlin/app/revanced/patches/layouts/CreateButtonRemover.kt +++ b/src/main/kotlin/app/revanced/patches/layout/CreateButtonRemover.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.layouts +package app.revanced.patches.layout import app.revanced.patcher.cache.Cache import app.revanced.patcher.patch.Patch diff --git a/src/main/kotlin/app/revanced/patches/layout/HideReels.kt b/src/main/kotlin/app/revanced/patches/layout/HideReels.kt new file mode 100644 index 000000000..79c9cd3c0 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/layout/HideReels.kt @@ -0,0 +1,29 @@ +package app.revanced.patches.layout + +import app.revanced.patcher.cache.Cache +import app.revanced.patcher.patch.Patch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.writer.ASMWriter.insertAt +import org.objectweb.asm.Opcodes +import org.objectweb.asm.tree.MethodInsnNode +import org.objectweb.asm.tree.VarInsnNode + +class HideReels : Patch("hide-reels") { + override fun execute(cache: Cache): PatchResult { + val patchData = cache.methods["hide-reel-patch"] + + patchData.method.instructions.insertAt( + patchData.scanData.endIndex + 1, + VarInsnNode(Opcodes.ALOAD, 18), + MethodInsnNode( + Opcodes.INVOKESTATIC, + "fi/razerman/youtube/XAdRemover", + "HideReels", + "(Landroid/view/View;)V" + ) + ) + + return PatchResultSuccess() + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/layout/HideSuggestions.kt b/src/main/kotlin/app/revanced/patches/layout/HideSuggestions.kt new file mode 100644 index 000000000..955dd685f --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/layout/HideSuggestions.kt @@ -0,0 +1,52 @@ +package app.revanced.patches.layout + +import app.revanced.patcher.cache.Cache +import app.revanced.patcher.patch.Patch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultError +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.signature.Signature +import app.revanced.patcher.writer.ASMWriter.insertAt +import org.objectweb.asm.Opcodes +import org.objectweb.asm.Type +import org.objectweb.asm.tree.MethodInsnNode +import org.objectweb.asm.tree.VarInsnNode + +class HideSuggestions : Patch("hide-suggestions") { + override fun execute(cache: Cache): PatchResult { + val method = cache.methods["hide-suggestions-patch"].findParentMethod( + Signature( + "hide-suggestions-method", + Type.VOID_TYPE, + Opcodes.ACC_PUBLIC or Opcodes.ACC_FINAL, + arrayOf(Type.BOOLEAN_TYPE), + arrayOf( + Opcodes.ALOAD, + Opcodes.ILOAD, + Opcodes.PUTFIELD, + Opcodes.ALOAD, + Opcodes.GETFIELD + ) + ) + ) ?: return PatchResultError("Parent method hide-suggestions-method has not been found") + + method.method.instructions.insertAt( + 0, + VarInsnNode(Opcodes.ILOAD, 1), + MethodInsnNode( + Opcodes.INVOKESTATIC, + "java/lang/Boolean", + "valueOf", + "(Z)Ljava/lang/Boolean" + ), + MethodInsnNode( + Opcodes.INVOKESTATIC, + "fi/razerman/youtube/XAdRemover", + "HideReels", + "(Landroid/view/View;)V" + ) + ) + + return PatchResultSuccess() + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/layouts/MinimizedPlayback.kt b/src/main/kotlin/app/revanced/patches/layout/MinimizedPlayback.kt similarity index 91% rename from src/main/kotlin/app/revanced/patches/layouts/MinimizedPlayback.kt rename to src/main/kotlin/app/revanced/patches/layout/MinimizedPlayback.kt index 1a67bc211..b5380d9c3 100644 --- a/src/main/kotlin/app/revanced/patches/layouts/MinimizedPlayback.kt +++ b/src/main/kotlin/app/revanced/patches/layout/MinimizedPlayback.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.layouts +package app.revanced.patches.layout import app.revanced.patcher.cache.Cache import app.revanced.patcher.patch.Patch diff --git a/src/main/kotlin/app/revanced/patches/layout/OldQualityLayout.kt b/src/main/kotlin/app/revanced/patches/layout/OldQualityLayout.kt new file mode 100644 index 000000000..54a9f871f --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/layout/OldQualityLayout.kt @@ -0,0 +1,52 @@ +package app.revanced.patches.layout + +import app.revanced.patcher.cache.Cache +import app.revanced.patcher.patch.Patch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultError +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.signature.Signature +import app.revanced.patcher.util.ExtraTypes +import app.revanced.patcher.writer.ASMWriter.insertAt +import org.objectweb.asm.Opcodes +import org.objectweb.asm.tree.JumpInsnNode +import org.objectweb.asm.tree.MethodInsnNode +import org.objectweb.asm.tree.VarInsnNode + +class OldQualityLayout : Patch("old-quality-restore") { + override fun execute(cache: Cache): PatchResult { + val method = cache.methods["old-quality-patch"].findParentMethod( + Signature( + "old-quality-patch-method", + ExtraTypes.Any, + Opcodes.ACC_PUBLIC or Opcodes.ACC_FINAL, + arrayOf(), + arrayOf( + Opcodes.ALOAD, + Opcodes.GETFIELD, + Opcodes.ISTORE, + Opcodes.ICONST_3, + Opcodes.ISTORE + ) + ) + ) ?: return PatchResultError("Parent method old-quality-patch-method has not been found") + + method.method.instructions.insertAt( + 0, + MethodInsnNode( + Opcodes.INVOKESTATIC, + "fi/razerman/youtube/XGlobals", + "useOldStyleQualitySettings", + "()Z" + ), + VarInsnNode(Opcodes.ISTORE, 1), + VarInsnNode(Opcodes.ILOAD, 1), + JumpInsnNode( + Opcodes.IFNE, + (method.method.instructions[method.scanData.endIndex + 3] as JumpInsnNode).label + ), + ) + + return PatchResultSuccess() + } +} \ No newline at end of file