File tree 2 files changed +16
-3
lines changed
app/src/main/java/org/matrix/chromext
2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 1
1
package org.matrix.chromext.hook
2
2
3
3
import android.content.Context
4
+ import android.os.Bundle
4
5
import android.os.Handler
5
6
import android.util.DisplayMetrics
6
7
import android.view.Menu
@@ -104,6 +105,10 @@ object PageMenuHook : BaseHook() {
104
105
findMethod(proxy.chromeTabbedActivity) {
105
106
parameterTypes.size == 0 &&
106
107
returnType.declaredMethods.size >= 6 &&
108
+ (returnType.declaredMethods.find {
109
+ // Bundle getBundleForMenuItem(int itemId);
110
+ it.returnType == Bundle ::class .java && it.parameterTypes.size == 1
111
+ } != null ) &&
107
112
(returnType.declaredFields.size == 0 ||
108
113
returnType.declaredFields.find { it.type == Context ::class .java } != null ) &&
109
114
(returnType.isInterface() || Modifier .isAbstract(returnType.modifiers))
@@ -150,7 +155,8 @@ object PageMenuHook : BaseHook() {
150
155
findMethod(appMenuPropertiesDelegateImpl, true ) {
151
156
parameterTypes.size == 2 &&
152
157
parameterTypes.first() == Menu ::class .java &&
153
- returnType == Void .TYPE
158
+ returnType == Void .TYPE &&
159
+ ! Modifier .isStatic(modifiers)
154
160
}
155
161
// public void prepareMenu(Menu menu, AppMenuHandler handler)
156
162
.hookAfter inflate@{
Original file line number Diff line number Diff line change 1
1
package org.matrix.chromext.proxy
2
2
3
3
import android.net.Uri
4
+ import android.view.ContextThemeWrapper
4
5
import org.matrix.chromext.Chrome
5
6
import org.matrix.chromext.script.ScriptDbManager
6
7
import org.matrix.chromext.utils.Log
@@ -51,8 +52,14 @@ object UserScriptProxy {
51
52
val target = find { it.name == " mId" }
52
53
if (target == null ) {
53
54
val profile = Chrome .load(" org.chromium.chrome.browser.profiles.Profile" )
54
- val startIndex = indexOfFirst { it.type == gURL }
55
- val endIndex = indexOfFirst { it.type == profile }
55
+ val windowAndroid = Chrome .load(" org.chromium.ui.base.WindowAndroid" )
56
+ var startIndex = indexOfFirst { it.type == gURL }
57
+ if (startIndex == - 1 ) startIndex = 0
58
+ val endIndex = indexOfFirst {
59
+ it.type == profile ||
60
+ it.type == ContextThemeWrapper ::class .java ||
61
+ it.type == windowAndroid
62
+ }
56
63
slice(startIndex.. endIndex).findLast { it.type == Int ::class .java }!!
57
64
} else target
58
65
}
You can’t perform that action at this time.
0 commit comments