mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-05-29 13:00:17 +02:00
feat: gallery media send override
This commit is contained in:
parent
e4ebb324fb
commit
bcaa7b78ae
@ -38,7 +38,7 @@
|
||||
"hide_typing_notification": "Hide Typing Notification",
|
||||
"menu_slot_id": "Friend Menu Slot ID",
|
||||
"message_preview_length": "Message Preview Length",
|
||||
"external_media_as_snap": "External Media As Snap",
|
||||
"gallery_media_send_override": "Gallery Media Send Override",
|
||||
"auto_save": "Auto Save",
|
||||
"anti_auto_save": "Anti Auto Save Button",
|
||||
"snapchat_plus": "Snapchat Plus",
|
||||
|
@ -134,11 +134,14 @@ enum class ConfigProperty(
|
||||
ConfigIntegerValue(20)
|
||||
),
|
||||
|
||||
EXTERNAL_MEDIA_AS_SNAP(
|
||||
"property.external_media_as_snap",
|
||||
"description.external_media_as_snap",
|
||||
GALLERY_MEDIA_SEND_OVERRIDE(
|
||||
"property.gallery_media_send_override",
|
||||
"description.gallery_media_send_override",
|
||||
ConfigCategory.EXTRAS,
|
||||
ConfigStateValue(false)
|
||||
ConfigStateSelection(
|
||||
listOf("OFF", "NOTE", "SNAP"),
|
||||
"OFF"
|
||||
)
|
||||
),
|
||||
AUTO_SAVE("property.auto_save", "description.auto_save", ConfigCategory.EXTRAS, ConfigStateValue(false)),
|
||||
ANTI_AUTO_SAVE("property.anti_auto_save", "description.anti_auto_save", ConfigCategory.EXTRAS, ConfigStateValue(false)),
|
||||
|
@ -1,47 +0,0 @@
|
||||
package me.rhunk.snapenhance.features.impl.extras
|
||||
|
||||
import me.rhunk.snapenhance.config.ConfigProperty
|
||||
import me.rhunk.snapenhance.data.ContentType
|
||||
import me.rhunk.snapenhance.data.wrapper.impl.MessageContent
|
||||
import me.rhunk.snapenhance.features.Feature
|
||||
import me.rhunk.snapenhance.features.FeatureLoadParams
|
||||
import me.rhunk.snapenhance.hook.HookStage
|
||||
import me.rhunk.snapenhance.hook.Hooker
|
||||
import me.rhunk.snapenhance.util.protobuf.ProtoReader
|
||||
import me.rhunk.snapenhance.util.protobuf.ProtoWriter
|
||||
|
||||
class ExternalMediaAsSnap : Feature("External Media As Snap", loadParams = FeatureLoadParams.INIT_SYNC) {
|
||||
private val redSnapProto: ByteArray by lazy {
|
||||
ProtoWriter().apply {
|
||||
write(11, 5) {
|
||||
write(1) {
|
||||
write(1) {
|
||||
writeConstant(2, 0)
|
||||
writeConstant(12, 0)
|
||||
writeConstant(15, 0)
|
||||
}
|
||||
writeConstant(6, 0)
|
||||
}
|
||||
write(2) {
|
||||
writeConstant(5, 0)
|
||||
writeBuffer(6, byteArrayOf())
|
||||
}
|
||||
}
|
||||
}.toByteArray()
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
Hooker.hook(context.classCache.conversationManager, "sendMessageWithContent", HookStage.BEFORE, {
|
||||
context.config.bool(ConfigProperty.EXTERNAL_MEDIA_AS_SNAP)
|
||||
}) { param ->
|
||||
val localMessageContent = MessageContent(param.arg(1))
|
||||
|
||||
if (localMessageContent.contentType != ContentType.EXTERNAL_MEDIA) return@hook
|
||||
//story replies
|
||||
if (ProtoReader(localMessageContent.content).exists(7)) return@hook
|
||||
|
||||
localMessageContent.contentType = ContentType.SNAP
|
||||
localMessageContent.content = redSnapProto
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package me.rhunk.snapenhance.features.impl.extras
|
||||
|
||||
import me.rhunk.snapenhance.Logger
|
||||
import me.rhunk.snapenhance.config.ConfigProperty
|
||||
import me.rhunk.snapenhance.data.ContentType
|
||||
import me.rhunk.snapenhance.data.wrapper.impl.MessageContent
|
||||
import me.rhunk.snapenhance.features.Feature
|
||||
import me.rhunk.snapenhance.features.FeatureLoadParams
|
||||
import me.rhunk.snapenhance.hook.HookStage
|
||||
import me.rhunk.snapenhance.hook.Hooker
|
||||
import me.rhunk.snapenhance.util.protobuf.ProtoReader
|
||||
import me.rhunk.snapenhance.util.protobuf.ProtoWriter
|
||||
|
||||
class GalleryMediaSendOverride : Feature("Gallery Media Send Override", loadParams = FeatureLoadParams.INIT_SYNC) {
|
||||
private val redSnapProto: ByteArray by lazy {
|
||||
ProtoWriter().apply {
|
||||
write(11, 5) {
|
||||
write(1) {
|
||||
write(1) {
|
||||
writeConstant(2, 0)
|
||||
writeConstant(12, 0)
|
||||
writeConstant(15, 0)
|
||||
}
|
||||
writeConstant(6, 0)
|
||||
}
|
||||
write(2) {
|
||||
writeConstant(5, 0)
|
||||
writeBuffer(6, byteArrayOf())
|
||||
}
|
||||
}
|
||||
}.toByteArray()
|
||||
}
|
||||
|
||||
private val audioNoteProto: (Int) -> ByteArray = { duration ->
|
||||
ProtoWriter().apply {
|
||||
write(6, 1) {
|
||||
write(1) {
|
||||
writeConstant(2, 4)
|
||||
write(5) {
|
||||
writeConstant(1, 0)
|
||||
writeConstant(2, 0)
|
||||
}
|
||||
writeConstant(7, 0)
|
||||
writeConstant(13, duration)
|
||||
}
|
||||
}
|
||||
}.toByteArray()
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
Hooker.hook(context.classCache.conversationManager, "sendMessageWithContent", HookStage.BEFORE) { param ->
|
||||
val localMessageContent = MessageContent(param.arg(1))
|
||||
|
||||
if (localMessageContent.contentType != ContentType.EXTERNAL_MEDIA) return@hook
|
||||
//story replies
|
||||
val messageProtoReader = ProtoReader(localMessageContent.content)
|
||||
if (messageProtoReader.exists(7)) return@hook
|
||||
|
||||
when (context.config.state(ConfigProperty.GALLERY_MEDIA_SEND_OVERRIDE)) {
|
||||
"SNAP" -> {
|
||||
localMessageContent.contentType = ContentType.SNAP
|
||||
localMessageContent.content = redSnapProto
|
||||
}
|
||||
"NOTE" -> {
|
||||
localMessageContent.contentType = ContentType.NOTE
|
||||
val mediaDuration = messageProtoReader.getInt(3, 3, 5, 1, 1, 15) ?: 0
|
||||
localMessageContent.content = audioNoteProto(mediaDuration)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@ import me.rhunk.snapenhance.features.impl.downloader.MediaDownloader
|
||||
import me.rhunk.snapenhance.features.impl.extras.AntiAutoSave
|
||||
import me.rhunk.snapenhance.features.impl.extras.AutoSave
|
||||
import me.rhunk.snapenhance.features.impl.extras.DisableVideoLengthRestriction
|
||||
import me.rhunk.snapenhance.features.impl.extras.ExternalMediaAsSnap
|
||||
import me.rhunk.snapenhance.features.impl.extras.GalleryMediaSendOverride
|
||||
import me.rhunk.snapenhance.features.impl.extras.MediaQualityLevelOverride
|
||||
import me.rhunk.snapenhance.features.impl.extras.Notifications
|
||||
import me.rhunk.snapenhance.features.impl.extras.SnapchatPlus
|
||||
@ -66,7 +66,7 @@ class FeatureManager(private val context: ModContext) : Manager {
|
||||
register(UITweaks::class)
|
||||
register(ConfigEnumKeys::class)
|
||||
register(AntiAutoDownload::class)
|
||||
register(ExternalMediaAsSnap::class)
|
||||
register(GalleryMediaSendOverride::class)
|
||||
register(AntiAutoSave::class)
|
||||
register(UnlimitedSnapViewTime::class)
|
||||
register(DisableVideoLengthRestriction::class)
|
||||
|
Loading…
x
Reference in New Issue
Block a user