mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 21:27:43 +02:00
fix(YouTube/Disable force auto captions): patch doesn't work with Shorts https://github.com/inotia00/ReVanced_Extended/issues/2346
This commit is contained in:
@ -1,65 +0,0 @@
|
||||
package app.revanced.patches.shared.captions
|
||||
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
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.patch.BytecodePatch
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.shared.captions.fingerprints.SubtitleButtonControllerFingerprint
|
||||
import app.revanced.patches.shared.captions.fingerprints.SubtitleTrackFingerprint
|
||||
import app.revanced.patches.shared.fingerprints.StartVideoInformerFingerprint
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
abstract class BaseAutoCaptionsPatch(
|
||||
private val classDescriptor: String,
|
||||
private val captionsButtonStatus: Boolean
|
||||
) : BytecodePatch(
|
||||
setOf(
|
||||
StartVideoInformerFingerprint,
|
||||
SubtitleButtonControllerFingerprint,
|
||||
SubtitleTrackFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
SubtitleTrackFingerprint.resultOrThrow().mutableMethod.apply {
|
||||
if (captionsButtonStatus) {
|
||||
addInstructionsWithLabels(
|
||||
0, """
|
||||
invoke-static {}, $classDescriptor->disableAutoCaptions()Z
|
||||
move-result v0
|
||||
if-eqz v0, :disabled
|
||||
const/4 v0, 0x1
|
||||
return v0
|
||||
""", ExternalLabel("disabled", getInstruction(0))
|
||||
)
|
||||
} else {
|
||||
val index = implementation!!.instructions.lastIndex
|
||||
val register = getInstruction<OneRegisterInstruction>(index).registerA
|
||||
|
||||
addInstructions(
|
||||
index, """
|
||||
invoke-static {v$register}, $classDescriptor->disableAutoCaptions(Z)Z
|
||||
move-result v$register
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (!captionsButtonStatus) return
|
||||
|
||||
mapOf(
|
||||
StartVideoInformerFingerprint to 0,
|
||||
SubtitleButtonControllerFingerprint to 1
|
||||
).forEach { (fingerprint, enabled) ->
|
||||
fingerprint.resultOrThrow().mutableMethod.addInstructions(
|
||||
0, """
|
||||
const/4 v0, 0x$enabled
|
||||
invoke-static {v0}, $classDescriptor->setCaptionsButtonStatus(Z)V
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package app.revanced.patches.shared.captions.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
internal object SubtitleButtonControllerFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("Lcom/google/android/libraries/youtube/player/subtitles/model/SubtitleTrack;"),
|
||||
opcodes = listOf(
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.IF_NEZ,
|
||||
Opcode.RETURN_VOID,
|
||||
Opcode.IGET_BOOLEAN,
|
||||
Opcode.CONST_4,
|
||||
Opcode.IF_NEZ,
|
||||
Opcode.CONST,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.IGET_OBJECT,
|
||||
)
|
||||
)
|
@ -1,16 +0,0 @@
|
||||
package app.revanced.patches.shared.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
internal object StartVideoInformerFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_INTERFACE,
|
||||
Opcode.RETURN_VOID
|
||||
),
|
||||
strings = listOf("pc")
|
||||
)
|
@ -1,4 +1,4 @@
|
||||
package app.revanced.patches.shared.captions.fingerprints
|
||||
package app.revanced.patches.shared.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
Reference in New Issue
Block a user