mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-06-12 05:07:45 +02:00
fix(YouTube - Disable auto captions): Correctly hide captions with YT 20.12
This commit is contained in:
@ -8,7 +8,9 @@ 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.patches.youtube.shared.subtitleButtonControllerFingerprint
|
||||
|
||||
private const val EXTENSION_CLASS_DESCRIPTOR =
|
||||
"Lapp/revanced/extension/youtube/patches/DisableAutoCaptionsPatch;"
|
||||
|
||||
val autoCaptionsPatch = bytecodePatch(
|
||||
name = "Disable auto captions",
|
||||
@ -36,35 +38,33 @@ val autoCaptionsPatch = bytecodePatch(
|
||||
addResources("youtube", "layout.autocaptions.autoCaptionsPatch")
|
||||
|
||||
PreferenceScreen.PLAYER.addPreferences(
|
||||
SwitchPreference("revanced_auto_captions"),
|
||||
SwitchPreference("revanced_disable_auto_captions"),
|
||||
)
|
||||
|
||||
subtitleTrackFingerprint.method.addInstructions(
|
||||
0,
|
||||
"""
|
||||
invoke-static {}, $EXTENSION_CLASS_DESCRIPTOR->disableAutoCaptions()Z
|
||||
move-result v0
|
||||
if-eqz v0, :auto_captions_enabled
|
||||
const/4 v0, 0x1
|
||||
return v0
|
||||
:auto_captions_enabled
|
||||
nop
|
||||
"""
|
||||
)
|
||||
|
||||
mapOf(
|
||||
startVideoInformerFingerprint to 0,
|
||||
subtitleButtonControllerFingerprint to 1,
|
||||
storyboardRendererDecoderRecommendedLevelFingerprint to 1
|
||||
).forEach { (fingerprint, enabled) ->
|
||||
fingerprint.method.addInstructions(
|
||||
0,
|
||||
"""
|
||||
const/4 v0, 0x$enabled
|
||||
sput-boolean v0, Lapp/revanced/extension/youtube/patches/DisableAutoCaptionsPatch;->captionsButtonDisabled:Z
|
||||
""",
|
||||
invoke-static { v0 }, $EXTENSION_CLASS_DESCRIPTOR->setCaptionsButtonStatus(Z)V
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
subtitleTrackFingerprint.method.addInstructions(
|
||||
0,
|
||||
"""
|
||||
invoke-static {}, Lapp/revanced/extension/youtube/patches/DisableAutoCaptionsPatch;->autoCaptionsEnabled()Z
|
||||
move-result v0
|
||||
if-eqz v0, :auto_captions_enabled
|
||||
sget-boolean v0, Lapp/revanced/extension/youtube/patches/DisableAutoCaptionsPatch;->captionsButtonDisabled:Z
|
||||
if-nez v0, :auto_captions_enabled
|
||||
const/4 v0, 0x1
|
||||
return v0
|
||||
:auto_captions_enabled
|
||||
nop
|
||||
""",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,13 @@ internal val startVideoInformerFingerprint = fingerprint {
|
||||
strings("pc")
|
||||
}
|
||||
|
||||
internal val storyboardRendererDecoderRecommendedLevelFingerprint = fingerprint {
|
||||
returns("V")
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
|
||||
parameters("L")
|
||||
strings("#-1#")
|
||||
}
|
||||
|
||||
internal val subtitleTrackFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
|
||||
returns("Z")
|
||||
@ -28,6 +35,6 @@ internal val subtitleTrackFingerprint = fingerprint {
|
||||
)
|
||||
strings("DISABLE_CAPTIONS_OPTION")
|
||||
custom { _, classDef ->
|
||||
classDef.endsWith("SubtitleTrack;")
|
||||
classDef.endsWith("/SubtitleTrack;")
|
||||
}
|
||||
}
|
||||
|
@ -540,9 +540,9 @@ Adjust volume by swiping vertically on the right side of the screen"</string>
|
||||
<string name="revanced_swipe_change_video_summary_off">Swiping in fullscreen mode will not change to the next/previous video</string>
|
||||
</patch>
|
||||
<patch id="layout.autocaptions.autoCaptionsPatch">
|
||||
<string name="revanced_auto_captions_title">Disable auto captions</string>
|
||||
<string name="revanced_auto_captions_summary_on">Auto captions are disabled</string>
|
||||
<string name="revanced_auto_captions_summary_off">Auto captions are enabled</string>
|
||||
<string name="revanced_disable_auto_captions_title">Disable auto captions</string>
|
||||
<string name="revanced_disable_auto_captions_summary_on">Auto captions are disabled</string>
|
||||
<string name="revanced_disable_auto_captions_summary_off">Auto captions are enabled</string>
|
||||
</patch>
|
||||
<patch id="layout.buttons.action.hideButtonsPatch">
|
||||
<string name="revanced_hide_buttons_screen_title">Action buttons</string>
|
||||
|
Reference in New Issue
Block a user