feat(YouTube - Hide player components): Hide related video overlay in fullscreen (#4938)

This commit is contained in:
MarcaD 2025-05-14 10:03:33 +03:00 committed by GitHub
parent b89927a10e
commit ac9be9760c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 124 additions and 1 deletions

View File

@ -0,0 +1,13 @@
package app.revanced.extension.youtube.patches;
import app.revanced.extension.youtube.settings.Settings;
@SuppressWarnings("unused")
public final class HideRelatedVideoOverlayPatch {
/**
* Injection point.
*/
public static boolean hideRelatedVideoOverlay() {
return Settings.HIDE_RELATED_VIDEO_OVERLAY.get();
}
}

View File

@ -139,6 +139,7 @@ public class Settings extends BaseSettings {
public static final BooleanSetting HIDE_EMERGENCY_BOX = new BooleanSetting("revanced_hide_emergency_box", TRUE); public static final BooleanSetting HIDE_EMERGENCY_BOX = new BooleanSetting("revanced_hide_emergency_box", TRUE);
public static final BooleanSetting HIDE_ENDSCREEN_CARDS = new BooleanSetting("revanced_hide_endscreen_cards", FALSE); public static final BooleanSetting HIDE_ENDSCREEN_CARDS = new BooleanSetting("revanced_hide_endscreen_cards", FALSE);
public static final BooleanSetting HIDE_END_SCREEN_SUGGESTED_VIDEO = new BooleanSetting("revanced_end_screen_suggested_video", FALSE, true); public static final BooleanSetting HIDE_END_SCREEN_SUGGESTED_VIDEO = new BooleanSetting("revanced_end_screen_suggested_video", FALSE, true);
public static final BooleanSetting HIDE_RELATED_VIDEO_OVERLAY = new BooleanSetting("revanced_hide_related_video_overlay", FALSE, true);
public static final BooleanSetting HIDE_HIDE_CHANNEL_GUIDELINES = new BooleanSetting("revanced_hide_channel_guidelines", TRUE); public static final BooleanSetting HIDE_HIDE_CHANNEL_GUIDELINES = new BooleanSetting("revanced_hide_channel_guidelines", TRUE);
public static final BooleanSetting HIDE_INFO_PANELS = new BooleanSetting("revanced_hide_info_panels", TRUE); public static final BooleanSetting HIDE_INFO_PANELS = new BooleanSetting("revanced_hide_info_panels", TRUE);
public static final BooleanSetting HIDE_INFO_CARDS = new BooleanSetting("revanced_hide_info_cards", FALSE); public static final BooleanSetting HIDE_INFO_CARDS = new BooleanSetting("revanced_hide_info_cards", FALSE);
@ -478,4 +479,3 @@ public class Settings extends BaseSettings {
// endregion // endregion
} }
} }

View File

@ -1220,6 +1220,10 @@ public final class app/revanced/patches/youtube/layout/hide/player/flyoutmenupan
public static final fun getHidePlayerFlyoutMenuPatch ()Lapp/revanced/patcher/patch/BytecodePatch; public static final fun getHidePlayerFlyoutMenuPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
} }
public final class app/revanced/patches/youtube/layout/hide/relatedvideooverlay/HideRelatedVideoOverlayPatchKt {
public static final fun getHideRelatedVideoOverlayPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
}
public final class app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatchKt { public final class app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatchKt {
public static final fun getDisableRollingNumberAnimationPatch ()Lapp/revanced/patcher/patch/BytecodePatch; public static final fun getDisableRollingNumberAnimationPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
} }

View File

@ -0,0 +1,18 @@
package app.revanced.patches.youtube.layout.hide.relatedvideooverlay
import app.revanced.patcher.fingerprint
import app.revanced.util.literal
internal val relatedEndScreenResultsParentFingerprint = fingerprint {
returns("V")
literal{ appRelatedEndScreenResults }
}
internal val relatedEndScreenResultsFingerprint = fingerprint {
returns("V")
parameters(
"I",
"Z",
"I",
)
}

View File

@ -0,0 +1,83 @@
package app.revanced.patches.youtube.layout.hide.relatedvideooverlay
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patcher.patch.resourcePatch
import app.revanced.patches.all.misc.resources.addResources
import app.revanced.patches.all.misc.resources.addResourcesPatch
import app.revanced.patches.shared.misc.mapping.get
import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
import app.revanced.patches.shared.misc.mapping.resourceMappings
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
import app.revanced.patches.youtube.misc.settings.settingsPatch
import app.revanced.patcher.util.smali.ExternalLabel
internal var appRelatedEndScreenResults = -1L
private set
private val hideRelatedVideoOverlayResourcePatch = resourcePatch {
dependsOn(
resourceMappingPatch,
)
execute {
appRelatedEndScreenResults = resourceMappings[
"layout",
"app_related_endscreen_results",
]
}
}
private const val EXTENSION_CLASS_DESCRIPTOR =
"Lapp/revanced/extension/youtube/patches/HideRelatedVideoOverlayPatch;"
@Suppress("unused")
val hideRelatedVideoOverlayPatch = bytecodePatch(
name = "Hide related video overlay",
description = "Adds an option to hide the related video overlay shown when swiping up in fullscreen.",
) {
dependsOn(
settingsPatch,
sharedExtensionPatch,
addResourcesPatch,
hideRelatedVideoOverlayResourcePatch,
)
compatibleWith(
"com.google.android.youtube"(
"19.16.39",
"19.25.37",
"19.34.42",
"19.43.41",
"19.47.53",
"20.07.39",
"20.12.46",
)
)
execute {
addResources("youtube", "layout.hide.relatedvideooverlay.hideRelatedVideoOverlayPatch")
PreferenceScreen.PLAYER.addPreferences(
SwitchPreference("revanced_hide_related_video_overlay")
)
relatedEndScreenResultsFingerprint.match(
relatedEndScreenResultsParentFingerprint.originalClassDef
).method.apply {
addInstructionsWithLabels(
0,
"""
invoke-static {}, $EXTENSION_CLASS_DESCRIPTOR->hideRelatedVideoOverlay()Z
move-result v0
if-eqz v0, :show
return-void
""",
ExternalLabel("show", getInstruction(0))
)
}
}
}

View File

@ -855,6 +855,11 @@ Autoplay can be changed in YouTube settings:
Settings → Playback → Autoplay next video"</string> Settings → Playback → Autoplay next video"</string>
<string name="revanced_end_screen_suggested_video_summary_off">End screen suggested video is shown</string> <string name="revanced_end_screen_suggested_video_summary_off">End screen suggested video is shown</string>
</patch> </patch>
<patch id="layout.hide.relatedvideooverlay.hideRelatedVideoOverlayPatch">
<string name="revanced_hide_related_video_overlay_title">Hide related video overlay in fullscreen</string>
<string name="revanced_hide_related_video_overlay_summary_on">Related video overlay is hidden</string>
<string name="revanced_hide_related_video_overlay_summary_off">Related video overlay is shown</string>
</patch>
<patch id="layout.hide.time.hideTimestampPatch"> <patch id="layout.hide.time.hideTimestampPatch">
<string name="revanced_hide_timestamp_title">Hide video timestamp</string> <string name="revanced_hide_timestamp_title">Hide video timestamp</string>
<string name="revanced_hide_timestamp_summary_on">Timestamp is hidden</string> <string name="revanced_hide_timestamp_summary_on">Timestamp is hidden</string>