From fdc30bd43a156bbf472923870a553530bcba2a5b Mon Sep 17 00:00:00 2001 From: inotia00 Date: Sun, 5 Feb 2023 12:45:53 +0900 Subject: [PATCH] add `hide-tooltip-content` patch --- .../resourceid/patch/SharedResourceIdPatch.kt | 2 + .../TooltipContentViewFingerprint.kt | 20 ++++++++++ .../patch/TooltipContentViewBytecodePatch.kt | 34 +++++++++++++++++ .../resource/patch/TooltipContentViewPatch.kt | 38 +++++++++++++++++++ .../youtube/settings/xml/revanced_prefs.xml | 1 + 5 files changed, 95 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/youtube/misc/tooltip/bytecode/fingerprints/TooltipContentViewFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/youtube/misc/tooltip/bytecode/patch/TooltipContentViewBytecodePatch.kt create mode 100644 src/main/kotlin/app/revanced/patches/youtube/misc/tooltip/resource/patch/TooltipContentViewPatch.kt diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/resourceid/patch/SharedResourceIdPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/resourceid/patch/SharedResourceIdPatch.kt index e35489383..00440bbc8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/resourceid/patch/SharedResourceIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/resourceid/patch/SharedResourceIdPatch.kt @@ -35,6 +35,7 @@ class SharedResourcdIdPatch : ResourcePatch { var liveChatButtonId: Long = -1 var scrubbingLabelId: Long = -1 var timebarColorLabelId: Long = -1 + var tooltipLabelId: Long = -1 var videoqualityfragmentLabelId: Long = -1 } @@ -63,6 +64,7 @@ class SharedResourcdIdPatch : ResourcePatch { liveChatButtonId = findSharedResourceId("id", "live_chat_overlay_button") scrubbingLabelId = findSharedResourceId("dimen", "vertical_touch_offset_to_enter_fine_scrubbing") timebarColorLabelId = findSharedResourceId("color", "inline_time_bar_progress_color") + tooltipLabelId = findSharedResourceId("layout", "tooltip_content_view") videoqualityfragmentLabelId = findSharedResourceId("layout", "video_quality_bottom_sheet_list_fragment_title") return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/tooltip/bytecode/fingerprints/TooltipContentViewFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/tooltip/bytecode/fingerprints/TooltipContentViewFingerprint.kt new file mode 100644 index 000000000..d4c498c73 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/tooltip/bytecode/fingerprints/TooltipContentViewFingerprint.kt @@ -0,0 +1,20 @@ +package app.revanced.patches.youtube.misc.tooltip.bytecode.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch +import org.jf.dexlib2.iface.instruction.WideLiteralInstruction +import org.jf.dexlib2.AccessFlags +import org.jf.dexlib2.Opcode + +object TooltipContentViewFingerprint : MethodFingerprint( + returnType = "V", + access = AccessFlags.PUBLIC or AccessFlags.FINAL, + parameters = listOf("L"), + customFingerprint = { methodDef -> + methodDef.implementation?.instructions?.any { instruction -> + instruction.opcode.ordinal == Opcode.CONST.ordinal && + (instruction as? WideLiteralInstruction)?.wideLiteral == SharedResourcdIdPatch.tooltipLabelId + } == true + } +) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/tooltip/bytecode/patch/TooltipContentViewBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/tooltip/bytecode/patch/TooltipContentViewBytecodePatch.kt new file mode 100644 index 000000000..27b380ef0 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/tooltip/bytecode/patch/TooltipContentViewBytecodePatch.kt @@ -0,0 +1,34 @@ +package app.revanced.patches.youtube.misc.tooltip.bytecode.patch + +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch +import app.revanced.patches.youtube.misc.tooltip.bytecode.fingerprints.TooltipContentViewFingerprint +import app.revanced.shared.annotation.YouTubeCompatibility +import app.revanced.shared.extensions.toErrorResult + +@Name("hide-tooltip-content-bytecode-patch") +@DependsOn([SharedResourcdIdPatch::class]) +@YouTubeCompatibility +@Version("0.0.1") +class TooltipContentViewBytecodePatch : BytecodePatch( + listOf( + TooltipContentViewFingerprint + ) +) { + override fun execute(context: BytecodeContext): PatchResult { + + TooltipContentViewFingerprint.result?.mutableMethod?.addInstruction( + 0, + "return-void" + ) ?: return TooltipContentViewFingerprint.toErrorResult() + + return PatchResultSuccess() + } +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/tooltip/resource/patch/TooltipContentViewPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/tooltip/resource/patch/TooltipContentViewPatch.kt new file mode 100644 index 000000000..e93dc4a4e --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/tooltip/resource/patch/TooltipContentViewPatch.kt @@ -0,0 +1,38 @@ +package app.revanced.patches.youtube.misc.tooltip.resource.patch + +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.ResourceContext +import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch +import app.revanced.patches.youtube.misc.tooltip.bytecode.patch.TooltipContentViewBytecodePatch +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +import app.revanced.shared.annotation.YouTubeCompatibility +import app.revanced.shared.util.resources.ResourceHelper + +@Patch +@Name("hide-tooltip-content") +@Description("Hides the tooltip box that appears on first install.") +@DependsOn( + [ + TooltipContentViewBytecodePatch::class, + SettingsPatch::class + ] +) +@YouTubeCompatibility +@Version("0.0.1") +class MinimizedPlaybackPatch : ResourcePatch { + override fun execute(context: ResourceContext): PatchResult { + + ResourceHelper.patchSuccess( + context, + "hide-tooltip-content" + ) + + return PatchResultSuccess() + } +} \ No newline at end of file diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml index 37e93acb5..c99b55252 100644 --- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml +++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml @@ -431,6 +431,7 @@ +