Skip to content

Commit

Permalink
Enhance GhostMode
Browse files Browse the repository at this point in the history
  • Loading branch information
Keeperorowner committed Dec 23, 2024
1 parent afb9e54 commit f037133
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 62 deletions.
3 changes: 0 additions & 3 deletions app/src/main/java/cc/ioctl/tmoe/fragment/SettingsFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ class SettingsFragment : BaseHierarchyFragment() {
GhostMode,"GhostMode", R.string.GhostMode,
"GhostModeDesc", R.string.GhostModeDesc
)
functionSwitch(
BoostSpeed,"BoostSpeed", R.string.BoostSpeed
)
functionSwitch(
AntiAntiForward, "AntiAntiForward", R.string.AntiAntiForward,
"RestrictContentMitigationDesc", R.string.RestrictContentMitigationDesc
Expand Down
51 changes: 0 additions & 51 deletions app/src/main/java/cc/ioctl/tmoe/hook/func/BoostSpeed.kt

This file was deleted.

47 changes: 39 additions & 8 deletions app/src/main/java/cc/ioctl/tmoe/hook/func/GhostMode.kt
Original file line number Diff line number Diff line change
@@ -1,31 +1,62 @@
package cc.ioctl.tmoe.hook.func;
package cc.ioctl.tmoe.hook.func

import cc.ioctl.tmoe.base.annotation.FunctionHookEntry
import cc.ioctl.tmoe.hook.base.CommonDynamicHook
import com.github.kyuubiran.ezxhelper.utils.*
import de.robv.android.xposed.XposedHelpers

@FunctionHookEntry
object GhostMode : CommonDynamicHook() {
override fun initOnce(): Boolean = tryOrFalse {
findMethod(loadClass("org.telegram.messenger.MessagesController")){
name=="completeReadTask"
// 原有的已读消息hook
findMethod(loadClass("org.telegram.messenger.MessagesController")) {
name == "completeReadTask"
}.hookBefore {
if (!isEnabled)return@hookBefore
if (!isEnabled) return@hookBefore
it.result = null
}

findMethod(loadClass("org.telegram.ui.ChatActivity\$ChatActivityEnterViewDelegate")){
name=="needSendTyping"

findMethod(loadClass("org.telegram.ui.ChatActivity\$ChatActivityEnterViewDelegate")) {
name == "needSendTyping"
}.hookBefore {
if (!isEnabled) return@hookBefore
it.result = null
}

findMethod(loadClass("org.telegram.ui.Stories.StoriesController")){
name=="markStoryAsRead"

findMethod(loadClass("org.telegram.ui.Stories.StoriesController")) {
name == "markStoryAsRead"
}.hookBefore {
if (!isEnabled) return@hookBefore
it.result = false
}

findMethod(loadClass("org.telegram.tgnet.ConnectionsManager")) {
name == "sendRequestInternal" &&
parameterTypes.size == 10 &&
parameterTypes[0] == loadClass("org.telegram.tgnet.TLObject") &&
parameterTypes[1] == loadClass("org.telegram.tgnet.RequestDelegate") &&
parameterTypes[2] == loadClass("org.telegram.tgnet.RequestDelegateTimestamp") &&
parameterTypes[3] == loadClass("org.telegram.tgnet.QuickAckDelegate") &&
parameterTypes[4] == loadClass("org.telegram.tgnet.WriteToSocketDelegate") &&
parameterTypes[5] == Integer.TYPE &&
parameterTypes[6] == Integer.TYPE &&
parameterTypes[7] == Integer.TYPE &&
parameterTypes[8] == java.lang.Boolean.TYPE &&
parameterTypes[9] == Integer.TYPE
}.hookBefore { param ->
if (!isEnabled) return@hookBefore

try {
val updateStatusClass = loadClass("org.telegram.tgnet.TLRPC\$TL_account_updateStatus")
val requestObject = param.args[0]

if (updateStatusClass.isInstance(requestObject)) {
XposedHelpers.setBooleanField(requestObject, "offline", true)
}
} catch (_: Exception) {
}
}
}
}

0 comments on commit f037133

Please sign in to comment.