mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-28 04:40:19 +02:00
feat(YouTube/Hide suggested video overlay): add Auto play the next video
settings
This commit is contained in:
parent
867c08e1e8
commit
0daed9a909
@ -7,15 +7,21 @@ import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchException
|
||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patches.youtube.player.suggestedvideooverlay.fingerprints.CoreContainerBuilderFingerprint
|
||||
import app.revanced.patches.youtube.player.suggestedvideooverlay.fingerprints.TouchAreaOnClickListenerFingerprint
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.CoreContainer
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.exception
|
||||
import app.revanced.util.getWideLiteralInstructionIndex
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
|
||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
|
||||
@Patch(
|
||||
name = "Hide suggested video overlay",
|
||||
@ -58,7 +64,10 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
)
|
||||
@Suppress("unused")
|
||||
object SuggestedVideoOverlayPatch : BytecodePatch(
|
||||
setOf(CoreContainerBuilderFingerprint)
|
||||
setOf(
|
||||
CoreContainerBuilderFingerprint,
|
||||
TouchAreaOnClickListenerFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
@ -81,6 +90,22 @@ object SuggestedVideoOverlayPatch : BytecodePatch(
|
||||
}
|
||||
} ?: throw CoreContainerBuilderFingerprint.exception
|
||||
|
||||
TouchAreaOnClickListenerFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val insertMethod = it.mutableClass.methods.find { method -> method.parameters == listOf("Landroid/view/View${'$'}OnClickListener;") }
|
||||
|
||||
insertMethod?.apply {
|
||||
val setOnClickListenerIndex = getOnClickListenerIndex()
|
||||
val setOnClickListenerRegister = getInstruction<FiveRegisterInstruction>(setOnClickListenerIndex).registerC
|
||||
|
||||
addInstruction(
|
||||
setOnClickListenerIndex + 1,
|
||||
"invoke-static {v$setOnClickListenerRegister}, $PLAYER->hideSuggestedVideoOverlayAutoPlay(Landroid/view/View;)V"
|
||||
)
|
||||
} ?: throw PatchException("Failed to find setOnClickListener method")
|
||||
}
|
||||
} ?: throw TouchAreaOnClickListenerFingerprint.exception
|
||||
|
||||
/**
|
||||
* Add settings
|
||||
*/
|
||||
@ -95,4 +120,12 @@ object SuggestedVideoOverlayPatch : BytecodePatch(
|
||||
SettingsPatch.updatePatchStatus("Hide suggested video overlay")
|
||||
|
||||
}
|
||||
|
||||
private fun MutableMethod.getOnClickListenerIndex(): Int {
|
||||
return implementation!!.instructions.indexOfFirst { instruction ->
|
||||
if (instruction.opcode != Opcode.INVOKE_VIRTUAL) return@indexOfFirst false
|
||||
|
||||
return@indexOfFirst ((instruction as Instruction35c).reference as MethodReference).name == "setOnClickListener"
|
||||
}
|
||||
}
|
||||
}
|
@ -4,10 +4,16 @@ import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.CoreContainer
|
||||
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
object CoreContainerBuilderFingerprint : LiteralValueFingerprint(
|
||||
returnType = "Landroid/view/View;",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("Landroid/content/Context;"),
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_DIRECT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.CONST
|
||||
),
|
||||
literalSupplier = { CoreContainer }
|
||||
)
|
@ -0,0 +1,12 @@
|
||||
package app.revanced.patches.youtube.player.suggestedvideooverlay.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.TouchArea
|
||||
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
object TouchAreaOnClickListenerFingerprint : LiteralValueFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
||||
literalSupplier = { TouchArea }
|
||||
)
|
@ -80,6 +80,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
||||
var TabsBarTextTabView: Long = -1
|
||||
var ToolTipContentView: Long = -1
|
||||
var TotalTime: Long = -1
|
||||
var TouchArea: Long = -1
|
||||
var VideoQualityBottomSheet: Long = -1
|
||||
var VideoZoomIndicatorLayout: Long = -1
|
||||
var YoutubeControlsOverlay: Long = -1
|
||||
@ -164,6 +165,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
||||
TabsBarTextTabView = find(ID, "tabs_bar_text_tab_view")
|
||||
ToolTipContentView = find(LAYOUT, "tooltip_content_view")
|
||||
TotalTime = find(STRING, "total_time")
|
||||
TouchArea = find(ID, "touch_area")
|
||||
VideoQualityBottomSheet = find(LAYOUT, "video_quality_bottom_sheet_list_fragment_title")
|
||||
VideoZoomIndicatorLayout = find(ID, "video_zoom_indicator_layout")
|
||||
YoutubeControlsOverlay = find(ID, "youtube_controls_overlay")
|
||||
|
@ -646,9 +646,9 @@ Known issue: Official headers in search results will be hidden."</string>
|
||||
<string name="revanced_hide_suggested_actions_summary_off">Suggested actions shown.</string>
|
||||
<string name="revanced_hide_suggested_actions_summary_on">Suggested actions hidden.</string>
|
||||
<string name="revanced_hide_suggested_actions_title">Hide suggested actions</string>
|
||||
<string name="revanced_hide_suggested_video_overlay_summary">"Hides suggested video overlay to play next.
|
||||
|
||||
Known issue: Autoplay does not work."</string>
|
||||
<string name="revanced_hide_suggested_video_overlay_auto_play_summary">When you finished a video, another play automatically</string>
|
||||
<string name="revanced_hide_suggested_video_overlay_auto_play_title">Auto play the next video</string>
|
||||
<string name="revanced_hide_suggested_video_overlay_summary">Hides suggested video overlay to play next.</string>
|
||||
<string name="revanced_hide_suggested_video_overlay_title">Hide suggested video overlay</string>
|
||||
<string name="revanced_hide_suggestions_shelf_method_summary_off">"Identifies the suggestions shelf through the browse id.
|
||||
|
||||
|
@ -629,7 +629,8 @@
|
||||
<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_SUGGESTED_VIDEO_OVERLAY
|
||||
<SwitchPreference android:title="@string/revanced_hide_suggested_video_overlay_title" android:key="revanced_hide_suggested_video_overlay" android:defaultValue="false" android:summary="@string/revanced_hide_suggested_video_overlay_summary" />SETTINGS: HIDE_SUGGESTED_VIDEO_OVERLAY -->
|
||||
<SwitchPreference android:title="@string/revanced_hide_suggested_video_overlay_title" android:key="revanced_hide_suggested_video_overlay" android:defaultValue="false" android:summary="@string/revanced_hide_suggested_video_overlay_summary" />
|
||||
<SwitchPreference android:title="@string/revanced_hide_suggested_video_overlay_auto_play_title" android:key="revanced_hide_suggested_video_overlay_auto_play" android:defaultValue="false" android:summary="@string/revanced_hide_suggested_video_overlay_auto_play_summary" android:dependency="revanced_hide_suggested_video_overlay" />SETTINGS: HIDE_SUGGESTED_VIDEO_OVERLAY -->
|
||||
|
||||
<!-- SETTINGS: DISABLE_HAPTIC_FEEDBACK
|
||||
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_haptic_feedback_title" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user