From 6b672a64ca360162ffa49ca66b783b4b3ab70c71 Mon Sep 17 00:00:00 2001 From: JingMatrix Date: Mon, 5 Feb 2024 23:33:14 +0100 Subject: [PATCH] Find AppMenuPropertiesDelegate and loadUrlParams The class AppMenuPropertiesDelegate is abstract after Chrome v123. Close #149 as completed. --- app/src/main/java/org/matrix/chromext/hook/PageMenu.kt | 7 +++++-- app/src/main/java/org/matrix/chromext/proxy/UserScript.kt | 7 +------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/matrix/chromext/hook/PageMenu.kt b/app/src/main/java/org/matrix/chromext/hook/PageMenu.kt index 45fa2ba..61d11aa 100644 --- a/app/src/main/java/org/matrix/chromext/hook/PageMenu.kt +++ b/app/src/main/java/org/matrix/chromext/hook/PageMenu.kt @@ -10,6 +10,7 @@ import android.view.View import android.widget.ImageButton import android.widget.LinearLayout import de.robv.android.xposed.XC_MethodHook.Unhook +import java.lang.reflect.Modifier import java.util.ArrayList import org.matrix.chromext.Chrome import org.matrix.chromext.Listener @@ -102,8 +103,10 @@ object PageMenuHook : BaseHook() { findMenuHook = findMethod(proxy.chromeTabbedActivity) { parameterTypes.size == 0 && - returnType.isInterface() && - returnType.declaredMethods.size >= 6 + returnType.declaredMethods.size >= 6 && + (returnType.declaredFields.size == 0 || + returnType.declaredFields.find { it.type == Context::class.java } != null) && + (returnType.isInterface() || Modifier.isAbstract(returnType.modifiers)) } // public AppMenuPropertiesDelegate createAppMenuPropertiesDelegate() .hookAfter { diff --git a/app/src/main/java/org/matrix/chromext/proxy/UserScript.kt b/app/src/main/java/org/matrix/chromext/proxy/UserScript.kt index 23de6d4..e582b75 100644 --- a/app/src/main/java/org/matrix/chromext/proxy/UserScript.kt +++ b/app/src/main/java/org/matrix/chromext/proxy/UserScript.kt @@ -62,12 +62,7 @@ object UserScriptProxy { val loadUrl = findMethod(tabImpl) { parameterTypes contentDeepEquals arrayOf(loadUrlParams) && - returnType == - if (Chrome.isSamsung) { - Void.TYPE - } else { - Int::class.java - } + (Chrome.isSamsung || returnType != Void.TYPE) } val kMaxURLChars = 2097152