mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2024-11-10 01:01:56 +01:00
feat: use consistent names for patches
This commit is contained in:
parent
b738b6bf35
commit
6347146900
7 changed files with 26 additions and 20 deletions
|
@ -22,4 +22,4 @@ import app.revanced.patcher.annotation.Package
|
|||
)]
|
||||
)
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
internal annotation class GeneralAdsCompatibility
|
||||
internal annotation class HideAdsCompatibility
|
|
@ -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 ->
|
|
@ -21,5 +21,5 @@ import app.revanced.patcher.annotation.Package
|
|||
)]
|
||||
)
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
internal annotation class GeneralAdsCompatibility
|
||||
internal annotation class HideAdsCompatibility
|
||||
|
|
@ -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
|
||||
}
|
||||
)
|
|
@ -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
|
|
@ -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
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue