Skip to content

Commit

Permalink
Fix Nekogram X
Browse files Browse the repository at this point in the history
  • Loading branch information
shatyuka committed Jan 17, 2022
1 parent 37690d8 commit 74ab6ae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Killergram

An Android Xposed module to remove sponsored messages of Telegram
An Android Xposed module to remove sponsored messages of Telegram.

Also allows you to copy or save messages when "Restrict saving content" is enabled. Forwarding messages is still not working due to server limitation.

### Support clients

Expand Down
12 changes: 9 additions & 3 deletions app/src/main/java/com/shatyuka/killergram/MainHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,15 @@ public class MainHook implements IXposedHookLoadPackage {
public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam lpparam) {
if (hookPackages.contains(lpparam.packageName)) {
try {
Class<?> messagesControllerClass = XposedHelpers.findClass("org.telegram.messenger.MessagesController", lpparam.classLoader);
XposedBridge.hookAllMethods(messagesControllerClass, "getSponsoredMessages", XC_MethodReplacement.returnConstant(null));
XposedBridge.hookAllMethods(messagesControllerClass, "isChatNoForwards", XC_MethodReplacement.returnConstant(false));
Class<?> messagesControllerClass = XposedHelpers.findClassIfExists("org.telegram.messenger.MessagesController", lpparam.classLoader);
if (messagesControllerClass != null) {
XposedBridge.hookAllMethods(messagesControllerClass, "getSponsoredMessages", XC_MethodReplacement.returnConstant(null));
XposedBridge.hookAllMethods(messagesControllerClass, "isChatNoForwards", XC_MethodReplacement.returnConstant(false));
}
Class<?> chatUIActivityClass = XposedHelpers.findClassIfExists("org.telegram.ui.ChatActivity", lpparam.classLoader);
if (chatUIActivityClass != null) {
XposedBridge.hookAllMethods(chatUIActivityClass, "addSponsoredMessages", XC_MethodReplacement.returnConstant(null));
}
} catch (Throwable ignored) {
}
}
Expand Down

0 comments on commit 74ab6ae

Please sign in to comment.