mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-13 05:37:40 +02:00
fix(YouTube - Change live ring click action): Clicking on the timestamp in the comments opens the channel
This commit is contained in:
@ -11,8 +11,17 @@ public final class OpenChannelOfLiveAvatarPatch {
|
|||||||
Settings.CHANGE_LIVE_RING_CLICK_ACTION.get();
|
Settings.CHANGE_LIVE_RING_CLICK_ACTION.get();
|
||||||
|
|
||||||
private static volatile String videoId = "";
|
private static volatile String videoId = "";
|
||||||
|
private static volatile boolean isCommentsPanelOpen = false;
|
||||||
private static volatile boolean liveChannelAvatarClicked = false;
|
private static volatile boolean liveChannelAvatarClicked = false;
|
||||||
|
|
||||||
|
public static void commentsPanelClosed() {
|
||||||
|
isCommentsPanelOpen = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void commentsPanelOpen() {
|
||||||
|
isCommentsPanelOpen = true;
|
||||||
|
}
|
||||||
|
|
||||||
public static void liveChannelAvatarClicked() {
|
public static void liveChannelAvatarClicked() {
|
||||||
liveChannelAvatarClicked = true;
|
liveChannelAvatarClicked = true;
|
||||||
}
|
}
|
||||||
@ -25,6 +34,9 @@ public final class OpenChannelOfLiveAvatarPatch {
|
|||||||
if (!liveChannelAvatarClicked) {
|
if (!liveChannelAvatarClicked) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (isCommentsPanelOpen) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
VideoDetailsRequest request = VideoDetailsRequest.getRequestForVideoId(videoId);
|
VideoDetailsRequest request = VideoDetailsRequest.getRequestForVideoId(videoId);
|
||||||
if (request != null) {
|
if (request != null) {
|
||||||
String channelId = request.getInfo();
|
String channelId = request.getInfo();
|
||||||
@ -45,10 +57,13 @@ public final class OpenChannelOfLiveAvatarPatch {
|
|||||||
if (!CHANGE_LIVE_RING_CLICK_ACTION) {
|
if (!CHANGE_LIVE_RING_CLICK_ACTION) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (newlyLoadedVideoId.isEmpty()) {
|
if (!liveChannelAvatarClicked) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!liveChannelAvatarClicked) {
|
if (isCommentsPanelOpen) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (newlyLoadedVideoId.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
videoId = newlyLoadedVideoId;
|
videoId = newlyLoadedVideoId;
|
||||||
|
@ -40,3 +40,39 @@ internal fun indexOfPlaybackStartDescriptorInstruction(method: Method) =
|
|||||||
reference?.returnType == "Lcom/google/android/libraries/youtube/player/model/PlaybackStartDescriptor;" &&
|
reference?.returnType == "Lcom/google/android/libraries/youtube/player/model/PlaybackStartDescriptor;" &&
|
||||||
reference.parameterTypes.isEmpty()
|
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
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ -6,6 +6,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWith
|
|||||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
import app.revanced.patcher.patch.bytecodePatch
|
import app.revanced.patcher.patch.bytecodePatch
|
||||||
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
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.extension.Constants.GENERAL_PATH
|
||||||
import app.revanced.patches.youtube.utils.patch.PatchList.CHANGE_LIVE_RING_CLICK_ACTION
|
import app.revanced.patches.youtube.utils.patch.PatchList.CHANGE_LIVE_RING_CLICK_ACTION
|
||||||
import app.revanced.patches.youtube.utils.resourceid.sharedResourceIdPatch
|
import app.revanced.patches.youtube.utils.resourceid.sharedResourceIdPatch
|
||||||
@ -37,6 +38,18 @@ val openChannelOfLiveAvatarPatch = bytecodePatch(
|
|||||||
|
|
||||||
execute {
|
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(
|
elementsImageFingerprint.methodOrThrow().addInstruction(
|
||||||
0,
|
0,
|
||||||
"invoke-static { }, $EXTENSION_CLASS_DESCRIPTOR->liveChannelAvatarClicked()V"
|
"invoke-static { }, $EXTENSION_CLASS_DESCRIPTOR->liveChannelAvatarClicked()V"
|
||||||
|
Reference in New Issue
Block a user