fix(YouTube - Change live ring click action): Clicking on the timestamp in the comments opens the channel

This commit is contained in:
inotia00
2025-01-20 02:31:09 +09:00
parent c7c4d225e8
commit b27aae8501
3 changed files with 66 additions and 2 deletions

View File

@ -40,3 +40,39 @@ internal fun indexOfPlaybackStartDescriptorInstruction(method: Method) =
reference?.returnType == "Lcom/google/android/libraries/youtube/player/model/PlaybackStartDescriptor;" &&
reference.parameterTypes.isEmpty()
}
internal val engagementPanelCommentsClosedFingerprint = legacyFingerprint(
name = "engagementPanelCommentsClosedFingerprint",
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = emptyList(),
opcodes = listOf(
Opcode.IGET_OBJECT,
Opcode.INVOKE_STATIC,
Opcode.IGET_OBJECT,
Opcode.INVOKE_DIRECT,
),
customFingerprint = { method, _ ->
method.indexOfFirstInstruction {
opcode == Opcode.INVOKE_INTERFACE &&
getReference<MethodReference>()?.name == "hasNext"
} >= 0
}
)
internal val engagementPanelCommentsOpenFingerprint = legacyFingerprint(
name = "engagementPanelCommentsOpenFingerprint",
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("L"),
opcodes = listOf(
Opcode.IGET_OBJECT,
Opcode.IF_NE,
Opcode.RETURN_VOID,
Opcode.IPUT_OBJECT,
Opcode.RETURN_VOID,
),
customFingerprint = { method, _ ->
method.implementation!!.instructions.count() == 5
}
)

View File

@ -6,6 +6,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWith
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.youtube.utils.engagementPanelTitleParentFingerprint
import app.revanced.patches.youtube.utils.extension.Constants.GENERAL_PATH
import app.revanced.patches.youtube.utils.patch.PatchList.CHANGE_LIVE_RING_CLICK_ACTION
import app.revanced.patches.youtube.utils.resourceid.sharedResourceIdPatch
@ -37,6 +38,18 @@ val openChannelOfLiveAvatarPatch = bytecodePatch(
execute {
mapOf(
engagementPanelCommentsClosedFingerprint to "commentsPanelClosed",
engagementPanelCommentsOpenFingerprint to "commentsPanelOpen",
).forEach { (fingerprint, methodName) ->
fingerprint
.methodOrThrow(engagementPanelTitleParentFingerprint)
.addInstruction(
0,
"invoke-static {}, $EXTENSION_CLASS_DESCRIPTOR->$methodName()V"
)
}
elementsImageFingerprint.methodOrThrow().addInstruction(
0,
"invoke-static { }, $EXTENSION_CLASS_DESCRIPTOR->liveChannelAvatarClicked()V"