diff --git a/README.md b/README.md index a6cbda4cb..5e201a7c9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# ReVanced Patches +# ReVanced Patches 🧩 Official patches by ReVanced diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/patch/SwipeControlsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/patch/SwipeControlsPatch.kt index 31117035e..dc5178811 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/patch/SwipeControlsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/patch/SwipeControlsPatch.kt @@ -13,6 +13,7 @@ import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.youtube.interaction.swipecontrols.annotation.SwipeControlsCompatibility import app.revanced.patches.youtube.interaction.swipecontrols.fingerprints.WatchWhileOnStartFingerprint import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch +import app.revanced.patches.youtube.misc.playeroverlay.patch.PlayerOverlaysHookPatch import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch @Patch @@ -24,6 +25,7 @@ import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch dependencies = [ IntegrationsPatch::class, PlayerTypeHookPatch::class, + PlayerOverlaysHookPatch::class, SwipeControlsResourcesPatch::class ] ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/annotation/PlayerOverlaysHookCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/annotation/PlayerOverlaysHookCompatibility.kt new file mode 100644 index 000000000..9a994154b --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/annotation/PlayerOverlaysHookCompatibility.kt @@ -0,0 +1,13 @@ +package app.revanced.patches.youtube.misc.playeroverlay.annotation + +import app.revanced.patcher.annotation.Compatibility +import app.revanced.patcher.annotation.Package + +@Compatibility( + [Package( + "com.google.android.youtube", arrayOf("17.24.34", "17.25.34", "17.26.35") + )] +) +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.RUNTIME) +internal annotation class PlayerOverlaysHookCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/fingerprint/PlayerOverlaysOnFinishInflateFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/fingerprint/PlayerOverlaysOnFinishInflateFingerprint.kt new file mode 100644 index 000000000..26ecae38b --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/fingerprint/PlayerOverlaysOnFinishInflateFingerprint.kt @@ -0,0 +1,21 @@ +package app.revanced.patches.youtube.misc.playeroverlay.fingerprint + +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.youtube.misc.playeroverlay.annotation.PlayerOverlaysHookCompatibility + +@Name("player-overlays-onFinishInflate-fingerprint") +@MatchingMethod( + "LYouTubePlayerOverlaysLayout;", "onFinishInflate" +) +@DirectPatternScanMethod +@PlayerOverlaysHookCompatibility +@Version("0.0.1") +object PlayerOverlaysOnFinishInflateFingerprint : MethodFingerprint( + null, null, null, null, null, { methodDef -> + methodDef.definingClass.endsWith("YouTubePlayerOverlaysLayout;") && methodDef.name == "onFinishInflate" + } +) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/patch/PlayerOverlaysHookPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/patch/PlayerOverlaysHookPatch.kt new file mode 100644 index 000000000..d3e3c7681 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/patch/PlayerOverlaysHookPatch.kt @@ -0,0 +1,35 @@ +package app.revanced.patches.youtube.misc.playeroverlay.patch + +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.annotations.Dependencies +import app.revanced.patcher.patch.impl.BytecodePatch +import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch +import app.revanced.patches.youtube.misc.playeroverlay.annotation.PlayerOverlaysHookCompatibility +import app.revanced.patches.youtube.misc.playeroverlay.fingerprint.PlayerOverlaysOnFinishInflateFingerprint + +@Name("player-overlays-hook") +@Description("hook for adding custom overlays to the video player.") +@PlayerOverlaysHookCompatibility +@Version("0.0.1") +@Dependencies(dependencies = [IntegrationsPatch::class]) +class PlayerOverlaysHookPatch : BytecodePatch( + listOf( + PlayerOverlaysOnFinishInflateFingerprint + ) +) { + override fun execute(data: BytecodeData): PatchResult { + // hook YouTubePlayerOverlaysLayout.onFinishInflate() + val method = PlayerOverlaysOnFinishInflateFingerprint.result!!.mutableMethod + method.addInstruction( + method.implementation!!.instructions.size - 2, + "invoke-static { p0 }, Lapp/revanced/integrations/patches/PlayerOverlaysHookPatch;->YouTubePlayerOverlaysLayout_onFinishInflateHook(Ljava/lang/Object;)V" + ) + return PatchResultSuccess() + } +} \ No newline at end of file