Skip to content

Commit

Permalink
Support com.naver.whale
Browse files Browse the repository at this point in the history
  • Loading branch information
JingMatrix committed Sep 12, 2023
1 parent 08f4126 commit dcbe55a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<package android:name="com.microsoft.emmx.beta"/>
<package android:name="com.microsoft.emmx.canary"/>
<package android:name="com.microsoft.emmx.dev"/>
<package android:name="com.naver.whale"/>
<package android:name="com.sec.android.app.sbrowser"/>
<package android:name="com.sec.android.app.sbrowser.beta"/>
<package android:name="com.vivaldi.browser"/>
Expand Down
19 changes: 7 additions & 12 deletions app/src/main/java/org/matrix/chromext/MainHook.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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()
Expand Down Expand Up @@ -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")
}
}
}
5 changes: 3 additions & 2 deletions app/src/main/java/org/matrix/chromext/proxy/UserScript.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
}

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<item>com.microsoft.emmx.beta</item>
<item>com.microsoft.emmx.canary</item>
<item>com.microsoft.emmx.dev</item>
<item>com.naver.whale</item>
<item>com.sec.android.app.sbrowser</item>
<item>com.sec.android.app.sbrowser.beta</item>
<item>com.vivaldi.browser</item>
Expand Down

0 comments on commit dcbe55a

Please sign in to comment.