From 634714690086168e63d6aa9475893135cb58db68 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Tue, 9 May 2023 08:29:43 +0200 Subject: [PATCH] feat: use consistent names for patches --- ...sCompatibility.kt => HideAdsCompatibility.kt} | 2 +- .../{GeneralAdsPatch.kt => HideAdsPatch.kt} | 8 ++++---- ...sCompatibility.kt => HideAdsCompatibility.kt} | 2 +- .../fingerprints/ReelConstructorFingerprint.kt | 4 ++-- .../{GeneralAdsPatch.kt => HideAdsPatch.kt} | 16 ++++++++-------- ...sResourcePatch.kt => HideAdsResourcePatch.kt} | 6 +++--- .../comments/bytecode/patch/CommentsPatch.kt | 8 +++++++- 7 files changed, 26 insertions(+), 20 deletions(-) rename src/main/kotlin/app/revanced/patches/reddit/ad/general/annotations/{GeneralAdsCompatibility.kt => HideAdsCompatibility.kt} (92%) rename src/main/kotlin/app/revanced/patches/reddit/ad/general/patch/{GeneralAdsPatch.kt => HideAdsPatch.kt} (92%) rename src/main/kotlin/app/revanced/patches/youtube/ad/general/annotation/{GeneralAdsCompatibility.kt => HideAdsCompatibility.kt} (91%) rename src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/patch/{GeneralAdsPatch.kt => HideAdsPatch.kt} (88%) rename src/main/kotlin/app/revanced/patches/youtube/ad/general/resource/patch/{GeneralAdsResourcePatch.kt => HideAdsResourcePatch.kt} (98%) diff --git a/src/main/kotlin/app/revanced/patches/reddit/ad/general/annotations/GeneralAdsCompatibility.kt b/src/main/kotlin/app/revanced/patches/reddit/ad/general/annotations/HideAdsCompatibility.kt similarity index 92% rename from src/main/kotlin/app/revanced/patches/reddit/ad/general/annotations/GeneralAdsCompatibility.kt rename to src/main/kotlin/app/revanced/patches/reddit/ad/general/annotations/HideAdsCompatibility.kt index e513e941e..64e444224 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/ad/general/annotations/GeneralAdsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/ad/general/annotations/HideAdsCompatibility.kt @@ -22,4 +22,4 @@ import app.revanced.patcher.annotation.Package )] ) @Target(AnnotationTarget.CLASS) -internal annotation class GeneralAdsCompatibility +internal annotation class HideAdsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/reddit/ad/general/patch/GeneralAdsPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/ad/general/patch/HideAdsPatch.kt similarity index 92% rename from src/main/kotlin/app/revanced/patches/reddit/ad/general/patch/GeneralAdsPatch.kt rename to src/main/kotlin/app/revanced/patches/reddit/ad/general/patch/HideAdsPatch.kt index 86341a62a..7f58d558e 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/ad/general/patch/GeneralAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/ad/general/patch/HideAdsPatch.kt @@ -8,7 +8,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.reddit.ad.general.annotations.GeneralAdsCompatibility +import app.revanced.patches.reddit.ad.general.annotations.HideAdsCompatibility import org.jf.dexlib2.Opcode import org.jf.dexlib2.builder.instruction.BuilderInstruction21c import org.jf.dexlib2.iface.instruction.ReferenceInstruction @@ -16,11 +16,11 @@ import org.jf.dexlib2.iface.reference.StringReference import org.jf.dexlib2.immutable.reference.ImmutableStringReference @Patch -@Name("general-reddit-ads") +@Name("hide-ads") @Description("Removes general ads from the Reddit frontpage and subreddits.") -@GeneralAdsCompatibility +@HideAdsCompatibility @Version("0.0.1") -class GeneralAdsPatch : BytecodePatch() { +class HideAdsPatch : BytecodePatch() { override fun execute(context: BytecodeContext): PatchResult { context.classes.forEach { classDef -> classDef.methods.forEach methodLoop@{ method -> diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/general/annotation/GeneralAdsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/general/annotation/HideAdsCompatibility.kt similarity index 91% rename from src/main/kotlin/app/revanced/patches/youtube/ad/general/annotation/GeneralAdsCompatibility.kt rename to src/main/kotlin/app/revanced/patches/youtube/ad/general/annotation/HideAdsCompatibility.kt index 65931d8c9..b090de22f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/general/annotation/GeneralAdsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/general/annotation/HideAdsCompatibility.kt @@ -21,5 +21,5 @@ import app.revanced.patcher.annotation.Package )] ) @Target(AnnotationTarget.CLASS) -internal annotation class GeneralAdsCompatibility +internal annotation class HideAdsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/fingerprints/ReelConstructorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/fingerprints/ReelConstructorFingerprint.kt index 09a992669..06708052a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/fingerprints/ReelConstructorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/fingerprints/ReelConstructorFingerprint.kt @@ -1,7 +1,7 @@ package app.revanced.patches.youtube.ad.general.bytecode.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.ad.general.resource.patch.GeneralAdsResourcePatch +import app.revanced.patches.youtube.ad.general.resource.patch.HideAdsResourcePatch import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.WideLiteralInstruction @@ -11,7 +11,7 @@ object ReelConstructorFingerprint : MethodFingerprint( ), customFingerprint = { method, _ -> method.implementation?.instructions?.any { - it.opcode == Opcode.CONST && (it as WideLiteralInstruction).wideLiteral == GeneralAdsResourcePatch.reelMultipleItemShelfId + it.opcode == Opcode.CONST && (it as WideLiteralInstruction).wideLiteral == HideAdsResourcePatch.reelMultipleItemShelfId } ?: false } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/patch/GeneralAdsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/patch/HideAdsPatch.kt similarity index 88% rename from src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/patch/GeneralAdsPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/patch/HideAdsPatch.kt index 7f737c565..c681c9f63 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/patch/GeneralAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/patch/HideAdsPatch.kt @@ -15,9 +15,9 @@ 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.misc.fix.verticalscroll.patch.VerticalScrollPatch -import app.revanced.patches.youtube.ad.general.annotation.GeneralAdsCompatibility +import app.revanced.patches.youtube.ad.general.annotation.HideAdsCompatibility import app.revanced.patches.youtube.ad.general.bytecode.fingerprints.ReelConstructorFingerprint -import app.revanced.patches.youtube.ad.general.resource.patch.GeneralAdsResourcePatch +import app.revanced.patches.youtube.ad.general.resource.patch.HideAdsResourcePatch import app.revanced.patches.youtube.misc.fix.backtoexitgesture.patch.FixBackToExitGesturePatch import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction import org.jf.dexlib2.iface.instruction.formats.Instruction31i @@ -25,17 +25,17 @@ import org.jf.dexlib2.iface.instruction.formats.Instruction35c @Patch -@DependsOn([GeneralAdsResourcePatch::class, VerticalScrollPatch::class, FixBackToExitGesturePatch::class]) -@Name("general-ads") +@DependsOn([HideAdsResourcePatch::class, VerticalScrollPatch::class, FixBackToExitGesturePatch::class]) +@Name("hide-ads") @Description("Removes general ads.") -@GeneralAdsCompatibility +@HideAdsCompatibility @Version("0.0.1") -class GeneralAdsPatch : BytecodePatch( +class HideAdsPatch : BytecodePatch( listOf(ReelConstructorFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { fun String.buildHideCall(viewRegister: Int) = "invoke-static { v$viewRegister }, " + - "Lapp/revanced/integrations/patches/GeneralAdsPatch;" + + "Lapp/revanced/integrations/patches/litho/AdsFilter;" + "->" + "$this(Landroid/view/View;)V" @@ -49,7 +49,7 @@ class GeneralAdsPatch : BytecodePatch( if (instruction.opcode != org.jf.dexlib2.Opcode.CONST) return@forEachIndexed // Instruction to store the id adAttribution into a register - if ((instruction as Instruction31i).wideLiteral != GeneralAdsResourcePatch.adAttributionId) + if ((instruction as Instruction31i).wideLiteral != HideAdsResourcePatch.adAttributionId) return@forEachIndexed val insertIndex = index + 1 diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/general/resource/patch/GeneralAdsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/general/resource/patch/HideAdsResourcePatch.kt similarity index 98% rename from src/main/kotlin/app/revanced/patches/youtube/ad/general/resource/patch/GeneralAdsResourcePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/ad/general/resource/patch/HideAdsResourcePatch.kt index f170e9a08..c8cb32c4b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/general/resource/patch/GeneralAdsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/general/resource/patch/HideAdsResourcePatch.kt @@ -8,7 +8,7 @@ import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch import app.revanced.patches.shared.settings.preference.impl.* -import app.revanced.patches.youtube.ad.general.annotation.GeneralAdsCompatibility +import app.revanced.patches.youtube.ad.general.annotation.HideAdsCompatibility import app.revanced.patches.youtube.misc.litho.filter.patch.LithoFilterPatch import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch.PreferenceScreen @@ -20,9 +20,9 @@ import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch.P ResourceMappingPatch::class ] ) -@GeneralAdsCompatibility +@HideAdsCompatibility @Version("0.0.1") -class GeneralAdsResourcePatch : ResourcePatch { +class HideAdsResourcePatch : ResourcePatch { internal companion object { var adAttributionId: Long = -1 var reelMultipleItemShelfId: Long = -1 diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/comments/bytecode/patch/CommentsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/comments/bytecode/patch/CommentsPatch.kt index ee2d88458..e86de09fe 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/comments/bytecode/patch/CommentsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/comments/bytecode/patch/CommentsPatch.kt @@ -58,7 +58,7 @@ class CommentsPatch : BytecodePatch( addInstructions( insertIndex, """ - invoke-static { v$shortsCommentsButtonRegister }, Lapp/revanced/integrations/patches/HideShortsCommentsButtonPatch;->hideShortsCommentsButton(Landroid/view/View;)V + invoke-static { v$shortsCommentsButtonRegister }, $FILTER_METHOD_DESCRIPTOR """ ) } @@ -66,4 +66,10 @@ class CommentsPatch : BytecodePatch( return PatchResultSuccess() } + + private companion object { + private const val FILTER_METHOD_DESCRIPTOR = + "Lapp/revanced/integrations/patches/HideShortsCommentsButtonPatch;" + + "->hideShortsCommentsButton(Landroid/view/View;)V" + } }