diff --git a/api/revanced-patches.api b/api/revanced-patches.api index 48a8b53e2..2b5586b77 100644 --- a/api/revanced-patches.api +++ b/api/revanced-patches.api @@ -2554,12 +2554,22 @@ public final class app/revanced/patches/youtube/player/musicbutton/fingerprints/ public static final field INSTANCE Lapp/revanced/patches/youtube/player/musicbutton/fingerprints/MusicAppDeeplinkButtonFingerprint; } -public final class app/revanced/patches/youtube/player/playerbuttonbg/HidePlayerButtonBackgroundPatch : app/revanced/patcher/patch/ResourcePatch { - public static final field INSTANCE Lapp/revanced/patches/youtube/player/playerbuttonbg/HidePlayerButtonBackgroundPatch; +public final class app/revanced/patches/youtube/player/playerbuttonbg/ForceHidePlayerButtonBackgroundPatch : app/revanced/patcher/patch/ResourcePatch { + public static final field INSTANCE Lapp/revanced/patches/youtube/player/playerbuttonbg/ForceHidePlayerButtonBackgroundPatch; public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V } +public final class app/revanced/patches/youtube/player/playerbuttonbg/HidePlayerButtonBackgroundPatch : app/revanced/patcher/patch/BytecodePatch { + public static final field INSTANCE Lapp/revanced/patches/youtube/player/playerbuttonbg/HidePlayerButtonBackgroundPatch; + public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V + public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V +} + +public final class app/revanced/patches/youtube/player/playerbuttonbg/fingerprints/PlayerPatchFingerprint : app/revanced/patcher/fingerprint/MethodFingerprint { + public static final field INSTANCE Lapp/revanced/patches/youtube/player/playerbuttonbg/fingerprints/PlayerPatchFingerprint; +} + public final class app/revanced/patches/youtube/player/playeroverlay/CustomPlayerOverlayOpacityPatch : app/revanced/patcher/patch/BytecodePatch { public static final field INSTANCE Lapp/revanced/patches/youtube/player/playeroverlay/CustomPlayerOverlayOpacityPatch; public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/playerbuttonbg/HidePlayerButtonBackgroundPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/playerbuttonbg/HidePlayerButtonBackgroundPatch.kt new file mode 100644 index 000000000..93601ac48 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/player/playerbuttonbg/HidePlayerButtonBackgroundPatch.kt @@ -0,0 +1,84 @@ +package app.revanced.patches.youtube.player.playerbuttonbg + +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.annotation.CompatiblePackage +import app.revanced.patcher.patch.annotation.Patch +import app.revanced.patches.youtube.player.playerbuttonbg.fingerprints.PlayerPatchFingerprint +import app.revanced.patches.youtube.utils.integrations.Constants.INTEGRATIONS_PATH +import app.revanced.patches.youtube.utils.playerbutton.PlayerButtonHookPatch +import app.revanced.patches.youtube.utils.settings.SettingsPatch +import app.revanced.util.exception + +@Patch( + name = "Hide player buttons background", + description = "Adds an option to hide player buttons background. Exclude \"Force hide player buttons background\".", + dependencies = [ + PlayerButtonHookPatch::class, + SettingsPatch::class + ], + compatiblePackages = [ + CompatiblePackage( + "com.google.android.youtube", + [ + "18.25.40", + "18.27.36", + "18.29.38", + "18.30.37", + "18.31.40", + "18.32.39", + "18.33.40", + "18.34.38", + "18.35.36", + "18.36.39", + "18.37.36", + "18.38.44", + "18.39.41", + "18.40.34", + "18.41.39", + "18.42.41", + "18.43.45", + "18.44.41", + "18.45.43", + "18.46.45", + "18.48.39", + "18.49.37", + "19.01.34", + "19.02.39", + "19.03.36", + "19.04.38", + "19.05.35", + "19.05.36" + ] + ) + ], + use = false +) +@Suppress("unused") +object HidePlayerButtonBackgroundPatch : BytecodePatch( + setOf(PlayerPatchFingerprint) +) { + override fun execute(context: BytecodeContext) { + + PlayerPatchFingerprint.result?.mutableMethod?.addInstruction( + 0, + "invoke-static {p0}, " + + "$INTEGRATIONS_PATH/utils/ResourceHelper;->" + + "hidePlayerButtonBackground(Landroid/view/View;)V" + ) ?: throw PlayerPatchFingerprint.exception + + /** + * Add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: PLAYER_SETTINGS", + "SETTINGS: HIDE_PLAYER_BUTTON_BACKGROUND" + ) + ) + + SettingsPatch.updatePatchStatus("Hide player buttons background") + + } +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/playerbuttonbg/fingerprints/PlayerPatchFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/playerbuttonbg/fingerprints/PlayerPatchFingerprint.kt new file mode 100644 index 000000000..b1104bea3 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/player/playerbuttonbg/fingerprints/PlayerPatchFingerprint.kt @@ -0,0 +1,10 @@ +package app.revanced.patches.youtube.player.playerbuttonbg.fingerprints + +import app.revanced.patcher.fingerprint.MethodFingerprint + +object PlayerPatchFingerprint : MethodFingerprint( + customFingerprint = { methodDef, _ -> + methodDef.definingClass == "Lapp/revanced/integrations/youtube/patches/player/PlayerPatch;" + && methodDef.name == "hidePlayerButton" + } +) diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml index 25761680d..ba4ed61cd 100644 --- a/src/main/resources/youtube/settings/host/values/strings.xml +++ b/src/main/resources/youtube/settings/host/values/strings.xml @@ -539,6 +539,9 @@ Some components may not be hidden." Place sections are shown. Place sections are hidden. Hide place sections + Player buttons background is shown. + Player buttons background is hidden. + Hide player buttons background Ambient mode menu is shown. Ambient mode menu is hidden. Hide ambient mode menu