This commit is contained in:
inotia00
2023-01-10 04:30:54 +09:00
parent 1b83a30a56
commit 7db88c2dc8
77 changed files with 807 additions and 663 deletions

View File

@ -4,7 +4,7 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object LayoutConstructorFingerprint : MethodFingerprint(
strings = listOf("1.0x"),
customFingerprint = { methodDef ->
methodDef.definingClass.endsWith("YouTubeControlsOverlay;")
customFingerprint = {
it.definingClass.endsWith("YouTubeControlsOverlay;")
}
)

View File

@ -11,6 +11,7 @@ import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.youtube.layout.player.autoplaybutton.bytecode.fingerprints.LayoutConstructorFingerprint
import app.revanced.shared.annotation.YouTubeCompatibility
import app.revanced.shared.extensions.toErrorResult
import app.revanced.shared.patches.mapping.ResourceMappingPatch
import app.revanced.shared.util.integrations.Constants.PLAYER_LAYOUT
import org.jf.dexlib2.iface.instruction.Instruction
@ -28,31 +29,33 @@ class HideAutoplayButtonBytecodePatch : BytecodePatch(
)
) {
override fun execute(context: BytecodeContext): PatchResult {
val layoutGenMethodResult = LayoutConstructorFingerprint.result!!
val layoutGenMethod = layoutGenMethodResult.mutableMethod
val layoutGenMethodInstructions = layoutGenMethod.implementation!!.instructions
// resolve the offsets such as ...
val autoNavPreviewStubId = ResourceMappingPatch.resourceMappings.single {
it.name == "autonav_preview_stub"
}.id
// where to insert the branch instructions and ...
val insertIndex = layoutGenMethodInstructions.indexOfFirst {
(it as? WideLiteralInstruction)?.wideLiteral == autoNavPreviewStubId
}
// where to branch away
val branchIndex = layoutGenMethodInstructions.subList(insertIndex + 1, layoutGenMethodInstructions.size - 1).indexOfFirst {
((it as? ReferenceInstruction)?.reference as? MethodReference)?.name == "addOnLayoutChangeListener"
} + 2
val jumpInstruction = layoutGenMethodInstructions[insertIndex + branchIndex] as Instruction
layoutGenMethod.addInstructions(
insertIndex, """
invoke-static {}, $PLAYER_LAYOUT->hideAutoPlayButton()Z
move-result v15
if-nez v15, :hidden
""", listOf(ExternalLabel("hidden", jumpInstruction))
)
LayoutConstructorFingerprint.result?.mutableMethod?.let { method ->
with (method.implementation!!.instructions) {
// where to insert the branch instructions and ...
val insertIndex = this.indexOfFirst {
(it as? WideLiteralInstruction)?.wideLiteral == autoNavPreviewStubId
}
// where to branch away
val branchIndex = this.subList(insertIndex + 1, this.size - 1).indexOfFirst {
((it as? ReferenceInstruction)?.reference as? MethodReference)?.name == "addOnLayoutChangeListener"
} + 2
val jumpInstruction = this[insertIndex + branchIndex] as Instruction
method.addInstructions(
insertIndex, """
invoke-static {}, $PLAYER_LAYOUT->hideAutoPlayButton()Z
move-result v15
if-nez v15, :hidden
""", listOf(ExternalLabel("hidden", jumpInstruction))
)
}
} ?: return LayoutConstructorFingerprint.toErrorResult()
return PatchResultSuccess()
}

View File

@ -8,6 +8,7 @@ import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.shared.annotation.YouTubeCompatibility
import app.revanced.shared.extensions.toErrorResult
import app.revanced.shared.fingerprints.SubtitleButtonControllerFingerprint
import app.revanced.shared.util.integrations.Constants.PLAYER_LAYOUT
import org.jf.dexlib2.Opcode
@ -15,24 +16,27 @@ import org.jf.dexlib2.Opcode
@Name("hide-captions-button-bytecode-patch")
@YouTubeCompatibility
@Version("0.0.1")
class HideCaptionsButtonBytecodePatch : BytecodePatch(listOf(
SubtitleButtonControllerFingerprint,
)) {
class HideCaptionsButtonBytecodePatch : BytecodePatch(
listOf(
SubtitleButtonControllerFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
val subtitleButtonControllerMethod = SubtitleButtonControllerFingerprint.result!!.mutableMethod
val subtitleButtonControllerMethodInstructions = subtitleButtonControllerMethod.implementation!!.instructions
SubtitleButtonControllerFingerprint.result?.mutableMethod?.let {
with (it.implementation!!.instructions) {
for ((index, instruction) in this.withIndex()) {
if (instruction.opcode != Opcode.IGET_BOOLEAN) continue
for ((index, instruction) in subtitleButtonControllerMethodInstructions.withIndex()) {
if (instruction.opcode != Opcode.IGET_BOOLEAN) continue
it.addInstruction(
index + 1,
"invoke-static {v0}, $PLAYER_LAYOUT->hideCaptionsButton(Landroid/widget/ImageView;)V"
)
subtitleButtonControllerMethod.addInstruction(
index + 1,
"invoke-static {v0}, $PLAYER_LAYOUT->hideCaptionsButton(Landroid/widget/ImageView;)V"
)
break
}
break
}
}
} ?: return SubtitleButtonControllerFingerprint.toErrorResult()
return PatchResultSuccess()
}

View File

@ -11,7 +11,7 @@ import org.jf.dexlib2.AccessFlags
@YouTubeCompatibility
@Version("0.0.1")
object InfocardsIncognitoFingerprint : MethodFingerprint(
"Ljava/lang/Boolean;",
AccessFlags.PUBLIC or AccessFlags.FINAL,
returnType = "Ljava/lang/Boolean;",
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
strings = listOf("vibrator")
)

View File

@ -11,7 +11,7 @@ import org.jf.dexlib2.AccessFlags
@YouTubeCompatibility
@Version("0.0.1")
object InfocardsIncognitoParentFingerprint : MethodFingerprint(
"Ljava/lang/String;",
AccessFlags.PUBLIC or AccessFlags.FINAL,
returnType = "Ljava/lang/String;",
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
strings = listOf("player_overlay_info_card_teaser"),
)

View File

@ -11,6 +11,7 @@ import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patches.youtube.layout.player.infocards.bytecode.fingerprints.InfocardsIncognitoFingerprint
import app.revanced.patches.youtube.layout.player.infocards.bytecode.fingerprints.InfocardsIncognitoParentFingerprint
import app.revanced.shared.annotation.YouTubeCompatibility
import app.revanced.shared.extensions.toErrorResult
import app.revanced.shared.util.integrations.Constants.PLAYER_LAYOUT
@Name("hide-info-cards-bytecode-patch")
@ -20,16 +21,17 @@ class HideInfoCardsBytecodePatch : BytecodePatch(
listOf(InfocardsIncognitoParentFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
with(InfocardsIncognitoFingerprint.also {
it.resolve(context, InfocardsIncognitoParentFingerprint.result!!.classDef)
}.result!!.mutableMethod) {
addInstructions(
InfocardsIncognitoParentFingerprint.result?.classDef?.let { classDef ->
InfocardsIncognitoFingerprint.also {
it.resolve(context, classDef)
}.result?.mutableMethod?.
addInstructions(
1, """
invoke-static {v0}, $PLAYER_LAYOUT->hideInfoCard(Z)Z
move-result v0
"""
)
}
"""
) ?: return InfocardsIncognitoFingerprint.toErrorResult()
} ?: return InfocardsIncognitoParentFingerprint.toErrorResult()
return PatchResultSuccess()
}