Skip to content

Commit 56fbd8c

Browse files
authored
feat(YouTube): Add Disable sign in to TV popup patch (#5639)
1 parent 1bb8c53 commit 56fbd8c

File tree

6 files changed

+104
-0
lines changed

6 files changed

+104
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package app.revanced.extension.youtube.patches;
2+
3+
import app.revanced.extension.youtube.settings.Settings;
4+
5+
@SuppressWarnings("unused")
6+
public class DisableSignInToTvPopupPatch {
7+
8+
/**
9+
* Injection point.
10+
*/
11+
public static boolean disableSignInToTvPopup() {
12+
return Settings.DISABLE_SIGNIN_TO_TV_POPUP.get();
13+
}
14+
}

extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ public class Settings extends BaseSettings {
256256
public static final BooleanSetting GRADIENT_LOADING_SCREEN = new BooleanSetting("revanced_gradient_loading_screen", FALSE, true);
257257
public static final EnumSetting<SplashScreenAnimationStyle> SPLASH_SCREEN_ANIMATION_STYLE = new EnumSetting<>("revanced_splash_screen_animation_style", SplashScreenAnimationStyle.FPS_60_ONE_SECOND, true);
258258
public static final EnumSetting<HeaderLogo> HEADER_LOGO = new EnumSetting<>("revanced_header_logo", HeaderLogo.DEFAULT, true);
259+
public static final BooleanSetting DISABLE_SIGNIN_TO_TV_POPUP = new BooleanSetting("revanced_disable_signin_to_tv_popup", FALSE);
259260

260261
public static final BooleanSetting REMOVE_VIEWER_DISCRETION_DIALOG = new BooleanSetting("revanced_remove_viewer_discretion_dialog", FALSE,
261262
"revanced_remove_viewer_discretion_dialog_user_dialog_message");

patches/api/patches.api

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,6 +1357,10 @@ public final class app/revanced/patches/youtube/layout/hide/shorts/HideShortsCom
13571357
public static final fun getHideShortsComponentsPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
13581358
}
13591359

1360+
public final class app/revanced/patches/youtube/layout/hide/signintotvpopup/DisableSignInToTvPatchPopupKt {
1361+
public static final fun getDisableSignInToTvPopupPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
1362+
}
1363+
13601364
public final class app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenPatchKt {
13611365
public static final fun getDisableSuggestedVideoEndScreenPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
13621366
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package app.revanced.patches.youtube.layout.hide.signintotvpopup
2+
3+
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
4+
import app.revanced.patcher.patch.bytecodePatch
5+
import app.revanced.patches.all.misc.resources.addResources
6+
import app.revanced.patches.all.misc.resources.addResourcesPatch
7+
import app.revanced.patches.shared.misc.mapping.get
8+
import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
9+
import app.revanced.patches.shared.misc.mapping.resourceMappings
10+
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
11+
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
12+
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
13+
import app.revanced.patches.youtube.misc.settings.settingsPatch
14+
15+
internal var mdx_seamless_tv_sign_in_drawer_fragment_title_id = -1L
16+
private set
17+
18+
private const val EXTENSION_CLASS_DESCRIPTOR =
19+
"Lapp/revanced/extension/youtube/patches/DisableSignInToTvPopupPatch;"
20+
21+
val disableSignInToTvPopupPatch = bytecodePatch(
22+
name = "Disable sign in to TV popup",
23+
description = "Adds an option to disable the popup asking to sign into a TV on the same local network.",
24+
) {
25+
dependsOn(
26+
settingsPatch,
27+
sharedExtensionPatch,
28+
addResourcesPatch,
29+
resourceMappingPatch
30+
)
31+
32+
compatibleWith(
33+
"com.google.android.youtube"(
34+
"19.34.42",
35+
"19.43.41",
36+
"19.47.53",
37+
"20.07.39",
38+
"20.12.46",
39+
"20.13.41",
40+
)
41+
)
42+
43+
execute {
44+
addResources("youtube", "layout.hide.signintotv.disableSignInToTvPopupPatch")
45+
46+
PreferenceScreen.MISC.addPreferences(
47+
SwitchPreference("revanced_disable_signin_to_tv_popup"),
48+
)
49+
50+
mdx_seamless_tv_sign_in_drawer_fragment_title_id = resourceMappings[
51+
"string",
52+
"mdx_seamless_tv_sign_in_drawer_fragment_title",
53+
]
54+
55+
signInToTvPopupFingerprint.method.addInstructionsWithLabels(
56+
0,
57+
"""
58+
invoke-static { }, $EXTENSION_CLASS_DESCRIPTOR->disableSignInToTvPopup()Z
59+
move-result v0
60+
if-eqz v0, :allow_sign_in_popup
61+
const/4 v0, 0x0
62+
return v0
63+
:allow_sign_in_popup
64+
nop
65+
"""
66+
)
67+
}
68+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package app.revanced.patches.youtube.layout.hide.signintotvpopup
2+
3+
import app.revanced.patcher.fingerprint
4+
import app.revanced.util.literal
5+
6+
internal val signInToTvPopupFingerprint = fingerprint {
7+
returns("Z")
8+
parameters("Ljava/lang/String;", "Z", "L")
9+
literal {
10+
mdx_seamless_tv_sign_in_drawer_fragment_title_id
11+
}
12+
}

patches/src/main/resources/addresources/values/strings.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,11 @@ This feature is only available for older devices"</string>
515515
<string name="revanced_remove_viewer_discretion_dialog_summary_off">Dialog will be shown</string>
516516
<string name="revanced_remove_viewer_discretion_dialog_user_dialog_message">This does not bypass the age restriction. It just accepts it automatically.</string>
517517
</patch>
518+
<patch id="layout.hide.signintotv.disableSignInToTvPopupPatch">
519+
<string name="revanced_disable_signin_to_tv_popup_title">Disable Sign in to TV popup</string>
520+
<string name="revanced_disable_signin_to_tv_popup_summary_on">Sign in to TV popup is disabled</string>
521+
<string name="revanced_disable_signin_to_tv_popup_summary_off">Sign in to TV popup is enabled</string>
522+
</patch>
518523
<patch id="interaction.doubletap.disableDoubleTapActionsPatch">
519524
<string name="revanced_disable_chapter_skip_double_tap_title">Disable double tap chapter skip</string>
520525
<string name="revanced_disable_chapter_skip_double_tap_summary_on">Double tap can never trigger a skip to the next/previous chapter</string>

0 commit comments

Comments
 (0)