From 05f2bf305548307663ea2d6f666a36b19dd01bca Mon Sep 17 00:00:00 2001 From: Shatyuka <958182453@qq.com> Date: Wed, 10 Nov 2021 14:47:40 +0800 Subject: [PATCH] Add more clients support --- .gitignore | 1 - app/.gitignore | 4 +++- app/build.gradle | 2 +- .../com/shatyuka/killergram/MainHook.java | 20 +++++++++++++++---- app/src/main/res/values/arrays.xml | 4 ++++ 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 6118307..10cfdbf 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ .gradle /local.properties /.idea -/.idea/assetWizardSettings.xml .DS_Store /build /captures diff --git a/app/.gitignore b/app/.gitignore index 42afabf..67aaf57 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -1 +1,3 @@ -/build \ No newline at end of file +/build +/release +/debug \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index a566d94..22e1413 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,7 +7,7 @@ android { defaultConfig { applicationId "com.shatyuka.killergram" - minSdk 23 + minSdk 16 targetSdk 31 versionCode 1 versionName "1.0" diff --git a/app/src/main/java/com/shatyuka/killergram/MainHook.java b/app/src/main/java/com/shatyuka/killergram/MainHook.java index 65a52cb..9732f15 100644 --- a/app/src/main/java/com/shatyuka/killergram/MainHook.java +++ b/app/src/main/java/com/shatyuka/killergram/MainHook.java @@ -1,5 +1,8 @@ package com.shatyuka.killergram; +import java.util.Arrays; +import java.util.List; + import de.robv.android.xposed.IXposedHookLoadPackage; import de.robv.android.xposed.XC_MethodReplacement; import de.robv.android.xposed.XposedBridge; @@ -7,12 +10,21 @@ import de.robv.android.xposed.callbacks.XC_LoadPackage; public class MainHook implements IXposedHookLoadPackage { + public final static List hookPackages = Arrays.asList( + "org.telegram.messenger", + "org.telegram.messenger.web", + "nekox.messenger", + "tw.nekomimi.nekogram", + "org.telegram.plus"); + @Override public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam lpparam) { - try { - Class chatUIActivityClass = XposedHelpers.findClass("org.telegram.ui.ChatActivity", lpparam.classLoader); - XposedBridge.hookAllMethods(chatUIActivityClass, "addSponsoredMessages", XC_MethodReplacement.returnConstant(null)); - } catch (Throwable ignored) { + if (hookPackages.contains(lpparam.packageName)) { + try { + Class chatUIActivityClass = XposedHelpers.findClass("org.telegram.ui.ChatActivity", lpparam.classLoader); + XposedBridge.hookAllMethods(chatUIActivityClass, "addSponsoredMessages", XC_MethodReplacement.returnConstant(null)); + } catch (Throwable ignored) { + } } } } diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 2e4cce4..2ab9496 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -2,5 +2,9 @@ org.telegram.messenger + org.telegram.messenger.web + nekox.messenger + tw.nekomimi.nekogram + org.telegram.plus