Skip to content

Commit

Permalink
Support old versions of Samsung browsers
Browse files Browse the repository at this point in the history
An ad hoc fix for #169
  • Loading branch information
JingMatrix committed May 21, 2024
1 parent f070143 commit f056566
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/org/matrix/chromext/Chrome.kt
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ object Chrome {
}

fun updateTab(tab: Any?) {
if (tab != null) {
if (tab != null && tab != getTab()) {
mTab = WeakReference(tab)
if (Chrome.isSamsung) {
val context = findField(UserScriptProxy.tabImpl) { name == "mContext" }
Expand Down
10 changes: 9 additions & 1 deletion app/src/main/java/org/matrix/chromext/hook/UserScript.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.matrix.chromext.script.ScriptDbManager
import org.matrix.chromext.utils.Log
import org.matrix.chromext.utils.findField
import org.matrix.chromext.utils.findMethod
import org.matrix.chromext.utils.findMethodOrNull
import org.matrix.chromext.utils.hookAfter
import org.matrix.chromext.utils.hookBefore

Expand All @@ -30,7 +31,14 @@ object UserScriptHook : BaseHook() {
// .hookBefore { Chrome.dropTabModel(it.thisObject) }

if (Chrome.isSamsung) {
findMethod(proxy.tabWebContentsDelegateAndroidImpl) { name == "onDidFinishNavigation" }
findMethodOrNull(proxy.tabWebContentsDelegateAndroidImpl) { name == "onDidFinishNavigation" }
.let {
if (it == null)
findMethod(proxy.tabWebContentsDelegateAndroidImpl) {
name == "updateBrowserControlsState"
}
else it
}
.hookAfter { Chrome.updateTab(it.thisObject) }

runCatching {
Expand Down
Binary file added base.apk
Binary file not shown.

0 comments on commit f056566

Please sign in to comment.