feat(youtube): add hide-seek-message patch

This commit is contained in:
inotia00 2023-05-08 09:38:00 +09:00
parent f2e2a3ca80
commit c212a5e37c
5 changed files with 91 additions and 0 deletions

View File

@ -0,0 +1,16 @@
package app.revanced.patches.youtube.layout.fullscreen.seekmessage.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
import org.jf.dexlib2.Opcode
object SeekEduContainerFingerprint : MethodFingerprint(
returnType = "V",
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.easySeekEduContainerId
} == true
}
)

View File

@ -0,0 +1,64 @@
package app.revanced.patches.youtube.layout.fullscreen.seekmessage.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.instruction
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.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.layout.fullscreen.seekmessage.fingerprints.SeekEduContainerFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.FULLSCREEN
@Patch
@Name("hide-seek-message")
@Description("Hides the 'Slide left or right to seek' message container.")
@DependsOn(
[
SettingsPatch::class,
SharedResourceIdPatch::class
]
)
@YouTubeCompatibility
@Version("0.0.1")
class SeekMessagePatch : BytecodePatch(
listOf(
SeekEduContainerFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
SeekEduContainerFingerprint.result?.mutableMethod?.let {
it.addInstructions(
0, """
invoke-static {}, $FULLSCREEN->hideSeekMessage()Z
move-result v0
if-eqz v0, :default
return-void
""", listOf(ExternalLabel("default", it.instruction(0)))
)
}
/**
* Add settings
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: FULLSCREEN_SETTINGS",
"SETTINGS: HIDE_SEEK_MESSAGE"
)
)
SettingsPatch.updatePatchStatus("hide-seek-message")
return PatchResultSuccess()
}
}

View File

@ -31,6 +31,8 @@ class SharedResourceIdPatch : ResourcePatch {
var controlsLayoutStubResourceId: Long = -1
var dislikeButtonLabelId: Long = -1
var donationCompanionResourceId: Long = -1
var easySeekEduContainerId: Long = -1
var expandButtonId: Long = -1
var fabLabelId: Long = -1
var filterBarHeightLabelId: Long = -1
var floatyBarTopMarginLabelId: Long = -1
@ -77,6 +79,8 @@ class SharedResourceIdPatch : ResourcePatch {
controlsLayoutStubResourceId = find(ID, "controls_layout_stub")
dislikeButtonLabelId = find(ID, "dislike_button")
donationCompanionResourceId = find(LAYOUT, "donation_companion")
easySeekEduContainerId = find(ID, "easy_seek_edu_container")
expandButtonId = find(LAYOUT, "expand_button_down")
fabLabelId = find(ID, "fab")
filterBarHeightLabelId = find(DIMEN, "filter_bar_height")
floatyBarTopMarginLabelId = find(DIMEN, "floaty_bar_button_top_margin")

View File

@ -400,6 +400,9 @@ Please do not report any issues you encounter while using this feature."</string
<string name="revanced_hide_seekbar_summary_off">Seekbar is shown</string>
<string name="revanced_hide_seekbar_summary_on">Seekbar is hidden</string>
<string name="revanced_hide_seekbar_title">Hide seekbar</string>
<string name="revanced_hide_seek_message_summary_off">Seek message is shown</string>
<string name="revanced_hide_seek_message_summary_on">Seek message is hidden</string>
<string name="revanced_hide_seek_message_title">Hide seek message</string>
<string name="revanced_hide_separator_summary_off">Gray separators are shown</string>
<string name="revanced_hide_separator_summary_on">Gray separators are hidden</string>
<string name="revanced_hide_separator_title">Hide gray separator</string>

View File

@ -228,6 +228,9 @@
<!-- SETTINGS: HIDE_FILMSTRIP_OVERLAY
<SwitchPreference android:title="@string/revanced_hide_filmstrip_overlay_title" android:key="revanced_hide_filmstrip_overlay" android:defaultValue="false" android:summaryOn="@string/revanced_hide_filmstrip_overlay_summary_on" android:summaryOff="@string/revanced_hide_filmstrip_overlay_summary_off" />SETTINGS: HIDE_FILMSTRIP_OVERLAY -->
<!-- SETTINGS: HIDE_SEEK_MESSAGE
<SwitchPreference android:title="@string/revanced_hide_seek_message_title" android:key="revanced_hide_seek_message" android:defaultValue="false" android:summaryOn="@string/revanced_hide_seek_message_summary_on" android:summaryOff="@string/revanced_hide_seek_message_summary_off" />SETTINGS: HIDE_SEEK_MESSAGE -->
<!-- SETTINGS: HIDE_QUICK_ACTIONS
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_quick_actions_components_title" />
<SwitchPreference android:title="@string/revanced_hide_quick_actions_title" android:key="revanced_hide_quick_actions" android:defaultValue="false" android:summaryOn="@string/revanced_hide_quick_actions_summary_on" android:summaryOff="@string/revanced_hide_quick_actions_summary_off" />
@ -510,6 +513,7 @@
<Preference android:title="hide-autoplay-preview" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="hide-endscreen-overlay" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="hide-filmstrip-overlay" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="hide-seek-message" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="hide-quick-actions" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="disable-landscape-mode" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="disable-haptic-feedback" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>