refactor: location spoofer

This commit is contained in:
rhunk
2023-10-11 16:53:53 +02:00
parent 1a7755e45c
commit 32a458a690
15 changed files with 238 additions and 257 deletions

View File

@ -356,6 +356,16 @@
"name": "Global",
"description": "Tweak Global Snapchat Settings",
"properties": {
"spoofLocation": {
"name": "Location",
"description": "Spoof your location",
"properties": {
"coordinates": {
"name": "Coordinates",
"description": "Set the coordinates"
}
}
},
"snapchat_plus": {
"name": "Snapchat Plus",
"description": "Enables Snapchat Plus features\nSome Server-sided features may not work"
@ -464,20 +474,6 @@
"name": "Spoof",
"description": "Spoof various information about you",
"properties": {
"location": {
"name": "Location",
"description": "Spoof your location",
"properties": {
"location_latitude": {
"name": "Latitude",
"description": "The latitude of the location"
},
"location_longitude": {
"name": "Longitude",
"description": "The longitude of the location"
}
}
},
"device": {
"name": "Device",
"description": "Spoof your device information",

View File

@ -8,8 +8,7 @@ enum class EnumAction(
val isCritical: Boolean = false,
) {
CLEAN_CACHE("clean_snapchat_cache", exitOnFinish = true),
EXPORT_CHAT_MESSAGES("export_chat_messages"),
OPEN_MAP("open_map");
EXPORT_CHAT_MESSAGES("export_chat_messages");
companion object {
const val ACTION_PARAMETER = "se_action"

View File

@ -60,6 +60,12 @@ open class ConfigContainer(
container.parentContainerKey = it
}.get()
protected fun mapCoordinates(
key: String,
defaultValue: Pair<Double, Double> = 0.0 to 0.0,
params: ConfigParamsBuilder = {}
) = registerProperty(key, DataProcessors.MAP_COORDINATES, PropertyValue(defaultValue), params)
fun toJson(): JsonObject {
val json = JsonObject()
properties.forEach { (propertyKey, propertyValue) ->

View File

@ -14,6 +14,7 @@ object DataProcessors {
FLOAT,
STRING_MULTIPLE_SELECTION,
STRING_UNIQUE_SELECTION,
MAP_COORDINATES,
CONTAINER,
}
@ -75,6 +76,20 @@ object DataProcessors {
deserialize = { obj -> obj.takeIf { !it.isJsonNull }?.asString }
)
val MAP_COORDINATES = PropertyDataProcessor(
type = Type.MAP_COORDINATES,
serialize = {
JsonObject().apply {
addProperty("lat", it.first)
addProperty("lng", it.second)
}
},
deserialize = { obj ->
val jsonObject = obj.asJsonObject
jsonObject["lat"].asDouble to jsonObject["lng"].asDouble
},
)
fun <T : ConfigContainer> container(container: T) = PropertyDataProcessor(
type = Type.CONTAINER,
serialize = {

View File

@ -4,6 +4,10 @@ import me.rhunk.snapenhance.common.config.ConfigContainer
import me.rhunk.snapenhance.common.config.FeatureNotice
class Global : ConfigContainer() {
inner class SpoofLocation : ConfigContainer(hasGlobalState = true) {
val coordinates = mapCoordinates("coordinates", 0.0 to 0.0) { requireRestart()} // lat, long
}
val spoofLocation = container("spoofLocation", SpoofLocation())
val snapchatPlus = boolean("snapchat_plus") { addNotices(FeatureNotice.BAN_RISK); requireRestart() }
val disableMetrics = boolean("disable_metrics")
val blockAds = boolean("block_ads")

View File

@ -4,12 +4,6 @@ import me.rhunk.snapenhance.common.config.ConfigContainer
import me.rhunk.snapenhance.common.config.FeatureNotice
class Spoof : ConfigContainer() {
inner class Location : ConfigContainer(hasGlobalState = true) {
val latitude = float("location_latitude")
val longitude = float("location_longitude")
}
val location = container("location", Location())
inner class Device : ConfigContainer(hasGlobalState = true) {
val fingerprint = string("fingerprint")
val androidId = string("android_id")