From e925720c00113cedd8bf0e40ee3f5d7687fa61c9 Mon Sep 17 00:00:00 2001 From: JingMatrix Date: Tue, 21 May 2024 22:42:05 +0200 Subject: [PATCH] Ad hoc fix for method activateReaderMode There is no good solution to find the correct method --- .../java/org/matrix/chromext/hook/PageMenu.kt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 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 9558259..bbaeb33 100644 --- a/app/src/main/java/org/matrix/chromext/hook/PageMenu.kt +++ b/app/src/main/java/org/matrix/chromext/hook/PageMenu.kt @@ -34,13 +34,17 @@ object readerMode { findFieldOrNull(it::class.java) { type == PageMenuProxy.propertyModel } != null }!! - val activateReaderMode = - // There exist other methods with the same signatures - findMethod(readerModeManager::class.java) { - parameterTypes.size == 0 && returnType == Void.TYPE && name != "destroy" + readerModeManager::class + .java + .declaredMethods + .filter { + // There exist other methods with the same signatures, which might be tryShowingPrompt + it.parameterTypes.size == 0 && + !Modifier.isStatic(it.modifiers) && + it.returnType == Void.TYPE && + it.name != "destroy" } - - activateReaderMode.invoke(readerModeManager) + .forEach { it.invoke(readerModeManager) } } }