diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/toolbar/ToolBarComponentsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/toolbar/ToolBarComponentsPatch.kt index 911ecb9883..320091e12e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/toolbar/ToolBarComponentsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/toolbar/ToolBarComponentsPatch.kt @@ -24,6 +24,7 @@ import app.revanced.patches.youtube.general.toolbar.fingerprints.SearchBarParent import app.revanced.patches.youtube.general.toolbar.fingerprints.SearchResultFingerprint import app.revanced.patches.youtube.general.toolbar.fingerprints.SetActionBarRingoFingerprint import app.revanced.patches.youtube.general.toolbar.fingerprints.SetWordMarkHeaderFingerprint +import app.revanced.patches.youtube.general.toolbar.fingerprints.YoodlesImageViewFingerprint import app.revanced.patches.youtube.general.toolbar.fingerprints.YouActionBarFingerprint import app.revanced.patches.youtube.utils.castbutton.CastButtonPatch import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE @@ -42,6 +43,7 @@ import app.revanced.util.REGISTER_TEMPLATE_REPLACEMENT import app.revanced.util.alsoResolve import app.revanced.util.doRecursively import app.revanced.util.findMethodOrThrow +import app.revanced.util.findOpcodeIndicesReversed import app.revanced.util.getReference import app.revanced.util.getWalkerMethod import app.revanced.util.indexOfFirstInstructionOrThrow @@ -84,6 +86,7 @@ object ToolBarComponentsPatch : BaseBytecodePatch( SetActionBarRingoFingerprint, SetWordMarkHeaderFingerprint, ImageSearchButtonConfigFingerprint, + YoodlesImageViewFingerprint, ) ) { private const val TARGET_RESOURCE_PATH = "res/layout/action_bar_ringo_background.xml" @@ -366,6 +369,26 @@ object ToolBarComponentsPatch : BaseBytecodePatch( // endregion + // region patch for hide YouTube Doodles + + YoodlesImageViewFingerprint.resultOrThrow().mutableMethod.apply { + findOpcodeIndicesReversed{ + opcode == Opcode.INVOKE_VIRTUAL + && getReference()?.name == "setImageDrawable" + }.forEach { insertIndex -> + val (viewRegister, drawableRegister) = getInstruction(insertIndex).let { + Pair(it.registerC, it.registerD) + } + replaceInstruction( + insertIndex, + "invoke-static {v$viewRegister, v$drawableRegister}, " + + "$GENERAL_CLASS_DESCRIPTOR->hideYouTubeDoodles(Landroid/widget/ImageView;Landroid/graphics/drawable/Drawable;)V" + ) + } + } + + // endregion + // region patch for replace create button CreateButtonDrawableFingerprint.resultOrThrow().mutableMethod.apply { diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/toolbar/fingerprints/YoodlesImageViewFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/toolbar/fingerprints/YoodlesImageViewFingerprint.kt new file mode 100644 index 0000000000..90f21ec7b9 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/general/toolbar/fingerprints/YoodlesImageViewFingerprint.kt @@ -0,0 +1,14 @@ +package app.revanced.patches.youtube.general.toolbar.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.YouTubeLogo +import app.revanced.util.fingerprint.LiteralValueFingerprint +import com.android.tools.smali.dexlib2.AccessFlags + +@Suppress("SpellCheckingInspection") +internal object YoodlesImageViewFingerprint : LiteralValueFingerprint( + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + parameters = listOf("L", "L"), + returnType = "Landroid/view/View;", + literalSupplier = { YouTubeLogo } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/SharedResourceIdPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/SharedResourceIdPatch.kt index 0320937b2d..0819c4138b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/SharedResourceIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/SharedResourceIdPatch.kt @@ -118,6 +118,7 @@ object SharedResourceIdPatch : ResourcePatch() { var VideoZoomSnapIndicator = -1L var VoiceSearch = -1L var YouTubeControlsOverlaySubtitleButton = -1L + var YouTubeLogo = -1L var YtOutlinePictureInPictureWhite = -1L var YtOutlineVideoCamera = -1L var YtOutlineXWhite = -1L @@ -233,6 +234,7 @@ object SharedResourceIdPatch : ResourcePatch() { VoiceSearch = getId(ID, "voice_search") YouTubeControlsOverlaySubtitleButton = getId(LAYOUT, "youtube_controls_overlay_subtitle_button") + YouTubeLogo = getId(ID, "youtube_logo") YtOutlinePictureInPictureWhite = getId(DRAWABLE, "yt_outline_picture_in_picture_white_24") YtOutlineVideoCamera = getId(DRAWABLE, "yt_outline_video_camera_black_24") YtOutlineXWhite = getId(DRAWABLE, "yt_outline_x_white_24") diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml index 6aa2997543..71bfacf397 100644 --- a/src/main/resources/youtube/settings/host/values/strings.xml +++ b/src/main/resources/youtube/settings/host/values/strings.xml @@ -623,6 +623,13 @@ You tab → View channel → Menu → Settings" Hide voice search button Voice search button is hidden. Voice search button is shown. + Hide YouTube Doodles + YouTube Doodles are hidden. + YouTube Doodles are shown. + "YouTube Doodles show up a few days each year. + +If a YouTube Doodle is currently showing in your region and this hide setting is on, then the filter bar below the search bar will also be hidden." + Replace Create button Replaces the Create button with the Settings button. Action type to assign to button diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml index de1ad6cf65..7d4b8d02e2 100644 --- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml +++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml @@ -236,6 +236,7 @@