From cc08c6c3d38879dd4672ec671631b34aa2e3cc77 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Mon, 21 Mar 2022 18:25:12 +0100 Subject: [PATCH] feat: MinimizedPlayback, CreateButtonRemover --- src/main/kotlin/net/revanced/patches/Index.kt | 8 +++-- .../net/revanced/patches/ads/VideoAds.kt | 5 +-- .../patches/layouts/CreateButtonRemover.kt | 32 +++++++++++++++++++ .../patches/layouts/MinimizedPlayback.kt | 13 ++++++++ 4 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 src/main/kotlin/net/revanced/patches/layouts/CreateButtonRemover.kt create mode 100644 src/main/kotlin/net/revanced/patches/layouts/MinimizedPlayback.kt diff --git a/src/main/kotlin/net/revanced/patches/Index.kt b/src/main/kotlin/net/revanced/patches/Index.kt index 1fca6391c..84af57f93 100644 --- a/src/main/kotlin/net/revanced/patches/Index.kt +++ b/src/main/kotlin/net/revanced/patches/Index.kt @@ -1,11 +1,15 @@ package net.revanced.patches import net.revanced.patches.ads.VideoAds +import net.revanced.patches.layouts.CreateButtonRemover +import net.revanced.patches.layouts.MinimizedPlayback // This object contains all the patches and should be imported when using this library object Index { // Array of patches. New patches should be added to the array val patches = arrayOf( - VideoAds::class + VideoAds::class, + MinimizedPlayback::class, + CreateButtonRemover::class ) -} +} \ No newline at end of file diff --git a/src/main/kotlin/net/revanced/patches/ads/VideoAds.kt b/src/main/kotlin/net/revanced/patches/ads/VideoAds.kt index fd0361c18..7de455851 100644 --- a/src/main/kotlin/net/revanced/patches/ads/VideoAds.kt +++ b/src/main/kotlin/net/revanced/patches/ads/VideoAds.kt @@ -12,7 +12,7 @@ import org.objectweb.asm.Type import org.objectweb.asm.tree.MethodInsnNode import org.objectweb.asm.tree.VarInsnNode -class VideoAds: Patch("VideoAds") { +class VideoAds : Patch("VideoAds") { override fun execute(cache: Cache): PatchResult { val showVideoAdsMethodData = cache.methods["show-video-ads"].findParentMethod( Signature( @@ -24,7 +24,8 @@ class VideoAds: Patch("VideoAds") { ) ) ?: return PatchResultError("Could not find required method to patch") - showVideoAdsMethodData.method.instructions.insertAt(0, + showVideoAdsMethodData.method.instructions.insertAt( + 0, VarInsnNode(Opcodes.ISTORE, 1), MethodInsnNode( Opcodes.INVOKESTATIC, diff --git a/src/main/kotlin/net/revanced/patches/layouts/CreateButtonRemover.kt b/src/main/kotlin/net/revanced/patches/layouts/CreateButtonRemover.kt new file mode 100644 index 000000000..06b383363 --- /dev/null +++ b/src/main/kotlin/net/revanced/patches/layouts/CreateButtonRemover.kt @@ -0,0 +1,32 @@ +package net.revanced.patches.layouts + +import net.revanced.patcher.cache.Cache +import net.revanced.patcher.patch.Patch +import net.revanced.patcher.patch.PatchResult +import net.revanced.patcher.patch.PatchResultSuccess +import net.revanced.patcher.writer.ASMWriter.insertAt +import org.objectweb.asm.Opcodes +import org.objectweb.asm.tree.MethodInsnNode +import org.objectweb.asm.tree.VarInsnNode + +class CreateButtonRemover : Patch("create-button-remover") { + override fun execute(cache: Cache): PatchResult { + val patchData = cache.methods["create-button-patch"] + + patchData.method.instructions.insertAt( + patchData.scanData.endIndex - 1, + VarInsnNode( + Opcodes.ALOAD, + 6 + ), + MethodInsnNode( + Opcodes.INVOKESTATIC, + "fi/razerman/youtube/XAdRemover", + "hideCreateButton", + "(Landroid/view/View;)V" + ) + ) + + return PatchResultSuccess() + } +} \ No newline at end of file diff --git a/src/main/kotlin/net/revanced/patches/layouts/MinimizedPlayback.kt b/src/main/kotlin/net/revanced/patches/layouts/MinimizedPlayback.kt new file mode 100644 index 000000000..14eb11ce7 --- /dev/null +++ b/src/main/kotlin/net/revanced/patches/layouts/MinimizedPlayback.kt @@ -0,0 +1,13 @@ +package net.revanced.patches.layouts + +import net.revanced.patcher.cache.Cache +import net.revanced.patcher.patch.Patch +import net.revanced.patcher.patch.PatchResult +import net.revanced.patcher.patch.PatchResultSuccess + +class MinimizedPlayback: Patch("minimized-playback") { + override fun execute(cache: Cache): PatchResult { + cache.methods["minimized-playback-manager"].method.instructions.clear() + return PatchResultSuccess() + } +} \ No newline at end of file