Fix Nekogram X

This commit is contained in:
Shatyuka 2022-01-17 17:10:27 +08:00
parent 37690d8f3f
commit 74ab6ae411
2 changed files with 12 additions and 4 deletions

View file

@ -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

View file

@ -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);
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) {
}
}