From dcbe55a4c1ab3f1a9efa7f269332393f4e292df1 Mon Sep 17 00:00:00 2001 From: JingMatrix Date: Tue, 12 Sep 2023 10:43:35 +0200 Subject: [PATCH] Support com.naver.whale --- app/src/main/AndroidManifest.xml | 1 + .../main/java/org/matrix/chromext/MainHook.kt | 19 +++++++------------ .../org/matrix/chromext/proxy/UserScript.kt | 5 +++-- app/src/main/res/values/arrays.xml | 1 + 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 598ada16..ae8dd7f3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -12,6 +12,7 @@ + diff --git a/app/src/main/java/org/matrix/chromext/MainHook.kt b/app/src/main/java/org/matrix/chromext/MainHook.kt index 8575ad5c..ca009adb 100644 --- a/app/src/main/java/org/matrix/chromext/MainHook.kt +++ b/app/src/main/java/org/matrix/chromext/MainHook.kt @@ -28,6 +28,7 @@ val supportedPackages = "com.microsoft.emmx.beta", "com.microsoft.emmx.canary", "com.microsoft.emmx.dev", + "com.naver.whale", "com.sec.android.app.sbrowser", "com.sec.android.app.sbrowser.beta", "com.vivaldi.browser", @@ -51,11 +52,8 @@ class MainHook : IXposedHookLoadPackage, IXposedHookZygoteInit { .declaredConstructors[1] .hookAfter { Chrome.init(it.args[0] as Context, lpparam.packageName) - if (Chrome.isSamsung) { - initHooks(UserScriptHook, ContextMenuHook) - } else { - initHooks(UserScriptHook, MenuHook) - } + runCatching { initHooks(UserScriptHook, MenuHook) } + .onFailure { initHooks(UserScriptHook, ContextMenuHook) } } } else { val ctx = AndroidAppHelper.currentApplication() @@ -91,13 +89,10 @@ class MainHook : IXposedHookLoadPackage, IXposedHookZygoteInit { private fun initHooks(vararg hook: BaseHook) { hook.forEach { - runCatching { - if (it.isInit) return@forEach - it.init() - it.isInit = true - Log.d("${it.javaClass.simpleName} hooked") - } - .onFailure { Log.ex(it) } + if (it.isInit) return@forEach + it.init() + it.isInit = true + Log.d("${it.javaClass.simpleName} hooked") } } } 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 d6c9b205..6fbb7041 100644 --- a/app/src/main/java/org/matrix/chromext/proxy/UserScript.kt +++ b/app/src/main/java/org/matrix/chromext/proxy/UserScript.kt @@ -5,6 +5,7 @@ import org.matrix.chromext.Chrome import org.matrix.chromext.script.ScriptDbManager import org.matrix.chromext.utils.Log import org.matrix.chromext.utils.findField +import org.matrix.chromext.utils.findFieldOrNull import org.matrix.chromext.utils.findMethod import org.matrix.chromext.utils.invokeMethod import org.matrix.chromext.utils.parseOrigin @@ -43,6 +44,7 @@ object UserScriptProxy { Chrome.load("org.chromium.chrome.browser.tab.TabImpl") } val mNativeAndroid = findField(tabImpl) { type == Long::class.java } + val mTab = findFieldOrNull(tabWebContentsDelegateAndroidImpl) { type == tabImpl } val mIsLoading = tabImpl.declaredFields .run { @@ -101,8 +103,7 @@ object UserScriptProxy { if (Chrome.isSamsung) { return delegate } else { - val mTab = tabWebContentsDelegateAndroidImpl.getDeclaredField("a") - return mTab.get(delegate) + return mTab?.get(delegate) } } diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index a5641ffb..148e1b78 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -12,6 +12,7 @@ com.microsoft.emmx.beta com.microsoft.emmx.canary com.microsoft.emmx.dev + com.naver.whale com.sec.android.app.sbrowser com.sec.android.app.sbrowser.beta com.vivaldi.browser