Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added clients + bugfix, cleaned code, updated readme #52

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Generated APK AAB (Upload - Create Artifact To Github Action)

env:
# The name of the main module repository
main_project_module: app

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

# Set Current Date As Env Variable
- name: Set current date as env variable
run: echo "date_today=$(date +'%Y-%m-%d')" >> $GITHUB_ENV

# Set Repository Name As Env Variable
- name: Set repository name as env variable
run: echo "repository_name=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV

- name: Set Up JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '17'
cache: 'gradle'

- name: Change wrapper permissions
run: chmod +x ./gradlew

# Run Tests Build
- name: Run gradle tests
run: ./gradlew test

# Run Build Project
- name: Build gradle project
run: ./gradlew build

# Create APK Debug
- name: Build apk debug project (APK) - ${{ env.main_project_module }} module
run: ./gradlew assembleDebug

# Create APK Release
- name: Build apk release project (APK) - ${{ env.main_project_module }} module
run: ./gradlew assemble

# Create Bundle AAB Release
# Noted for main module build [main_project_module]:bundleRelease
- name: Build app bundle release (AAB) - ${{ env.main_project_module }} module
run: ./gradlew ${{ env.main_project_module }}:bundleRelease

# Upload Artifact Build
# Noted For Output [main_project_module]/build/outputs/apk/debug/
- name: Upload APK Debug - ${{ env.repository_name }}
uses: actions/upload-artifact@v3
with:
name: ${{ env.date_today }} - ${{ env.repository_name }} - APK(s) debug generated
path: ${{ env.main_project_module }}/build/outputs/apk/debug/

# Noted For Output [main_project_module]/build/outputs/apk/release/
- name: Upload APK Release - ${{ env.repository_name }}
uses: actions/upload-artifact@v3
with:
name: ${{ env.date_today }} - ${{ env.repository_name }} - APK(s) release generated
path: ${{ env.main_project_module }}/build/outputs/apk/release/

# Noted For Output [main_project_module]/build/outputs/bundle/release/
- name: Upload AAB (App Bundle) Release - ${{ env.repository_name }}
uses: actions/upload-artifact@v3
with:
name: ${{ env.date_today }} - ${{ env.repository_name }} - App bundle(s) AAB release generated
path: ${{ env.main_project_module }}/build/outputs/bundle/release/
61 changes: 41 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,48 @@
# Killergram
Xposed module for removing sponsored messages in 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.

Also allows you to copy or save messages when "Restrict saving content" is enabled. Forwarding messages is still not working due to server limitation.
## Supported clients
These clients were successfully tested with Killergram enabled.

### Support clients
| Name | Package | Notes |
|:--------------:|:--------------------------------|:-------------|
| Official | `org.telegram.messenger` | |
| Official | `org.telegram.messenger.web` | |
| Official | `org.telegram.messenger.beta` | |
| Nekogram X | `nekox.messenger` | |
| Forkgram | `org.forkclient.messenger` | |
| Forkgram | `org.forkclient.messenger.beta` | |
| exteraGram | `com.exteragram.messenger` | |
| exteraGram | `com.exteragram.messenger.beta` | |
| MDGram | `org.telegram.mdgram` | Only AdBlock |
| MDGram | `org.telegram.mdgramyou` | Only AdBlock |
| BGram | `org.telegram.BifToGram` | |
| Catogram | `ua.itaysonlab.messenger` | |
| Catogram X | `org.nift4.catox` | |
| Nullgram | `top.qwq2333.nullgram` | |
| Nanogram | `com.cool2645.nekolite` | |
| Ninjagram | `me.ninjagram.messenger` | |
| Ninjagram | `org.ninjagram.messenger` | |
| Graph | `ir.ilmili.telegraph` | |
| Plus Messenger | `org.telegram.plus` | |
| iMe Messenger | `com.iMe.android` | |
| aka | `org.aka.messenger` | |
| TurboTel Pro | `ellipi.messenger` | |
| MercuryGram | `belloworld.mercurygram` | |

- **Official** org.telegram.messenger
- **Official** org.telegram.messenger.web
- **Official** org.telegram.messenger.beta
- **NekoX** nekox.messenger
- **Nanogram** com.cool2645.nekolite
- **Plus Messenger** org.telegram.plus
- **iMe Messenger** com.iMe.android
- **BGram** org.telegram.BifToGram
- **Catogram** ua.itaysonlab.messenger
- **Forkgram** org.forkclient.messenger
- **Forkgram** org.forkclient.messenger.beta
- **aka** org.aka.messenger
- **TurboTel Pro** ellipi.messenger
- **Catogram X** org.nift4.catox
- **OwlGram** it.owlgram.android

## License
## Unsupported clients
These mods have a built-in Xposed protection
which is *impossible* to bypass.

| Name | Package |
|:--------:|:-----------------------|
| Nekogram | `tw.nekomimi.nekogram` |
| OwlGram | `it.owlgram.android` |

This project is licensed under the [GNU General Public Licence, version 3](https://choosealicense.com/licenses/gpl-3.0/).
## License
This project is licensed under the
[GNU General Public Licence, version 3](https://www.gnu.org/licenses/gpl-3.0.txt).
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ plugins {
}

android {
compileSdk 31
compileSdk 33

defaultConfig {
applicationId "com.shatyuka.killergram"
minSdk 16
targetSdk 31
targetSdk 33
versionCode appVerCode.toInteger()
versionName appVerName
}
Expand All @@ -25,6 +25,7 @@ android {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.debug
}
}
compileOptions {
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round">
android:label="@string/app_name">

<meta-data
android:name="xposedmodule"
Expand Down
76 changes: 43 additions & 33 deletions app/src/main/java/com/shatyuka/killergram/MainHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,62 @@

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;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;

public class MainHook implements IXposedHookLoadPackage {

public final static List<String> hookPackages = Arrays.asList(
"org.telegram.messenger",
"org.telegram.messenger.web",
"org.telegram.messenger.beta",
"nekox.messenger",
"org.forkclient.messenger",
"org.forkclient.messenger.beta",
"com.exteragram.messenger",
"com.exteragram.messenger.beta",
"org.telegram.mdgram",
"org.telegram.mdgramyou",
"org.telegram.BifToGram",
"ua.itaysonlab.messenger",
"org.nift4.catox",
"top.qwq2333.nullgram",
"com.cool2645.nekolite",
"me.ninjagram.messenger",
"org.ninjagram.messenger",
"ir.ilmili.telegraph",
"org.telegram.plus",
"com.iMe.android",
"org.telegram.BifToGram",
"ua.itaysonlab.messenger",
"org.forkclient.messenger",
"org.forkclient.messenger.beta",
"org.aka.messenger",
"ellipi.messenger",
"org.nift4.catox",
"it.owlgram.android");
"it.belloworld.mercurygram"
);

@Override
public void handleLoadPackage(final XC_LoadPackage.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 (chatUIActivityClass != null) {
XposedBridge.hookAllMethods(chatUIActivityClass, "addSponsoredMessages", XC_MethodReplacement.returnConstant(null));
}
Class<?> SharedConfigClass = XposedHelpers.findClassIfExists("org.telegram.messenger.SharedConfig", lpparam.classLoader);
if (SharedConfigClass != null) {
XposedBridge.hookAllMethods(SharedConfigClass, "getDevicePerformanceClass", XC_MethodReplacement.returnConstant(2));
}
Class<?> UserConfigClass = XposedHelpers.findClassIfExists("org.telegram.messenger.UserConfig", lpparam.classLoader);
if (UserConfigClass != null) {
XposedBridge.hookAllMethods(UserConfigClass, "getMaxAccountCount", XC_MethodReplacement.returnConstant(999));
XposedBridge.hookAllMethods(UserConfigClass, "hasPremiumOnAccounts", XC_MethodReplacement.returnConstant(true));
}
} catch (Throwable ignored) {
}
}
public void handleLoadPackage(final LoadPackageParam lpparam) {

if (!hookPackages.contains(lpparam.packageName)) return;

XposedClass messagesController = new XposedClass("org.telegram.messenger.MessagesController", lpparam.classLoader);
messagesController.hookAllMethods("getSponsoredMessages", XC_MethodReplacement.returnConstant(null));
messagesController.hookAllMethods("isChatNoForwards", XC_MethodReplacement.returnConstant(false));

XposedClass chatUIActivity = new XposedClass("org.telegram.ui.ChatActivity", lpparam.classLoader);
chatUIActivity.hookAllMethods("addSponsoredMessages", XC_MethodReplacement.returnConstant(null));

XposedClass sponsoredMessages = new XposedClass("org.telegram.tgnet.TLRPC$messages_SponsoredMessages", lpparam.classLoader);
sponsoredMessages.hookAllMethods("TLdeserialize", XC_MethodReplacement.returnConstant(null));

XposedClass getSponsoredMessages = new XposedClass("org.telegram.tgnet.TLRPC$TL_channels_getSponsoredMessages", lpparam.classLoader);
getSponsoredMessages.hookAllMethods("a", XC_MethodReplacement.returnConstant(null));

XposedClass chat = new XposedClass("org.telegram.tgnet.TLRPC$Chat", lpparam.classLoader);
chat.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));
}
}
26 changes: 26 additions & 0 deletions app/src/main/java/com/shatyuka/killergram/NoForwardsHook.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
24 changes: 24 additions & 0 deletions app/src/main/java/com/shatyuka/killergram/XposedClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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);
}
}
}
30 changes: 0 additions & 30 deletions app/src/main/res/drawable-v24/ic_launcher_foreground.xml

This file was deleted.

Loading