From d2244a83f16f2c3328eb8890a70771203dcd149d Mon Sep 17 00:00:00 2001 From: klxiaoniu Date: Fri, 10 Nov 2023 12:47:56 +0800 Subject: [PATCH] fix: optimize OneTapTwentyLikes --- .../cc/ioctl/hook/profile/OneTapTwentyLikes.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/cc/ioctl/hook/profile/OneTapTwentyLikes.java b/app/src/main/java/cc/ioctl/hook/profile/OneTapTwentyLikes.java index c4acdc570f..a1636075b9 100644 --- a/app/src/main/java/cc/ioctl/hook/profile/OneTapTwentyLikes.java +++ b/app/src/main/java/cc/ioctl/hook/profile/OneTapTwentyLikes.java @@ -66,30 +66,32 @@ public boolean isAvailable() { @Override public boolean initOnce() throws ReflectiveOperationException { + Class CardProfile = Initiator.loadClass("com.tencent.mobileqq.data.CardProfile"); Method onClickVote = Reflex.findSingleMethod(Initiator._VoteHelper(), null, false, - Initiator.loadClass("com.tencent.mobileqq.data.CardProfile"), ImageView.class); + CardProfile, ImageView.class); for (Method m : Initiator.loadClass("com.tencent.mobileqq.activity.VisitorsActivity").getDeclaredMethods()) { if (m.getName().equals("onClick")) { HookUtils.hookBeforeIfEnabled(this, m, param -> { View view = (View) param.args[0]; Object profile = view.getTag(); + if (profile == null || !CardProfile.isInstance(profile)) return; Object voteHelper = getFirstByType(param.thisObject, Initiator._VoteHelper()); for (int i = 0; i < 20; i++) { - onClickVote.invoke(voteHelper, profile, (ImageView) view); + onClickVote.invoke(voteHelper, profile, view); } }); } } - Method onClickOnProfileCard = Reflex.findMethod(Initiator.loadClass("com.tencent.mobileqq.profilecard.base.component.AbsProfileHeaderComponent"), "handleVoteBtnClickForGuestProfile", + Method onClickOnProfileCard = Reflex.findMethod(Initiator.loadClass("com.tencent.mobileqq.profilecard.base.component.AbsProfileHeaderComponent"), + "handleVoteBtnClickForGuestProfile", Initiator.loadClass("com.tencent.mobileqq.data.Card")); - HookUtils.hookBeforeIfEnabled(this,onClickOnProfileCard,param -> { + HookUtils.hookBeforeIfEnabled(this, onClickOnProfileCard, param -> { for (int i = 0; i < 19; i++) { - XposedBridge.invokeOriginalMethod(param.method,param.thisObject,param.args); + XposedBridge.invokeOriginalMethod(param.method, param.thisObject, param.args); } }); - return true; } }