Skip to content

Commit

Permalink
Add more clients support
Browse files Browse the repository at this point in the history
  • Loading branch information
shatyuka committed Nov 10, 2021
1 parent 8a06e6c commit 05f2bf3
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
.gradle
/local.properties
/.idea
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
Expand Down
4 changes: 3 additions & 1 deletion app/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/build
/build
/release
/debug
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ android {

defaultConfig {
applicationId "com.shatyuka.killergram"
minSdk 23
minSdk 16
targetSdk 31
versionCode 1
versionName "1.0"
Expand Down
20 changes: 16 additions & 4 deletions app/src/main/java/com/shatyuka/killergram/MainHook.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
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;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;

public class MainHook implements IXposedHookLoadPackage {
public final static List<String> 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) {
}
}
}
}
4 changes: 4 additions & 0 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
<resources>
<string-array name="xposedscope">
<item>org.telegram.messenger</item>
<item>org.telegram.messenger.web</item>
<item>nekox.messenger</item>
<item>tw.nekomimi.nekogram</item>
<item>org.telegram.plus</item>
</string-array>
</resources>

0 comments on commit 05f2bf3

Please sign in to comment.