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/GeneralAdsPatch.kt index 8f6bdddb0..219e02a70 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/GeneralAdsPatch.kt @@ -24,7 +24,7 @@ import org.jf.dexlib2.iface.instruction.formats.Instruction35c @Patch -@DependsOn([GeneralAdsResourcePatch::class]) +@DependsOn([GeneralAdsResourcePatch::class, VerticalScrollPatch::class]) @Name("general-ads") @Description("Removes general ads.") @GeneralAdsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/verticalscroll/annotations/VerticalScrollCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/verticalscroll/annotations/VerticalScrollCompatibility.kt new file mode 100644 index 000000000..12a4b74b5 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/verticalscroll/annotations/VerticalScrollCompatibility.kt @@ -0,0 +1,13 @@ +package app.revanced.patches.youtube.misc.fix.verticalscroll.annotations + +import app.revanced.patcher.annotation.Compatibility +import app.revanced.patcher.annotation.Package + +@Compatibility( + [ + Package("com.google.android.youtube"), + ] +) +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.RUNTIME) +internal annotation class VerticalScrollCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/verticalscroll/fingerprints/CanScrollVerticallyFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/verticalscroll/fingerprints/CanScrollVerticallyFingerprint.kt new file mode 100644 index 000000000..1f8792482 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/verticalscroll/fingerprints/CanScrollVerticallyFingerprint.kt @@ -0,0 +1,12 @@ +package app.revanced.patches.youtube.misc.fix.verticalscroll.fingerprints + + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.Opcode + +object CanScrollVerticallyFingerprint : MethodFingerprint( + "Z", + parameters = emptyList(), + opcodes = listOf(Opcode.INSTANCE_OF), + customFingerprint = { methodDef -> methodDef.definingClass.endsWith("SwipeRefreshLayout;") } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/verticalscroll/patch/VerticalScrollPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/verticalscroll/patch/VerticalScrollPatch.kt new file mode 100644 index 000000000..3619ea653 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/verticalscroll/patch/VerticalScrollPatch.kt @@ -0,0 +1,33 @@ +package app.revanced.patches.youtube.misc.fix.verticalscroll.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patches.youtube.misc.fix.verticalscroll.annotations.VerticalScrollCompatibility +import app.revanced.patches.youtube.misc.fix.verticalscroll.fingerprints.CanScrollVerticallyFingerprint + +@Description("Fixes issues with scrolling on the home screen when the first component is of type EmptyComponent.") +@VerticalScrollCompatibility +@Version("0.0.1") +class VerticalScrollPatch : BytecodePatch( + listOf(CanScrollVerticallyFingerprint) +) { + override fun execute(context: BytecodeContext): PatchResult { + val result = CanScrollVerticallyFingerprint.result ?: return CanScrollVerticallyFingerprint.toErrorResult() + + result.mutableMethod.addInstructions( + 0, + """ + const/4 v0, 0x0 + return v0 + """ + ) + + return PatchResultSuccess() + } +}