mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 21:27:43 +02:00
feat(youtube/overlay-buttons): now you can disable autoplay by long-pressing the always repeat button
This commit is contained in:
@ -1,19 +0,0 @@
|
||||
package app.revanced.patches.youtube.overlaybutton.autorepeat.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object RepeatListenerFingerprint : MethodFingerprint(
|
||||
returnType = "Z",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_VIRTUAL_RANGE,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.CHECK_CAST,
|
||||
Opcode.CONST_WIDE_32
|
||||
),
|
||||
strings = listOf("ppoobsa")
|
||||
)
|
@ -5,10 +5,10 @@ import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.data.toMethodWalker
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
@ -16,15 +16,14 @@ import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.youtube.overlaybutton.autorepeat.fingerprints.AutoNavInformerFingerprint
|
||||
import app.revanced.patches.youtube.overlaybutton.autorepeat.fingerprints.RepeatListenerFingerprint
|
||||
import app.revanced.patches.youtube.overlaybutton.autorepeat.fingerprints.VideoEndFingerprint
|
||||
import app.revanced.patches.youtube.overlaybutton.autorepeat.fingerprints.VideoEndParentFingerprint
|
||||
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.utils.fingerprints.PlayerPatchFingerprint
|
||||
import app.revanced.util.integrations.Constants.INTEGRATIONS_PATH
|
||||
import app.revanced.util.integrations.Constants.UTILS_PATH
|
||||
import app.revanced.util.integrations.Constants.VIDEO_PATH
|
||||
import org.jf.dexlib2.builder.instruction.BuilderInstruction35c
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||
|
||||
@Name("always-repeat")
|
||||
@YouTubeCompatibility
|
||||
@ -32,7 +31,7 @@ import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||
class AutoRepeatPatch : BytecodePatch(
|
||||
listOf(
|
||||
AutoNavInformerFingerprint,
|
||||
RepeatListenerFingerprint,
|
||||
PlayerPatchFingerprint,
|
||||
VideoEndParentFingerprint
|
||||
)
|
||||
) {
|
||||
@ -42,6 +41,7 @@ class AutoRepeatPatch : BytecodePatch(
|
||||
it.mutableMethod.apply {
|
||||
addInstructionsWithLabels(
|
||||
0, """
|
||||
invoke-static {}, $UTILS_PATH/AlwaysRepeatPatch;->shouldRepeatAndPause()V
|
||||
invoke-static {}, $VIDEO_PATH/VideoInformation;->shouldAutoRepeat()Z
|
||||
move-result v0
|
||||
if-eqz v0, :notrepeat
|
||||
@ -52,28 +52,12 @@ class AutoRepeatPatch : BytecodePatch(
|
||||
} ?: return VideoEndFingerprint.toErrorResult()
|
||||
} ?: return VideoEndParentFingerprint.toErrorResult()
|
||||
|
||||
RepeatListenerFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = it.scanResult.patternScanResult!!.startIndex - 1
|
||||
val endIndex = it.scanResult.patternScanResult!!.endIndex
|
||||
|
||||
val registerC = getInstruction<BuilderInstruction35c>(targetIndex).registerC
|
||||
val registerD = getInstruction<BuilderInstruction35c>(targetIndex).registerD
|
||||
|
||||
val dummyRegister = getInstruction<OneRegisterInstruction>(endIndex).registerA
|
||||
val targetReference = getInstruction<ReferenceInstruction>(targetIndex).reference
|
||||
|
||||
addInstructionsWithLabels(
|
||||
targetIndex + 1, """
|
||||
invoke-static {}, $UTILS_PATH/AlwaysRepeatPatch;->shouldAlwaysRepeat()Z
|
||||
move-result v$dummyRegister
|
||||
if-nez v$dummyRegister, :bypass
|
||||
invoke-virtual {v$registerC, v$registerD}, $targetReference
|
||||
""", ExternalLabel("bypass", getInstruction(targetIndex + 1))
|
||||
)
|
||||
removeInstruction(targetIndex)
|
||||
}
|
||||
} ?: return RepeatListenerFingerprint.toErrorResult()
|
||||
PlayerPatchFingerprint.result?.mutableMethod?.addInstruction(
|
||||
0,
|
||||
"invoke-static {p0}, " +
|
||||
"$INTEGRATIONS_PATH/utils/ResourceHelper;->" +
|
||||
"setPlayPauseButton(Landroid/view/View;)V"
|
||||
) ?: return PlayerPatchFingerprint.toErrorResult()
|
||||
|
||||
AutoNavInformerFingerprint.result?.let {
|
||||
with(
|
||||
|
@ -13,6 +13,7 @@ import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.youtube.overlaybutton.autorepeat.patch.AutoRepeatPatch
|
||||
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.utils.overridespeed.patch.OverrideSpeedHookPatch
|
||||
import app.revanced.patches.youtube.utils.playerbutton.patch.PlayerButtonHookPatch
|
||||
import app.revanced.patches.youtube.utils.playercontrols.patch.PlayerControlsPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
|
||||
@ -30,6 +31,7 @@ import org.w3c.dom.Element
|
||||
[
|
||||
AutoRepeatPatch::class,
|
||||
OverrideSpeedHookPatch::class,
|
||||
PlayerButtonHookPatch::class,
|
||||
PlayerControlsPatch::class,
|
||||
SettingsPatch::class,
|
||||
SharedResourceIdPatch::class,
|
||||
|
@ -11,8 +11,8 @@ 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.patches.youtube.player.playerbuttonbg.fingerprints.HidePlayerButtonFingerprint
|
||||
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.utils.fingerprints.PlayerPatchFingerprint
|
||||
import app.revanced.patches.youtube.utils.playerbutton.patch.PlayerButtonHookPatch
|
||||
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.util.integrations.Constants.INTEGRATIONS_PATH
|
||||
@ -29,16 +29,16 @@ import app.revanced.util.integrations.Constants.INTEGRATIONS_PATH
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class HidePlayerButtonBackgroundPatch : BytecodePatch(
|
||||
listOf(HidePlayerButtonFingerprint)
|
||||
listOf(PlayerPatchFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
|
||||
HidePlayerButtonFingerprint.result?.mutableMethod?.addInstruction(
|
||||
PlayerPatchFingerprint.result?.mutableMethod?.addInstruction(
|
||||
0,
|
||||
"invoke-static {p0}, " +
|
||||
"$INTEGRATIONS_PATH/utils/ResourceHelper;->" +
|
||||
"hidePlayerButtonBackground(Landroid/view/View;)V"
|
||||
) ?: return HidePlayerButtonFingerprint.toErrorResult()
|
||||
) ?: return PlayerPatchFingerprint.toErrorResult()
|
||||
|
||||
/**
|
||||
* Add settings
|
||||
|
@ -1,7 +1,7 @@
|
||||
package app.revanced.patches.youtube.player.playerbuttonbg.fingerprints
|
||||
package app.revanced.patches.youtube.utils.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
|
||||
object HidePlayerButtonFingerprint : MethodFingerprint(
|
||||
object PlayerPatchFingerprint : MethodFingerprint(
|
||||
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("PlayerPatch;") && methodDef.name == "hidePlayerButton" }
|
||||
)
|
Reference in New Issue
Block a user