Cleaner code, added hooks fixing adblock/forwarding on other clients, updated clients list
This commit is contained in:
parent
a0ec8f2cbb
commit
d7bd65e788
4 changed files with 93 additions and 34 deletions
|
@ -5,16 +5,14 @@ import java.util.List;
|
||||||
|
|
||||||
import de.robv.android.xposed.IXposedHookLoadPackage;
|
import de.robv.android.xposed.IXposedHookLoadPackage;
|
||||||
import de.robv.android.xposed.XC_MethodReplacement;
|
import de.robv.android.xposed.XC_MethodReplacement;
|
||||||
import de.robv.android.xposed.XposedBridge;
|
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
|
||||||
import de.robv.android.xposed.XposedHelpers;
|
|
||||||
import de.robv.android.xposed.callbacks.XC_LoadPackage;
|
|
||||||
|
|
||||||
public class MainHook implements IXposedHookLoadPackage {
|
public class MainHook implements IXposedHookLoadPackage {
|
||||||
|
|
||||||
public final static List<String> hookPackages = Arrays.asList(
|
public final static List<String> hookPackages = Arrays.asList(
|
||||||
"org.telegram.messenger",
|
"org.telegram.messenger",
|
||||||
"org.telegram.messenger.web",
|
"org.telegram.messenger.web",
|
||||||
"org.telegram.messenger.beta",
|
"org.telegram.messenger.beta",
|
||||||
"tw.nekomimi.nekogram",
|
|
||||||
"nekox.messenger",
|
"nekox.messenger",
|
||||||
"org.forkclient.messenger",
|
"org.forkclient.messenger",
|
||||||
"org.forkclient.messenger.beta",
|
"org.forkclient.messenger.beta",
|
||||||
|
@ -23,9 +21,9 @@ public class MainHook implements IXposedHookLoadPackage {
|
||||||
"org.telegram.mdgram",
|
"org.telegram.mdgram",
|
||||||
"org.telegram.mdgramyou",
|
"org.telegram.mdgramyou",
|
||||||
"org.telegram.BifToGram",
|
"org.telegram.BifToGram",
|
||||||
"it.owlgram.android",
|
|
||||||
"ua.itaysonlab.messenger",
|
"ua.itaysonlab.messenger",
|
||||||
"org.nift4.catox",
|
"org.nift4.catox",
|
||||||
|
"top.qwq2333.nullgram",
|
||||||
"com.cool2645.nekolite",
|
"com.cool2645.nekolite",
|
||||||
"me.ninjagram.messenger",
|
"me.ninjagram.messenger",
|
||||||
"org.ninjagram.messenger",
|
"org.ninjagram.messenger",
|
||||||
|
@ -37,36 +35,38 @@ public class MainHook implements IXposedHookLoadPackage {
|
||||||
);
|
);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam lpparam) {
|
public void handleLoadPackage(final LoadPackageParam lpparam) {
|
||||||
if (hookPackages.contains(lpparam.packageName)) {
|
|
||||||
try {
|
|
||||||
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 (!hookPackages.contains(lpparam.packageName)) return;
|
||||||
if (chatUIActivityClass != null) {
|
|
||||||
XposedBridge.hookAllMethods(chatUIActivityClass, "addSponsoredMessages", XC_MethodReplacement.returnConstant(null));
|
|
||||||
}
|
|
||||||
|
|
||||||
Class<?> SharedConfigClass = XposedHelpers.findClassIfExists("org.telegram.messenger.SharedConfig", lpparam.classLoader);
|
XposedClass messagesController = new XposedClass("org.telegram.messenger.MessagesController", lpparam.classLoader);
|
||||||
if (SharedConfigClass != null) {
|
messagesController.hookAllMethods("getSponsoredMessages", XC_MethodReplacement.returnConstant(null));
|
||||||
XposedBridge.hookAllMethods(SharedConfigClass, "getDevicePerformanceClass", XC_MethodReplacement.returnConstant(2));
|
messagesController.hookAllMethods("isChatNoForwards", XC_MethodReplacement.returnConstant(false));
|
||||||
}
|
|
||||||
|
|
||||||
Class<?> UserConfigClass = XposedHelpers.findClassIfExists("org.telegram.messenger.UserConfig", lpparam.classLoader);
|
XposedClass chatUIActivity = new XposedClass("org.telegram.ui.ChatActivity", lpparam.classLoader);
|
||||||
if (UserConfigClass != null) {
|
chatUIActivity.hookAllMethods("addSponsoredMessages", XC_MethodReplacement.returnConstant(null));
|
||||||
XposedBridge.hookAllMethods(UserConfigClass, "getMaxAccountCount", XC_MethodReplacement.returnConstant(999));
|
|
||||||
XposedBridge.hookAllMethods(UserConfigClass, "hasPremiumOnAccounts", XC_MethodReplacement.returnConstant(true));
|
|
||||||
}
|
|
||||||
|
|
||||||
Class<?> getSponsoredMessagesClass = XposedHelpers.findClassIfExists("org.telegram.tgnet.TLRPC$TL_channels_getSponsoredMessages", lpparam.classLoader);
|
XposedClass sponsoredMessages = new XposedClass("org.telegram.tgnet.TLRPC$messages_SponsoredMessages", lpparam.classLoader);
|
||||||
if (getSponsoredMessagesClass != null) {
|
sponsoredMessages.hookAllMethods("TLdeserialize", XC_MethodReplacement.returnConstant(null));
|
||||||
XposedBridge.hookAllMethods(getSponsoredMessagesClass, "a", XC_MethodReplacement.returnConstant(null));
|
|
||||||
}
|
XposedClass getSponsoredMessages = new XposedClass("org.telegram.tgnet.TLRPC$TL_channels_getSponsoredMessages", lpparam.classLoader);
|
||||||
} catch (Throwable ignored) { }
|
getSponsoredMessages.hookAllMethods("a", XC_MethodReplacement.returnConstant(null));
|
||||||
}
|
|
||||||
|
XposedClass chat = new XposedClass("org.telegram.tgnet.TLRPC$Chat", lpparam.classLoader);
|
||||||
|
//chat.hookAllConstructors(new NoForwardsHook(true));
|
||||||
|
chat.hookAllMethods("TLdeserialize", new NoForwardsHook(false));
|
||||||
|
|
||||||
|
/*
|
||||||
|
XposedClass message = new XposedClass("org.telegram.tgnet.TLRPC$Message", lpparam.classLoader);
|
||||||
|
//message.hookAllConstructors(new NoForwardsHook(true));
|
||||||
|
message.hookAllMethods("TLdeserialize", new NoForwardsHook(false));
|
||||||
|
*/
|
||||||
|
|
||||||
|
XposedClass sharedConfig = new XposedClass("org.telegram.messenger.SharedConfig", lpparam.classLoader);
|
||||||
|
sharedConfig.hookAllMethods("getDevicePerformanceClass", XC_MethodReplacement.returnConstant(2));
|
||||||
|
|
||||||
|
XposedClass userConfig = new XposedClass("org.telegram.messenger.UserConfig", lpparam.classLoader);
|
||||||
|
userConfig.hookAllMethods("getMaxAccountCount", XC_MethodReplacement.returnConstant(999));
|
||||||
|
userConfig.hookAllMethods("hasPremiumOnAccounts", XC_MethodReplacement.returnConstant(true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.shatyuka.killergram;
|
||||||
|
|
||||||
|
import de.robv.android.xposed.XC_MethodHook;
|
||||||
|
import de.robv.android.xposed.XposedBridge;
|
||||||
|
import de.robv.android.xposed.XposedHelpers;
|
||||||
|
|
||||||
|
public class NoForwardsHook extends XC_MethodHook {
|
||||||
|
|
||||||
|
boolean forConstructor;
|
||||||
|
|
||||||
|
public NoForwardsHook(boolean forConstructor) {
|
||||||
|
super();
|
||||||
|
this.forConstructor = forConstructor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void afterHookedMethod(MethodHookParam param) {
|
||||||
|
try {
|
||||||
|
Object obj = this.forConstructor ? param.thisObject : param.getResult();
|
||||||
|
XposedHelpers.setBooleanField(obj, "noforwards", false);
|
||||||
|
}
|
||||||
|
catch (Throwable t) {
|
||||||
|
XposedBridge.log(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
34
app/src/main/java/com/shatyuka/killergram/XposedClass.java
Normal file
34
app/src/main/java/com/shatyuka/killergram/XposedClass.java
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
package com.shatyuka.killergram;
|
||||||
|
|
||||||
|
import de.robv.android.xposed.XC_MethodHook;
|
||||||
|
import de.robv.android.xposed.XposedBridge;
|
||||||
|
import de.robv.android.xposed.XposedHelpers;
|
||||||
|
|
||||||
|
public class XposedClass {
|
||||||
|
|
||||||
|
private final Class<?> aClass;
|
||||||
|
|
||||||
|
public XposedClass(String className, ClassLoader loader) {
|
||||||
|
aClass = XposedHelpers.findClassIfExists(className, loader);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hookAllMethods(String methodName, XC_MethodHook callback) {
|
||||||
|
try {
|
||||||
|
if (aClass == null) return;
|
||||||
|
XposedBridge.hookAllMethods(aClass, methodName, callback);
|
||||||
|
}
|
||||||
|
catch (Throwable t) {
|
||||||
|
XposedBridge.log(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hookAllConstructors(XC_MethodHook callback) {
|
||||||
|
try {
|
||||||
|
if (aClass == null) return;
|
||||||
|
XposedBridge.hookAllConstructors(aClass, callback);
|
||||||
|
}
|
||||||
|
catch (Throwable t) {
|
||||||
|
XposedBridge.log(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,7 +4,6 @@
|
||||||
<item>org.telegram.messenger</item>
|
<item>org.telegram.messenger</item>
|
||||||
<item>org.telegram.messenger.web</item>
|
<item>org.telegram.messenger.web</item>
|
||||||
<item>org.telegram.messenger.beta</item>
|
<item>org.telegram.messenger.beta</item>
|
||||||
<item>tw.nekomimi.nekogram</item>
|
|
||||||
<item>nekox.messenger</item>
|
<item>nekox.messenger</item>
|
||||||
<item>org.forkclient.messenger</item>
|
<item>org.forkclient.messenger</item>
|
||||||
<item>org.forkclient.messenger.beta</item>
|
<item>org.forkclient.messenger.beta</item>
|
||||||
|
@ -13,9 +12,9 @@
|
||||||
<item>org.telegram.mdgram</item>
|
<item>org.telegram.mdgram</item>
|
||||||
<item>org.telegram.mdgramyou</item>
|
<item>org.telegram.mdgramyou</item>
|
||||||
<item>org.telegram.BifToGram</item>
|
<item>org.telegram.BifToGram</item>
|
||||||
<item>it.owlgram.android</item>
|
|
||||||
<item>ua.itaysonlab.messenger</item>
|
<item>ua.itaysonlab.messenger</item>
|
||||||
<item>org.nift4.catox</item>
|
<item>org.nift4.catox</item>
|
||||||
|
<item>top.qwq2333.nullgram</item>
|
||||||
<item>com.cool2645.nekolite</item>
|
<item>com.cool2645.nekolite</item>
|
||||||
<item>me.ninjagram.messenger</item>
|
<item>me.ninjagram.messenger</item>
|
||||||
<item>org.ninjagram.messenger</item>
|
<item>org.ninjagram.messenger</item>
|
||||||
|
|
Loading…
Add table
Reference in a new issue