feat(YouTube - Hide layout components): Add "Hide view count" and "Hide upload time" settings (#5983)

This commit is contained in:
viSapio
2025-09-25 16:43:59 +04:00
committed by GitHub
parent 0ed7067459
commit 7a37d858fb
5 changed files with 127 additions and 2 deletions
@@ -147,3 +147,17 @@ internal val showFloatingMicrophoneButtonFingerprint = fingerprint {
)
literal { fabButtonId }
}
internal val hideViewCountFingerprint = fingerprint {
accessFlags(AccessFlags.PUBLIC, AccessFlags.STATIC)
returns("Ljava/lang/CharSequence;")
opcodes(
Opcode.RETURN_OBJECT,
Opcode.CONST_STRING,
Opcode.RETURN_OBJECT,
)
strings(
"Has attachmentRuns but drawableRequester is missing.",
)
}
@@ -36,6 +36,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
var expandButtonDownId = -1L
private set
@@ -239,6 +240,8 @@ val hideLayoutComponentsPatch = bytecodePatch(
SwitchPreference("revanced_hide_surveys"),
SwitchPreference("revanced_hide_ticket_shelf"),
SwitchPreference("revanced_hide_video_recommendation_labels"),
SwitchPreference("revanced_hide_view_count"),
SwitchPreference("revanced_hide_upload_time"),
SwitchPreference("revanced_hide_doodles"),
)
@@ -397,6 +400,39 @@ val hideLayoutComponentsPatch = bytecodePatch(
// endregion
// region hide view count
hideViewCountFingerprint.method.apply {
val startIndex = hideViewCountFingerprint.patternMatch!!.startIndex
var returnStringRegister = getInstruction<OneRegisterInstruction>(startIndex).registerA
// Find the instruction where the text dimension is retrieved.
val applyDimensionIndex = indexOfFirstInstructionReversedOrThrow {
val reference = getReference<MethodReference>()
opcode == Opcode.INVOKE_STATIC &&
reference?.definingClass == "Landroid/util/TypedValue;" &&
reference.returnType == "F" &&
reference.name == "applyDimension" &&
reference.parameterTypes == listOf("I", "F", "Landroid/util/DisplayMetrics;")
}
// A float value is passed which is used to determine subtitle text size.
val floatDimensionRegister = getInstruction<OneRegisterInstruction>(
applyDimensionIndex + 1
).registerA
addInstructions(
applyDimensionIndex - 1,
"""
invoke-static { v$returnStringRegister, v$floatDimensionRegister }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->modifyFeedSubtitleSpan(Landroid/text/SpannableString;F)Landroid/text/SpannableString;
move-result-object v$returnStringRegister
"""
)
}
// endregion
// region hide filter bar
/**
@@ -450,7 +450,6 @@ If a Doodle is currently showing in your region and this hide setting is on, the
<string name="revanced_hide_comments_thanks_button_title">Hide Thanks button</string>
<string name="revanced_hide_comments_thanks_button_summary_on">Thanks button is hidden</string>
<string name="revanced_hide_comments_thanks_button_summary_off">Thanks button is shown</string>
<string name="revanced_custom_filter_screen_title">Custom filter</string>
<string name="revanced_custom_filter_screen_summary">Hide components using custom filters</string>
<string name="revanced_custom_filter_title">Enable custom filter</string>
@@ -460,7 +459,20 @@ If a Doodle is currently showing in your region and this hide setting is on, the
<!-- 'Component path builder strings' is the technical name for identifying the Litho UI layout items to hide. This is an advanced feature and most users will never use this. -->
<string name="revanced_custom_filter_strings_summary">List of component path builder strings to filter separated by new line</string>
<string name="revanced_custom_filter_toast_invalid_syntax">Invalid custom filter: %s</string>
<string name="revanced_hide_view_count_title">Hide view count</string>
<string name="revanced_hide_view_count_summary_on">View count is hidden in feed and search results</string>
<string name="revanced_hide_view_count_summary_off">View count is shown in feed and search results</string>
<!-- Translations should lanaguge similar to revanced_hide_upload_time_user_dialog_message -->
<string name="revanced_hide_view_count_user_dialog_message">"Limitations:
• Shorts shelves, channel pages, and search results may still show view counts
• This feature does not work with automotive form factor"</string>
<string name="revanced_hide_upload_time_title">Hide upload time</string>
<string name="revanced_hide_upload_time_summary_on">Upload time is hidden in feed and search results</string>
<string name="revanced_hide_upload_time_summary_off">Upload time is shown in feed and search results</string>
<!-- Translations should lanaguge similar to revanced_hide_view_count_user_dialog_message -->
<string name="revanced_hide_upload_time_user_dialog_message">"Limitations:
• Shorts shelves, channel pages, and search results may still show upload times
• This feature does not work with automotive form factor"</string>
<string name="revanced_hide_keyword_content_screen_title">Hide keyword content</string>
<string name="revanced_hide_keyword_content_screen_summary">Hide feed and search videos using keyword filters</string>
<string name="revanced_hide_keyword_content_home_title">Hide Home videos by keywords</string>