mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-05-24 02:22:16 +02:00
feat(Messenger): Add Remove Meta AI
patch (#4945)
This commit is contained in:
parent
42d2c27798
commit
012dff7b65
3
extensions/messenger/build.gradle.kts
Normal file
3
extensions/messenger/build.gradle.kts
Normal file
@ -0,0 +1,3 @@
|
||||
dependencies {
|
||||
compileOnly(project(":extensions:shared:library"))
|
||||
}
|
1
extensions/messenger/src/main/AndroidManifest.xml
Normal file
1
extensions/messenger/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1 @@
|
||||
<manifest/>
|
@ -0,0 +1,15 @@
|
||||
package app.revanced.extension.messenger.metaai;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class RemoveMetaAIPatch {
|
||||
public static boolean overrideConfigBool(long id, boolean value) {
|
||||
// It seems like all configs starting with 363219 are related to Meta AI.
|
||||
// A list of specific ones that need disabling would probably be better,
|
||||
// but these config numbers seem to change slightly with each update.
|
||||
// These first 6 digits don't though.
|
||||
if (Long.toString(id).startsWith("363219"))
|
||||
return false;
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
@ -284,6 +284,14 @@ public final class app/revanced/patches/messenger/inputfield/DisableTypingIndica
|
||||
public static final fun getDisableTypingIndicatorPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/messenger/metaai/RemoveMetaAIPatchKt {
|
||||
public static final fun getRemoveMetaAIPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/messenger/misc/extension/ExtensionPatchKt {
|
||||
public static final fun getSharedExtensionPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/messenger/navbar/RemoveMetaAITabPatchKt {
|
||||
public static final fun getRemoveMetaAITabPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
package app.revanced.patches.messenger.metaai
|
||||
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import app.revanced.patcher.fingerprint
|
||||
|
||||
internal val getMobileConfigBoolFingerprint = fingerprint {
|
||||
parameters("J")
|
||||
returns("Z")
|
||||
opcodes(Opcode.RETURN)
|
||||
custom { method, classDef ->
|
||||
method.implementation ?: return@custom false // unsure if this is necessary
|
||||
classDef.interfaces.contains("Lcom/facebook/mobileconfig/factory/MobileConfigUnsafeContext;")
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package app.revanced.patches.messenger.metaai
|
||||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patches.messenger.misc.extension.sharedExtensionPatch
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/messenger/metaai/RemoveMetaAIPatch;"
|
||||
|
||||
@Suppress("unused")
|
||||
val removeMetaAIPatch = bytecodePatch(
|
||||
name = "Remove Meta AI",
|
||||
description = "Removes UI elements related to Meta AI."
|
||||
) {
|
||||
compatibleWith("com.facebook.orca")
|
||||
|
||||
dependsOn(sharedExtensionPatch)
|
||||
|
||||
execute {
|
||||
getMobileConfigBoolFingerprint.method.apply {
|
||||
val returnIndex = getMobileConfigBoolFingerprint.patternMatch!!.startIndex
|
||||
val returnRegister = getInstruction<OneRegisterInstruction>(returnIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
returnIndex,
|
||||
"""
|
||||
invoke-static {p1, p2, v$returnRegister}, $EXTENSION_CLASS_DESCRIPTOR->overrideConfigBool(JZ)Z
|
||||
|
||||
move-result v$returnRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package app.revanced.patches.messenger.misc.extension
|
||||
|
||||
import app.revanced.patches.shared.misc.extension.sharedExtensionPatch
|
||||
|
||||
val sharedExtensionPatch = sharedExtensionPatch("messenger", mainActivityOnCreateHook)
|
@ -0,0 +1,7 @@
|
||||
package app.revanced.patches.messenger.misc.extension
|
||||
|
||||
import app.revanced.patches.shared.misc.extension.extensionHook
|
||||
|
||||
internal val mainActivityOnCreateHook = extensionHook {
|
||||
strings("MainActivity_onCreate_begin")
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package app.revanced.patches.messenger.navbar
|
||||
|
||||
import app.revanced.patcher.fingerprint
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
internal val createTabConfigurationFingerprint = fingerprint {
|
||||
strings("MessengerTabConfigurationCreator.createTabConfiguration")
|
||||
opcodes(
|
||||
Opcode.INVOKE_DIRECT,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.IF_EQZ,
|
||||
Opcode.INVOKE_DIRECT,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.IF_EQZ,
|
||||
)
|
||||
}
|
@ -1,25 +1,12 @@
|
||||
package app.revanced.patches.messenger.navbar
|
||||
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import app.revanced.patches.messenger.metaai.removeMetaAIPatch
|
||||
|
||||
@Deprecated("Superseded by removeMetaAIPatch", ReplaceWith("removeMetaAIPatch"))
|
||||
@Suppress("unused")
|
||||
val removeMetaAITabPatch = bytecodePatch(
|
||||
name = "Remove Meta AI tab",
|
||||
description = "Removes the 'Meta AI' tab from the navbar.",
|
||||
) {
|
||||
compatibleWith("com.facebook.orca")
|
||||
|
||||
execute {
|
||||
createTabConfigurationFingerprint.let {
|
||||
val moveResultIndex = it.patternMatch!!.startIndex + 1
|
||||
val enabledRegister = it.method.getInstruction<OneRegisterInstruction>(moveResultIndex).registerA
|
||||
it.method.replaceInstruction(
|
||||
moveResultIndex,
|
||||
"const/4 v$enabledRegister, 0x0"
|
||||
)
|
||||
}
|
||||
}
|
||||
dependsOn(removeMetaAIPatch)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user